pub struct GainRule { /* private fields */ }Expand description
Restricts a pass to the paths whose accumulated heuristic loss stays within a gap.
At each node, choosing a feature other than the best-ranked one loses
the difference between their heuristic scores. The rule cuts the paths
whose total loss exceeds the gap; relaxing it widens the gap by delta
times the next step of its StepStrategy, up to limit.
Implementations§
Source§impl GainRule
impl GainRule
Sourcepub fn new(
gap: f64,
delta: f64,
limit: f64,
increment: Box<dyn StepStrategy>,
) -> Self
pub fn new( gap: f64, delta: f64, limit: f64, increment: Box<dyn StepStrategy>, ) -> Self
A rule starting at gap, widened in steps of delta up to limit.
Sourcepub fn with_priority(self, priority: u8) -> Self
pub fn with_priority(self, priority: u8) -> Self
Sets the evaluation priority.
Sourcepub fn with_delay(self, delay: u8) -> Self
pub fn with_delay(self, delay: u8) -> Self
Sets the number of passes before the rule takes effect.
Sourcepub fn with_limit(self, limit: f64) -> Self
pub fn with_limit(self, limit: f64) -> Self
Sets the largest gap.
Sourcepub fn update_gap_delta(&mut self, delta: f64)
pub fn update_gap_delta(&mut self, delta: f64)
Sets the step of the gap; ignored unless positive. The search sets it to the smallest loss seen in the first pass.
Sourcepub fn update_limit(&mut self, limit: f64)
pub fn update_limit(&mut self, limit: f64)
Lowers the largest gap to limit.
Trait Implementations§
Source§impl Rule for GainRule
impl Rule for GainRule
Source§fn evaluate(&self, context: &RuleContext) -> RuleResult
fn evaluate(&self, context: &RuleContext) -> RuleResult
Decides whether the search continues below the node.
Source§fn description(&self) -> String
fn description(&self) -> String
A short human-readable name.
Source§fn deactivate(&mut self)
fn deactivate(&mut self)
Stops applying the rule.
Source§fn is_relaxable(&self) -> bool
fn is_relaxable(&self) -> bool
Whether the rule restricts the search only temporarily. A search whose
pass was cut by a relaxable rule is not finished.
Source§fn relax(&mut self)
fn relax(&mut self)
Widens the rule’s budget before the next pass, or deactivates it once
the budget is at its limit.
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Upcast used by
RuleManager::get_rule_mut.Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Mutable upcast used by
RuleManager::get_rule_mut.Auto Trait Implementations§
impl !RefUnwindSafe for GainRule
impl !UnwindSafe for GainRule
impl Freeze for GainRule
impl Send for GainRule
impl Sync for GainRule
impl Unpin for GainRule
impl UnsafeUnpin for GainRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more