public class Solver
extends java.lang.Object
Modifier and Type  Class and Description 

class 
Solver.OptimizationOptions
Class used to store and modify info about which optimizations are enabled.

Constructor and Description 

Solver()
Constructs a new solver.

Modifier and Type  Method and Description 

void 
add(Constraint constraint)
Adds a constraint conjunction at the end of the store.

void 
addChoicePoint(Constraint constraint)
Opens a choice point for the first atomic constraint in the constraint conjunction
constraint . 
boolean 
check()
Solves the conjunction of constraints in the current constraint store.

boolean 
check(Constraint constraint)
Solves the passed constraint
constraint in the context of the current
constraint store and returns a boolean result. 
void 
clearStore()
Removes all constraints from the Constraint Store

void 
failure()
Method used to signal that the constraint resolution mechanism has failed and no solutions could be found.

int 
forEachSolution(java.util.function.Consumer<java.lang.Integer> consumer)
Runs the given runnable for each solution, counts the number of solutions and returns it.

Constraint 
getConstraint()
Returns a constraint conjunction consisting of all the not solved atomic constraints currently in the store.

Solver.OptimizationOptions 
getOptimizationOptions()
Returns the instance of
OptimizationOptions used by the solver. 
java.lang.Integer 
maximize(IntLVar intLVar)
Maximises the given integer logical variable and returns its maximum
(in the context of the current constraint store).

java.lang.Integer 
minimize(IntLVar intLVar)
Minimizes the given integer logical variable and returns its minimum
(in the context of the current constraint store).

boolean 
nextSolution()
This method tries to find a
new solution (if any) each time it is called.

LSet 
setof(LObject x)
Finds all possible values (by calling
x.getValue) for a logical object that satisfy the constraint
in current constraint store of this solver. 
LSet 
setof(LObject x,
Constraint constraint)
Computes and returns the (logical) set of all values (obtained calling
x.getValue() of x that satisfy constraint
and the constraints in the constraint store. 
void 
showStore()
This method prints each constraint that is not solved yet to standard output.

void 
showStoreAll()
This method prints each constraint still in the constraint store (solved or not) to standard output.

void 
showStoreInternals()
Like
showStoreAll() but prints the internal view of the constraint store to standard output. 
int 
size()
This method returns the number of atomic constraints in the store that are not yet solved.

void 
solve()
Solves (using backtracking) the constraints that are not in solved form.

void 
solve(Constraint constraint)
Adds the given constraint to the constraint store and solves it using solve()

boolean 
test()
Tests whether the constraint in the store is satisfiable but leaves each variable
that occur in the store unchanged.

public void add(@NotNull Constraint constraint)
constraint
 The constraint conjunction to be added to the store.public void addChoicePoint(@NotNull Constraint constraint)
constraint
.constraint
 the constraint that is opening the choice point. It must be an atomic constraint (not a conjunction).public void clearStore()
@NotNull public Constraint getConstraint()
public void showStore()
toString
on the returned constraint of the method getConstraint()
.public void showStoreAll()
public void showStoreInternals()
showStoreAll()
but prints the internal view of the constraint store to standard output.
Used for debugging purposes.public int size()
public boolean check()
true
if the conjunction is satisfiable, false
otherwise.public boolean check(@NotNull Constraint constraint)
constraint
in the context of the current
constraint store and returns a boolean result. If constraint
is unsatisfiable,
constraint
is removed from the constraint store.constraint
 the constraint conjunction to solve.true
constraint
is satisfiable in the context of the current store, false
otherwise.public void failure() throws Failure
Failure
 always.public int forEachSolution(@NotNull java.util.function.Consumer<java.lang.Integer> consumer)
consumer
 a consumer that gets the index of the solution and performs an action.public void solve() throws Failure
Fail
exception can be raised if constraints are inconsistent,
this exception is caught inside the method and starts the backtracking
procedure.Failure
 If the constraint in the store is unsatisfiable.public void solve(@NotNull Constraint constraint) throws Failure
constraint
 constraint conjunction to add to the constraint store.Failure
 if the constraint store and constraint
together are unsatisfiable.public boolean test()
true
if the constraint is satisfiable, otherwise it returns false
.@NotNull public java.lang.Integer minimize(@NotNull IntLVar intLVar)
intLVar
 variable to minimize.intLVar
.@NotNull public java.lang.Integer maximize(@NotNull IntLVar intLVar)
intLVar
 variable to minimize.intLVar
.public boolean nextSolution()
check
or solve
.true
if a next solution exists, false
otherwise.solve()
@NotNull public LSet setof(@NotNull LObject x)
x.getValue)
for a logical object that satisfy the constraint
in current constraint store of this solver.x
 The logical object of which we search the values.x.getValue()
.solve()
public LSet setof(@NotNull LObject x, @NotNull Constraint constraint)
x.getValue()
of x
that satisfy constraint
and the constraints in the constraint store.x
 logical variable the values of which are collected.constraint
 constraint that must be satisfied by the values of x
.x
.@NotNull public Solver.OptimizationOptions getOptimizationOptions()
OptimizationOptions
used by the solver.