ValueSelector

Trait ValueSelector 

Source
pub trait ValueSelector<Var> {
    // Required methods
    fn select_value(
        &mut self,
        context: &mut SelectionContext<'_>,
        decision_variable: Var,
    ) -> Predicate;
    fn subscribe_to_events(&self) -> Vec<BrancherEvent>;

    // Provided methods
    fn on_unassign_integer(&mut self, _variable: DomainId, _value: i32) { ... }
    fn on_solution(&mut self, _solution: SolutionReference<'_>) { ... }
    fn is_restart_pointless(&mut self) -> bool { ... }
}
Expand description

A trait containing the interface for ValueSelectors, specifying the appropriate hooks into the solver and the methods required for selecting a value for a given variable.

Required Methods§

Source

fn select_value( &mut self, context: &mut SelectionContext<'_>, decision_variable: Var, ) -> Predicate

Determines which value in the domain of decision_variable to branch next on. The domain of the decision_variable variable should have at least 2 values in it (as it otherwise should not have been selected as decision_variable). Returns a Predicate specifying the required change in the domain.

Source

fn subscribe_to_events(&self) -> Vec<BrancherEvent>

Indicates which BrancherEvent are relevant for this particular ValueSelector.

This can be used by [Brancher::subscribe_to_events] to determine upon which events which ValueSelector should be called.

Provided Methods§

Source

fn on_unassign_integer(&mut self, _variable: DomainId, _value: i32)

A function which is called after a DomainId is unassigned during backtracking (i.e. when it was fixed but is no longer), specifically, it provides variable which is the DomainId which has been reset and value which is the value to which the variable was previously fixed. This method could thus be called multiple times in a single backtracking operation by the solver.

To receive information about this event, use BrancherEvent::UnassignInteger in Self::subscribe_to_events

Source

fn on_solution(&mut self, _solution: SolutionReference<'_>)

This method is called when a solution is found; either when iterating over all solutions in the case of a satisfiable problem or on solutions of increasing quality when solving an optimisation problem.

To receive information about this event, use BrancherEvent::Solution in Self::subscribe_to_events

Source

fn is_restart_pointless(&mut self) -> bool

This method returns whether a restart is currently pointless for the ValueSelector.

For example, if a ValueSelector is using a static strategy (e.g. [InDomainMin]) then a restart is pointless; however, for a ValueSelector like [InDomainRandom] which changes throughout the search process restarting is not pointless.

Note that even if the ValueSelector has indicated that a restart is pointless, it could be that the restart is still performed.

Implementors§