Expand description
Contains structures and traits to define the decision making procedure of the Solver.
In general, it provides 3 traits:
- The
Brancherwhich defines how a branching procedure (which selects an unfixed variable and splits the domain in some way, see Section 4.3.1 of [1] for more information) should operate; the main method of this trait is theBrancher::next_decisionmethod. An example implementation of this trait is theIndependentVariableValueBrancher. - The
VariableSelectorwhich defines the method required of a variable selector (including the hooks into the solver); the main method of this trait is theVariableSelector::select_variablemethod. An example implementation of this trait is theVsidsstrategy. - The
ValueSelectorwhich defines the method required of a value selector (including the hooks into the solver); the main method of this trait is theValueSelector::select_valuemethod.
A Brancher is expected to be passed to Solver::satisfy, Solver::maximise, and
Solver::minimise:
let mut solver = Solver::default();
let variables = vec![solver.new_literal().get_propositional_variable()];
let mut termination = Indefinite;
let mut brancher = IndependentVariableValueBrancher::new(
Vsids::new(&variables),
PhaseSaving::new(&variables),
);
let result = solver.satisfy(&mut brancher, &mut termination);
if let SatisfactionResult::Satisfiable(solution) = result {
// Getting the value of the literal in the solution should not panic
variables.into_iter().for_each(|variable| {
solver.get_literal_value(Literal::new(variable, true));
});
} else {
panic!("Solving should have returned satsifiable")
}A default implementation of a Brancher
is provided using the method
Solver::default_brancher_over_all_propositional_variables.
let mut solver = Solver::default();
let literals = vec![solver.new_literal()];
let mut termination = Indefinite;
let mut brancher = solver.default_brancher_over_all_propositional_variables();
let result = solver.satisfy(&mut brancher, &mut termination);
if let SatisfactionResult::Satisfiable(solution) = result {
// Getting the value of the literal in the solution should not panic
literals.into_iter().for_each(|literal| {
solution.get_literal_value(literal);
})
} else {
panic!("Solving should have returned satsifiable")
}[1] F. Rossi, P. Van Beek, and T. Walsh, Handbook of constraint programming. Elsevier, 2006.
Re-exports§
pub use tie_breaking::*;pub use value_selection::*;pub use variable_selection::*;
Modules§
- Provides several implementations of
Branchers. - Contains structures for tie-breaking
- Provides the
ValueSelectortrait which is required for value selectors to implement; the main method in this trait relies onValueSelector::select_value. - Provides the
VariableSelectortrait which is required for variable selectors to implement; the main method in this trait relies onVariableSelector::select_variable.
Structs§
Traits§
- A trait for definining a branching strategy (oftentimes utilising a
VariableSelectorand aValueSelector).