pumpkin_solver

Module branching

Source
Expand description

Contains structures and traits to define the decision making procedure of the Solver.

In general, it provides 3 traits:

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§

Modules§

Structs§

  • The context provided to the Brancher, it allows the retrieval of domain values of variables and access to methods from a Random generator.

Traits§