pub trait VariableSelection<L: Literal>: Debug + Clone {
// Required methods
fn new<C: AsRef<[L]>>(num_vars: usize, vars: &[L], clauses: &[C]) -> Self;
fn pick<A: Assignment>(&mut self, assignment: &A) -> Option<L>;
fn bumps<T: IntoIterator<Item = L>>(&mut self, vars: T);
fn decay(&mut self, decay: f64);
fn decisions(&self) -> usize;
}Expand description
Trait defining the interface for variable selection strategies.
Implementors of this trait decide which unassigned variable to choose next for a decision and, implicitly or explicitly, which polarity to assign to it.
§Type Parameters
L: TheLiteraltype used by the solver.
Required Methods§
Sourcefn new<C: AsRef<[L]>>(num_vars: usize, vars: &[L], clauses: &[C]) -> Self
fn new<C: AsRef<[L]>>(num_vars: usize, vars: &[L], clauses: &[C]) -> Self
Creates a new instance of the variable selection strategy.
§Parameters
num_vars: The total number of variables in the SAT problem.vars: A slice of all literals (often used for initial setup, though not all strategies use it).clauses: A slice of clauses in the SAT problem. Some strategies use this to initialise scores.
Sourcefn pick<A: Assignment>(&mut self, assignment: &A) -> Option<L>
fn pick<A: Assignment>(&mut self, assignment: &A) -> Option<L>
Picks an unassigned variable for the next decision.
Returns Some(L) with the chosen literal (variable and its assigned polarity)
if an unassigned variable can be found. Returns None if all variables
relevant to the strategy are assigned.
§Parameters
assignment: The current state of variable assignments in the solver.
Sourcefn bumps<T: IntoIterator<Item = L>>(&mut self, vars: T)
fn bumps<T: IntoIterator<Item = L>>(&mut self, vars: T)
Increases the activity score of the specified variables.
This is called when a conflict is analysed, and the variables involved in the conflict (or the learned clause) are “rewarded”.
§Parameters
vars: An iterator over literals whose activity should be bumped.
Sourcefn decay(&mut self, decay: f64)
fn decay(&mut self, decay: f64)
Decays the activity scores of all variables.
This is periodically called to give more weight to recently active variables. The exact mechanism can vary (e.g. multiplying all scores by a factor, or increasing an activity increment).
§Parameters
decay: The decay factor. The interpretation of this factor depends on the specific strategy. For VSIDS-like strategies, it’s typically a value slightly less than 1 (e.g. 0.95), andactivity_incis divided by this factor.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl<L: Literal> VariableSelection<L> for VariableSelectionImpls
impl<L: Literal> VariableSelection<L> for FixedOrder
impl<L: Literal> VariableSelection<L> for JeroslowWangOneSided
impl<L: Literal> VariableSelection<L> for JeroslowWangTwoSided
impl<L: Literal> VariableSelection<L> for RandomOrder
VariableSelection trait implementation for the random order variable selection strategy.
impl<L: Literal> VariableSelection<L> for VsidsHeap
VariableSelection trait implementation for the VSIDS heap.
impl<L: Literal, const E: bool> VariableSelection<L> for Vsids<E>
VariableSelection trait implementation for the VSIDS variable selection strategy.