Skip to main content

TimeLimitRule

Struct TimeLimitRule 

Source
pub struct TimeLimitRule { /* private fields */ }
Expand description

Stops the search once the time limit is reached.

It also serves as the search’s clock. When made relaxable, reaching the limit ends the current pass and the clock restarts for the next one.

Implementations§

Source§

impl TimeLimitRule

Source

pub fn new(time_limit: f64) -> Self

A rule that stops the search after time_limit seconds.

Source

pub fn relaxable(self) -> Self

Makes the limit apply per pass rather than to the whole search.

Source

pub fn elapsed_seconds(&self) -> f64

Seconds since the rule was activated or reset.

Source

pub fn remaining_seconds(&self) -> f64

Seconds left before the limit, never negative.

Source

pub fn exhausted(&self) -> bool

Whether the limit is reached.

Trait Implementations§

Source§

impl Debug for TimeLimitRule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TimeLimitRule

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Rule for TimeLimitRule

Source§

fn evaluate(&self, _context: &RuleContext) -> RuleResult

Decides whether the search continues below the node.
Source§

fn priority(&self) -> u8

Rules with a higher priority are evaluated first.
Source§

fn description(&self) -> String

A short human-readable name.
Source§

fn state(&self) -> RuleState

The current state of the rule.
Source§

fn activate(&mut self)

Starts applying the rule; called before the first pass.
Source§

fn deactivate(&mut self)

Stops applying the rule.
Source§

fn reset(&mut self)

Resets any internal state, such as a timer.
Source§

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)

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

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Mutable upcast used by RuleManager::get_rule_mut.
Source§

fn is_active(&self) -> bool

Whether the rule is applied.
Source§

fn delay(&self) -> u8

Number of passes to wait before the rule takes effect.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.