Module constraints

Module constraints 

Source
Expand description

Defines the constraints that Pumpkin provides out of the box which can be added to the Solver.

A constraint is a relation over variables. In the solver, constraints are enforced through propagators, and therefore constraints can be viewed as a collection of propagators.

§Example

let mut solver = Solver::default();

let a = solver.new_bounded_integer(0, 3);
let b = solver.new_bounded_integer(0, 3);

// All constraints require a constraint tag.
let constraint_tag = solver.new_constraint_tag();

solver
    .add_constraint(constraints::equals([a, b], 0, constraint_tag))
    .post();

§Note

At the moment, the API for posting propagators is not yet publicly accessible as it is unstable. Consumers of the Pumpkin library can therefore only define constraints by decomposing them into the constraints that are predefined in the library. Once the propagator API is stabilized, it will become part of the public API.

Structs§

ConstraintPoster
A structure which is responsible for adding the created Constraints to the Solver. For an example on how to use this, see crate::constraints.

Traits§

Constraint
A Constraint is a relation over variables. It disqualifies certain partial assignments of making it into a solution of the problem.
NegatableConstraint
A Constraint which has a well-defined negation.

Functions§

absolute
Creates the Constraint |signed| = absolute.
all_different
Creates the Constraint that enforces that all the given variables are distinct.
binary_equals
Creates the NegatableConstraint lhs = rhs.
binary_greater_than
Creates the NegatableConstraint lhs > rhs.
binary_greater_than_or_equals
Creates the NegatableConstraint lhs >= rhs.
binary_less_than
Creates the NegatableConstraint lhs < rhs.
binary_less_than_or_equals
Creates the NegatableConstraint lhs <= rhs.
binary_not_equals
Creates the NegatableConstraint lhs != rhs.
boolean_equals
Creates the Constraint \sum weights_i * bools_i == rhs.
boolean_less_than_or_equals
Creates the Constraint \sum weights_i * bools_i <= rhs.
clause
Creates the NegatableConstraint \/ literal
conjunction
Creates the NegatableConstraint /\ literal
cumulative
Creates the Cumulative Constraint.
cumulative_with_options
Creates the Cumulative constraint with the provided CumulativeOptions.
disjunctive_strict
Creates the Disjunctive Constraint (also called the NoOverlap Constraint or the Unary Resource Constraint).
division
Creates the Constraint numerator / denominator = rhs.
element
Creates the element Constraint which states that array[index] = rhs.
equals
Creates the NegatableConstraint \sum terms_i = rhs.
greater_than
Create the NegatableConstraint \sum terms_i > rhs.
greater_than_or_equals
Create the NegatableConstraint \sum terms_i >= rhs.
less_than
Create the NegatableConstraint \sum terms_i < rhs.
less_than_or_equals
Create the NegatableConstraint \sum terms_i <= rhs.
maximum
Creates the Constraint max(array) = m.
minimum
Creates the Constraint min(array) = m.
negative_table
Create a negative table constraint over the variables xs.
not_equals
Create the NegatableConstraint \sum terms_i != rhs.
plus
Creates the Constraint a + b = c.
table
Create a table constraint over the variables xs.
times
Creates the Constraint a * b = c.