pub trait VariableSelector<Var> {
// Required methods
fn select_variable(
&mut self,
context: &mut SelectionContext<'_>,
) -> Option<Var>;
fn subscribe_to_events(&self) -> Vec<BrancherEvent>;
// Provided methods
fn on_conflict(&mut self) { ... }
fn on_backtrack(&mut self) { ... }
fn on_unassign_integer(&mut self, _variable: DomainId, _value: i32) { ... }
fn on_appearance_in_conflict_predicate(&mut self, _predicate: Predicate) { ... }
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§
Sourcefn select_variable(&mut self, context: &mut SelectionContext<'_>) -> Option<Var>
fn select_variable(&mut self, context: &mut 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.
Sourcefn subscribe_to_events(&self) -> Vec<BrancherEvent>
fn subscribe_to_events(&self) -> Vec<BrancherEvent>
Indicates which BrancherEvent are relevant for this particular VariableSelector.
This can be used by [Brancher::subscribe_to_events] to determine upon which
events which VariableSelector should be called.
Provided Methods§
Sourcefn on_conflict(&mut self)
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.
To receive information about this event, use BrancherEvent::Conflict in
Self::subscribe_to_events
Sourcefn on_backtrack(&mut self)
fn on_backtrack(&mut self)
A function which is called whenever a backtrack occurs in the solver.
To receive information about this event, use BrancherEvent::Backtrack in
Self::subscribe_to_events
Sourcefn on_unassign_integer(&mut self, _variable: DomainId, _value: i32)
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.
To receive information about this event, use BrancherEvent::UnassignInteger in
Self::subscribe_to_events
Sourcefn on_appearance_in_conflict_predicate(&mut self, _predicate: Predicate)
fn on_appearance_in_conflict_predicate(&mut self, _predicate: Predicate)
A function which is called when a Predicate appears in a conflict during conflict
analysis.
To receive information about this event, use
BrancherEvent::AppearanceInConflictPredicate in Self::subscribe_to_events
Sourcefn is_restart_pointless(&mut self) -> bool
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 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.