pumpkin_solver::branching::variable_selection

Trait VariableSelector

source
pub trait VariableSelector<Var> {
    // Required method
    fn select_variable(&mut self, context: &SelectionContext<'_>) -> Option<Var>;

    // Provided methods
    fn on_conflict(&mut self) { ... }
    fn on_unassign_literal(&mut self, _literal: Literal) { ... }
    fn on_unassign_integer(&mut self, _variable: DomainId, _value: i32) { ... }
    fn on_appearance_in_conflict_literal(&mut self, _literal: Literal) { ... }
    fn on_appearance_in_conflict_integer(&mut self, _variable: DomainId) { ... }
    fn is_restart_pointless(&mut self) -> bool { ... }
}
Expand description

A trait containing the interface for VariableSelectors, specifying the appropriate hooks into the solver and the methods required for selecting variables.

Required Methods§

source

fn select_variable(&mut self, context: &SelectionContext<'_>) -> Option<Var>

Determines which variable to select next if there are any left to branch on. Should only return None when all variables which have been passed to the VariableSelector have been assigned. Otherwise it should return the variable to branch on next.

Provided Methods§

source

fn on_conflict(&mut self)

A function which is called after a conflict has been found and processed but (currently) does not provide any additional information.

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. This method could thus be called multiple times in a single backtracking operation by the solver.

source

fn on_appearance_in_conflict_literal(&mut self, _literal: Literal)

A function which is called when a Literal appears in a conflict during conflict analysis.

source

fn on_appearance_in_conflict_integer(&mut self, _variable: DomainId)

A function which is called when a variable appears in a conflict during conflict analysis.

source

fn is_restart_pointless(&mut self) -> bool

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

For example, if a VariableSelector is using a static strategy (e.g. Smallest) then a restart is pointless; however, for a VariableSelector like Vsids which changes throughout the search process restarting is not pointless.

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

Implementors§

source§

impl VariableSelector<DomainId> for InputOrder<DomainId>

source§

impl VariableSelector<DomainId> for Vsids<DomainId>

source§

impl VariableSelector<PropositionalVariable> for InputOrder<PropositionalVariable>

source§

impl VariableSelector<PropositionalVariable> for Vsids<PropositionalVariable>

source§

impl<TieBreaking> VariableSelector<DomainId> for FirstFail<DomainId, TieBreaking>
where TieBreaking: TieBreaker<DomainId, i32>,

source§

impl<TieBreaking> VariableSelector<DomainId> for Largest<DomainId, TieBreaking>
where TieBreaking: TieBreaker<DomainId, i32>,

source§

impl<TieBreaking> VariableSelector<DomainId> for MaxRegret<DomainId, TieBreaking>
where TieBreaking: TieBreaker<DomainId, i32>,

source§

impl<TieBreaking> VariableSelector<DomainId> for MostConstrained<DomainId, TieBreaking>
where TieBreaking: TieBreaker<DomainId, MostConstrainedValue>,

source§

impl<TieBreaking> VariableSelector<DomainId> for Occurrence<DomainId, TieBreaking>
where TieBreaking: TieBreaker<DomainId, u32>,

source§

impl<TieBreaking> VariableSelector<DomainId> for Smallest<DomainId, TieBreaking>
where TieBreaking: TieBreaker<DomainId, i32>,

source§

impl<TieBreaking: TieBreaker<DomainId, i32>> VariableSelector<DomainId> for AntiFirstFail<DomainId, TieBreaking>

source§

impl<Var> VariableSelector<Var> for DynamicVariableSelector<Var>