pumpkin_solver::branching::value_selection

Trait ValueSelector

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

    // Provided methods
    fn on_unassign_literal(&mut self, _literal: Literal) { ... }
    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.

Provided Methods§

Source

fn on_unassign_literal(&mut self, _literal: Literal)

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

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.

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.

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§