Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
com.google.ortools.sat.CpModel Class Reference

Classes

class  CpModelException
 
class  MismatchedArrayLengths
 
class  WrongLength
 

Public Member Functions

 CpModel ()
 
CpModel getClone ()
 
IntVar newIntVar (long lb, long ub, String name)
 Integer variables.
 
IntVar newIntVarFromDomain (Domain domain, String name)
 
BoolVar newBoolVar (String name)
 
IntVar newConstant (long value)
 
Literal trueLiteral ()
 
Literal falseLiteral ()
 
BoolVar getBoolVarFromProtoIndex (int index)
 
IntVar getIntVarFromProtoIndex (int index)
 
Constraint addBoolOr (Literal[] literals)
 Boolean Constraints.
 
Constraint addBoolOr (Iterable< Literal > literals)
 
Constraint addAtLeastOne (Literal[] literals)
 
Constraint addAtLeastOne (Iterable< Literal > literals)
 
Constraint addAtMostOne (Literal[] literals)
 
Constraint addAtMostOne (Iterable< Literal > literals)
 
Constraint addExactlyOne (Literal[] literals)
 
Constraint addExactlyOne (Iterable< Literal > literals)
 
Constraint addBoolAnd (Literal[] literals)
 
Constraint addBoolAnd (Iterable< Literal > literals)
 
Constraint addBoolXor (Literal[] literals)
 
Constraint addBoolXor (Iterable< Literal > literals)
 
Constraint addImplication (Literal a, Literal b)
 
Constraint addLinearExpressionInDomain (LinearArgument expr, Domain domain)
 Linear constraints.
 
Constraint addLinearConstraint (LinearArgument expr, long lb, long ub)
 
Constraint addEquality (LinearArgument expr, long value)
 
Constraint addEquality (LinearArgument left, LinearArgument right)
 
Constraint addLessOrEqual (LinearArgument expr, long value)
 
Constraint addLessOrEqual (LinearArgument left, LinearArgument right)
 
Constraint addLessThan (LinearArgument expr, long value)
 
Constraint addLessThan (LinearArgument left, LinearArgument right)
 
Constraint addGreaterOrEqual (LinearArgument expr, long value)
 
Constraint addGreaterOrEqual (LinearArgument left, LinearArgument right)
 
Constraint addGreaterThan (LinearArgument expr, long value)
 
Constraint addGreaterThan (LinearArgument left, LinearArgument right)
 
Constraint addDifferent (LinearArgument expr, long value)
 
Constraint addDifferent (LinearArgument left, LinearArgument right)
 
Constraint addAllDifferent (LinearArgument[] expressions)
 Integer constraints.
 
Constraint addAllDifferent (Iterable<? extends LinearArgument > expressions)
 
Constraint addElement (IntVar index, IntVar[] variables, IntVar target)
 
Constraint addElement (IntVar index, long[] values, IntVar target)
 
Constraint addElement (IntVar index, int[] values, IntVar target)
 
CircuitConstraint addCircuit ()
 
MultipleCircuitConstraint addMultipleCircuit ()
 
TableConstraint addAllowedAssignments (IntVar[] variables)
 
TableConstraint addAllowedAssignments (Iterable< IntVar > variables)
 
TableConstraint addForbiddenAssignments (IntVar[] variables)
 
TableConstraint addForbiddenAssignments (Iterable< IntVar > variables)
 
AutomatonConstraint addAutomaton (IntVar[] transitionVariables, long startingState, long[] finalStates)
 
Constraint addInverse (IntVar[] variables, IntVar[] inverseVariables)
 
ReservoirConstraint addReservoirConstraint (long minLevel, long maxLevel)
 
void addMapDomain (IntVar var, Literal[] booleans, long offset)
 
Constraint addMinEquality (LinearArgument target, LinearArgument[] exprs)
 
Constraint addMinEquality (LinearArgument target, Iterable<? extends LinearArgument > exprs)
 
Constraint addMaxEquality (LinearArgument target, LinearArgument[] exprs)
 
Constraint addMaxEquality (LinearArgument target, Iterable<? extends LinearArgument > exprs)
 
Constraint addDivisionEquality (LinearArgument target, LinearArgument num, LinearArgument denom)
 
Constraint addAbsEquality (LinearArgument target, LinearArgument expr)
 
Constraint addModuloEquality (LinearArgument target, LinearArgument var, LinearArgument mod)
 
Constraint addModuloEquality (LinearArgument target, LinearArgument var, long mod)
 
Constraint addMultiplicationEquality (LinearArgument target, LinearArgument[] exprs)
 
Constraint addMultiplicationEquality (LinearArgument target, LinearArgument left, LinearArgument right)
 
IntervalVar newIntervalVar (LinearArgument start, LinearArgument size, LinearArgument end, String name)
 Scheduling support.
 
IntervalVar newFixedSizeIntervalVar (LinearArgument start, long size, String name)
 
IntervalVar newFixedInterval (long start, long size, String name)
 
IntervalVar newOptionalIntervalVar (LinearArgument start, LinearArgument size, LinearArgument end, Literal isPresent, String name)
 
IntervalVar newOptionalFixedSizeIntervalVar (LinearArgument start, long size, Literal isPresent, String name)
 
IntervalVar newOptionalFixedInterval (long start, long size, Literal isPresent, String name)
 
Constraint addNoOverlap (IntervalVar[] intervalVars)
 
Constraint addNoOverlap (Iterable< IntervalVar > intervalVars)
 
NoOverlap2dConstraint addNoOverlap2D ()
 
CumulativeConstraint addCumulative (LinearArgument capacity)
 
CumulativeConstraint addCumulative (long capacity)
 
void addHint (IntVar var, long value)
 
void clearHints ()
 
void addAssumption (Literal lit)
 
void addAssumptions (Literal[] literals)
 
void clearAssumptions ()
 
void minimize (LinearArgument expr)
 Objective.
 
void minimize (DoubleLinearExpr expr)
 
void maximize (LinearArgument expr)
 
void maximize (DoubleLinearExpr expr)
 
void clearObjective ()
 
boolean hasObjective ()
 
void addDecisionStrategy (LinearArgument[] expressions, DecisionStrategyProto.VariableSelectionStrategy varStr, DecisionStrategyProto.DomainReductionStrategy domStr)
 DecisionStrategy.
 
void addDecisionStrategy (Iterable<? extends LinearArgument > expressions, DecisionStrategyProto.VariableSelectionStrategy varStr, DecisionStrategyProto.DomainReductionStrategy domStr)
 
String modelStats ()
 
String validate ()
 
Boolean exportToFile (String file)
 
CpModelProto model ()
 Getters.
 
int negated (int index)
 
CpModelProto.Builder getBuilder ()
 
 CpModel ()
 
CpModel getClone ()
 
IntVar newIntVar (long lb, long ub, String name)
 Integer variables.
 
IntVar newIntVarFromDomain (Domain domain, String name)
 
BoolVar newBoolVar (String name)
 
IntVar newConstant (long value)
 
Literal trueLiteral ()
 
Literal falseLiteral ()
 
BoolVar getBoolVarFromProtoIndex (int index)
 
IntVar getIntVarFromProtoIndex (int index)
 
Constraint addBoolOr (Literal[] literals)
 Boolean Constraints.
 
Constraint addBoolOr (Iterable< Literal > literals)
 
Constraint addAtLeastOne (Literal[] literals)
 
Constraint addAtLeastOne (Iterable< Literal > literals)
 
Constraint addAtMostOne (Literal[] literals)
 
Constraint addAtMostOne (Iterable< Literal > literals)
 
Constraint addExactlyOne (Literal[] literals)
 
Constraint addExactlyOne (Iterable< Literal > literals)
 
Constraint addBoolAnd (Literal[] literals)
 
Constraint addBoolAnd (Iterable< Literal > literals)
 
Constraint addBoolXor (Literal[] literals)
 
Constraint addBoolXor (Iterable< Literal > literals)
 
Constraint addImplication (Literal a, Literal b)
 
Constraint addLinearExpressionInDomain (LinearArgument expr, Domain domain)
 Linear constraints.
 
Constraint addLinearConstraint (LinearArgument expr, long lb, long ub)
 
Constraint addEquality (LinearArgument expr, long value)
 
Constraint addEquality (LinearArgument left, LinearArgument right)
 
Constraint addLessOrEqual (LinearArgument expr, long value)
 
Constraint addLessOrEqual (LinearArgument left, LinearArgument right)
 
Constraint addLessThan (LinearArgument expr, long value)
 
Constraint addLessThan (LinearArgument left, LinearArgument right)
 
Constraint addGreaterOrEqual (LinearArgument expr, long value)
 
Constraint addGreaterOrEqual (LinearArgument left, LinearArgument right)
 
Constraint addGreaterThan (LinearArgument expr, long value)
 
Constraint addGreaterThan (LinearArgument left, LinearArgument right)
 
Constraint addDifferent (LinearArgument expr, long value)
 
Constraint addDifferent (LinearArgument left, LinearArgument right)
 
Constraint addAllDifferent (LinearArgument[] expressions)
 Integer constraints.
 
Constraint addAllDifferent (Iterable<? extends LinearArgument > expressions)
 
Constraint addElement (IntVar index, IntVar[] variables, IntVar target)
 
Constraint addElement (IntVar index, long[] values, IntVar target)
 
Constraint addElement (IntVar index, int[] values, IntVar target)
 
CircuitConstraint addCircuit ()
 
MultipleCircuitConstraint addMultipleCircuit ()
 
TableConstraint addAllowedAssignments (IntVar[] variables)
 
TableConstraint addAllowedAssignments (Iterable< IntVar > variables)
 
TableConstraint addForbiddenAssignments (IntVar[] variables)
 
TableConstraint addForbiddenAssignments (Iterable< IntVar > variables)
 
AutomatonConstraint addAutomaton (IntVar[] transitionVariables, long startingState, long[] finalStates)
 
Constraint addInverse (IntVar[] variables, IntVar[] inverseVariables)
 
ReservoirConstraint addReservoirConstraint (long minLevel, long maxLevel)
 
void addMapDomain (IntVar var, Literal[] booleans, long offset)
 
Constraint addMinEquality (LinearArgument target, LinearArgument[] exprs)
 
Constraint addMinEquality (LinearArgument target, Iterable<? extends LinearArgument > exprs)
 
Constraint addMaxEquality (LinearArgument target, LinearArgument[] exprs)
 
Constraint addMaxEquality (LinearArgument target, Iterable<? extends LinearArgument > exprs)
 
Constraint addDivisionEquality (LinearArgument target, LinearArgument num, LinearArgument denom)
 
Constraint addAbsEquality (LinearArgument target, LinearArgument expr)
 
Constraint addModuloEquality (LinearArgument target, LinearArgument var, LinearArgument mod)
 
Constraint addModuloEquality (LinearArgument target, LinearArgument var, long mod)
 
Constraint addMultiplicationEquality (LinearArgument target, LinearArgument[] exprs)
 
Constraint addMultiplicationEquality (LinearArgument target, LinearArgument left, LinearArgument right)
 
IntervalVar newIntervalVar (LinearArgument start, LinearArgument size, LinearArgument end, String name)
 Scheduling support.
 
IntervalVar newFixedSizeIntervalVar (LinearArgument start, long size, String name)
 
IntervalVar newFixedInterval (long start, long size, String name)
 
IntervalVar newOptionalIntervalVar (LinearArgument start, LinearArgument size, LinearArgument end, Literal isPresent, String name)
 
IntervalVar newOptionalFixedSizeIntervalVar (LinearArgument start, long size, Literal isPresent, String name)
 
IntervalVar newOptionalFixedInterval (long start, long size, Literal isPresent, String name)
 
Constraint addNoOverlap (IntervalVar[] intervalVars)
 
Constraint addNoOverlap (Iterable< IntervalVar > intervalVars)
 
NoOverlap2dConstraint addNoOverlap2D ()
 
CumulativeConstraint addCumulative (LinearArgument capacity)
 
CumulativeConstraint addCumulative (long capacity)
 
void addHint (IntVar var, long value)
 
void clearHints ()
 
void addAssumption (Literal lit)
 
void addAssumptions (Literal[] literals)
 
void clearAssumptions ()
 
void minimize (LinearArgument expr)
 Objective.
 
void minimize (DoubleLinearExpr expr)
 
void maximize (LinearArgument expr)
 
void maximize (DoubleLinearExpr expr)
 
void clearObjective ()
 
boolean hasObjective ()
 
void addDecisionStrategy (LinearArgument[] expressions, DecisionStrategyProto.VariableSelectionStrategy varStr, DecisionStrategyProto.DomainReductionStrategy domStr)
 DecisionStrategy.
 
void addDecisionStrategy (Iterable<? extends LinearArgument > expressions, DecisionStrategyProto.VariableSelectionStrategy varStr, DecisionStrategyProto.DomainReductionStrategy domStr)
 
String modelStats ()
 
String validate ()
 
Boolean exportToFile (String file)
 
CpModelProto model ()
 Getters.
 
int negated (int index)
 
CpModelProto.Builder getBuilder ()
 

Detailed Description

Main modeling class.

Proposes a factory to create all modeling objects understood by the SAT solver.

Definition at line 42 of file CpModel.java.

Constructor & Destructor Documentation

◆ CpModel() [1/2]

com.google.ortools.sat.CpModel.CpModel ( )

Definition at line 64 of file CpModel.java.

◆ CpModel() [2/2]

com.google.ortools.sat.CpModel.CpModel ( )

Definition at line 64 of file CpModel.java.

Member Function Documentation

◆ addAbsEquality() [1/2]

Constraint com.google.ortools.sat.CpModel.addAbsEquality ( LinearArgument target,
LinearArgument expr )

Adds target == Abs(expr).

Definition at line 661 of file CpModel.java.

◆ addAbsEquality() [2/2]

Constraint com.google.ortools.sat.CpModel.addAbsEquality ( LinearArgument target,
LinearArgument expr )

Adds target == Abs(expr).

Definition at line 661 of file CpModel.java.

◆ addAllDifferent() [1/4]

Constraint com.google.ortools.sat.CpModel.addAllDifferent ( Iterable<? extends LinearArgument > expressions)

Adds AllDifferent(expressions).

See also
addAllDifferent(LinearArgument[]).

Definition at line 358 of file CpModel.java.

◆ addAllDifferent() [2/4]

Constraint com.google.ortools.sat.CpModel.addAllDifferent ( Iterable<? extends LinearArgument > expressions)

Adds AllDifferent(expressions).

See also
addAllDifferent(LinearArgument[]).

Definition at line 358 of file CpModel.java.

◆ addAllDifferent() [3/4]

Constraint com.google.ortools.sat.CpModel.addAllDifferent ( LinearArgument[] expressions)

Integer constraints.

Adds AllDifferent(expressions).

This constraint forces all affine expressions to have different values.

Parameters
expressionsa list of affine integer expressions
Returns
an instance of the Constraint class

Definition at line 349 of file CpModel.java.

◆ addAllDifferent() [4/4]

Constraint com.google.ortools.sat.CpModel.addAllDifferent ( LinearArgument[] expressions)

Integer constraints.

Adds AllDifferent(expressions).

This constraint forces all affine expressions to have different values.

Parameters
expressionsa list of affine integer expressions
Returns
an instance of the Constraint class

Definition at line 349 of file CpModel.java.

◆ addAllowedAssignments() [1/4]

TableConstraint com.google.ortools.sat.CpModel.addAllowedAssignments ( IntVar[] variables)

Adds AllowedAssignments(variables).

An AllowedAssignments constraint is a constraint on an array of variables that forces, when all variables are fixed to a single value, that the corresponding list of values is equal to one of the tuples of the tupleList.

Parameters
variablesa list of variables
Returns
an instance of the TableConstraint class without any tuples. Tuples can be added directly to the table constraint.

Definition at line 441 of file CpModel.java.

◆ addAllowedAssignments() [2/4]

TableConstraint com.google.ortools.sat.CpModel.addAllowedAssignments ( IntVar[] variables)

Adds AllowedAssignments(variables).

An AllowedAssignments constraint is a constraint on an array of variables that forces, when all variables are fixed to a single value, that the corresponding list of values is equal to one of the tuples of the tupleList.

Parameters
variablesa list of variables
Returns
an instance of the TableConstraint class without any tuples. Tuples can be added directly to the table constraint.

Definition at line 441 of file CpModel.java.

◆ addAllowedAssignments() [3/4]

TableConstraint com.google.ortools.sat.CpModel.addAllowedAssignments ( Iterable< IntVar > variables)

Adds AllowedAssignments(variables).

See also
addAllowedAssignments(IntVar[])

Definition at line 450 of file CpModel.java.

◆ addAllowedAssignments() [4/4]

TableConstraint com.google.ortools.sat.CpModel.addAllowedAssignments ( Iterable< IntVar > variables)

Adds AllowedAssignments(variables).

See also
addAllowedAssignments(IntVar[])

Definition at line 450 of file CpModel.java.

◆ addAssumption() [1/2]

void com.google.ortools.sat.CpModel.addAssumption ( Literal lit)

Adds a literal to the model as assumption

Definition at line 910 of file CpModel.java.

◆ addAssumption() [2/2]

void com.google.ortools.sat.CpModel.addAssumption ( Literal lit)

Adds a literal to the model as assumption

Definition at line 910 of file CpModel.java.

◆ addAssumptions() [1/2]

void com.google.ortools.sat.CpModel.addAssumptions ( Literal[] literals)

Adds multiple literals to the model as assumptions

Definition at line 915 of file CpModel.java.

◆ addAssumptions() [2/2]

void com.google.ortools.sat.CpModel.addAssumptions ( Literal[] literals)

Adds multiple literals to the model as assumptions

Definition at line 915 of file CpModel.java.

◆ addAtLeastOne() [1/4]

Constraint com.google.ortools.sat.CpModel.addAtLeastOne ( Iterable< Literal > literals)

Same as addBoolOr. Sum(literals) >= 1.

Definition at line 163 of file CpModel.java.

◆ addAtLeastOne() [2/4]

Constraint com.google.ortools.sat.CpModel.addAtLeastOne ( Iterable< Literal > literals)

Same as addBoolOr. Sum(literals) >= 1.

Definition at line 163 of file CpModel.java.

◆ addAtLeastOne() [3/4]

Constraint com.google.ortools.sat.CpModel.addAtLeastOne ( Literal[] literals)

Same as addBoolOr. Sum(literals) >= 1.

Definition at line 158 of file CpModel.java.

◆ addAtLeastOne() [4/4]

Constraint com.google.ortools.sat.CpModel.addAtLeastOne ( Literal[] literals)

Same as addBoolOr. Sum(literals) >= 1.

Definition at line 158 of file CpModel.java.

◆ addAtMostOne() [1/4]

Constraint com.google.ortools.sat.CpModel.addAtMostOne ( Iterable< Literal > literals)

Adds AtMostOne(literals): Sum(literals) <= 1.

Definition at line 173 of file CpModel.java.

◆ addAtMostOne() [2/4]

Constraint com.google.ortools.sat.CpModel.addAtMostOne ( Iterable< Literal > literals)

Adds AtMostOne(literals): Sum(literals) <= 1.

Definition at line 173 of file CpModel.java.

◆ addAtMostOne() [3/4]

Constraint com.google.ortools.sat.CpModel.addAtMostOne ( Literal[] literals)

Adds AtMostOne(literals): Sum(literals) <= 1.

Definition at line 168 of file CpModel.java.

◆ addAtMostOne() [4/4]

Constraint com.google.ortools.sat.CpModel.addAtMostOne ( Literal[] literals)

Adds AtMostOne(literals): Sum(literals) <= 1.

Definition at line 168 of file CpModel.java.

◆ addAutomaton() [1/2]

AutomatonConstraint com.google.ortools.sat.CpModel.addAutomaton ( IntVar[] transitionVariables,
long startingState,
long[] finalStates )

Adds an automaton constraint.

An automaton constraint takes a list of variables (of size n), an initial state, a set of final states, and a set of transitions that will be added incrementally directly on the returned AutomatonConstraint instance. A transition is a triplet ('tail', 'transition', 'head'), where 'tail' and 'head' are states, and 'transition' is the label of an arc from 'head' to 'tail', corresponding to the value of one variable in the list of variables.

This automaton will be unrolled into a flow with n + 1 phases. Each phase contains the possible states of the automaton. The first state contains the initial state. The last phase contains the final states.

Between two consecutive phases i and i + 1, the automaton creates a set of arcs. For each transition (tail, label, head), it will add an arc from the state 'tail' of phase i and the state 'head' of phase i + 1. This arc labeled by the value 'label' of the variables 'variables[i]'. That is, this arc can only be selected if 'variables[i]' is assigned the value 'label'.

A feasible solution of this constraint is an assignment of variables such that, starting from the initial state in phase 0, there is a path labeled by the values of the variables that ends in one of the final states in the final phase.

Parameters
transitionVariablesa non empty list of variables whose values correspond to the labels of the arcs traversed by the automaton
startingStatethe initial state of the automaton
finalStatesa non empty list of admissible final states
Returns
an instance of the Constraint class

Definition at line 518 of file CpModel.java.

◆ addAutomaton() [2/2]

AutomatonConstraint com.google.ortools.sat.CpModel.addAutomaton ( IntVar[] transitionVariables,
long startingState,
long[] finalStates )

Adds an automaton constraint.

An automaton constraint takes a list of variables (of size n), an initial state, a set of final states, and a set of transitions that will be added incrementally directly on the returned AutomatonConstraint instance. A transition is a triplet ('tail', 'transition', 'head'), where 'tail' and 'head' are states, and 'transition' is the label of an arc from 'head' to 'tail', corresponding to the value of one variable in the list of variables.

This automaton will be unrolled into a flow with n + 1 phases. Each phase contains the possible states of the automaton. The first state contains the initial state. The last phase contains the final states.

Between two consecutive phases i and i + 1, the automaton creates a set of arcs. For each transition (tail, label, head), it will add an arc from the state 'tail' of phase i and the state 'head' of phase i + 1. This arc labeled by the value 'label' of the variables 'variables[i]'. That is, this arc can only be selected if 'variables[i]' is assigned the value 'label'.

A feasible solution of this constraint is an assignment of variables such that, starting from the initial state in phase 0, there is a path labeled by the values of the variables that ends in one of the final states in the final phase.

Parameters
transitionVariablesa non empty list of variables whose values correspond to the labels of the arcs traversed by the automaton
startingStatethe initial state of the automaton
finalStatesa non empty list of admissible final states
Returns
an instance of the Constraint class

Definition at line 518 of file CpModel.java.

◆ addBoolAnd() [1/4]

Constraint com.google.ortools.sat.CpModel.addBoolAnd ( Iterable< Literal > literals)

Adds And(literals) == true.

Definition at line 203 of file CpModel.java.

◆ addBoolAnd() [2/4]

Constraint com.google.ortools.sat.CpModel.addBoolAnd ( Iterable< Literal > literals)

Adds And(literals) == true.

Definition at line 203 of file CpModel.java.

◆ addBoolAnd() [3/4]

Constraint com.google.ortools.sat.CpModel.addBoolAnd ( Literal[] literals)

Adds And(literals) == true.

Definition at line 198 of file CpModel.java.

◆ addBoolAnd() [4/4]

Constraint com.google.ortools.sat.CpModel.addBoolAnd ( Literal[] literals)

Adds And(literals) == true.

Definition at line 198 of file CpModel.java.

◆ addBoolOr() [1/4]

Constraint com.google.ortools.sat.CpModel.addBoolOr ( Iterable< Literal > literals)

Adds Or(literals) == true.

Definition at line 148 of file CpModel.java.

◆ addBoolOr() [2/4]

Constraint com.google.ortools.sat.CpModel.addBoolOr ( Iterable< Literal > literals)

Adds Or(literals) == true.

Definition at line 148 of file CpModel.java.

◆ addBoolOr() [3/4]

Constraint com.google.ortools.sat.CpModel.addBoolOr ( Literal[] literals)

Boolean Constraints.

Adds Or(literals) == true.

Definition at line 143 of file CpModel.java.

◆ addBoolOr() [4/4]

Constraint com.google.ortools.sat.CpModel.addBoolOr ( Literal[] literals)

Boolean Constraints.

Adds Or(literals) == true.

Definition at line 143 of file CpModel.java.

◆ addBoolXor() [1/4]

Constraint com.google.ortools.sat.CpModel.addBoolXor ( Iterable< Literal > literals)

Adds XOr(literals) == true.

Definition at line 218 of file CpModel.java.

◆ addBoolXor() [2/4]

Constraint com.google.ortools.sat.CpModel.addBoolXor ( Iterable< Literal > literals)

Adds XOr(literals) == true.

Definition at line 218 of file CpModel.java.

◆ addBoolXor() [3/4]

Constraint com.google.ortools.sat.CpModel.addBoolXor ( Literal[] literals)

Adds XOr(literals) == true.

Definition at line 213 of file CpModel.java.

◆ addBoolXor() [4/4]

Constraint com.google.ortools.sat.CpModel.addBoolXor ( Literal[] literals)

Adds XOr(literals) == true.

Definition at line 213 of file CpModel.java.

◆ addCircuit() [1/2]

CircuitConstraint com.google.ortools.sat.CpModel.addCircuit ( )

Adds Circuit().

Adds an empty circuit constraint.

A circuit is a unique Hamiltonian path in a subgraph of the total graph. In case a node 'i' is not in the path, then there must be a loop arc 'i -> i' associated with a true literal. Otherwise this constraint will fail.

Definition at line 412 of file CpModel.java.

◆ addCircuit() [2/2]

CircuitConstraint com.google.ortools.sat.CpModel.addCircuit ( )

Adds Circuit().

Adds an empty circuit constraint.

A circuit is a unique Hamiltonian path in a subgraph of the total graph. In case a node 'i' is not in the path, then there must be a loop arc 'i -> i' associated with a true literal. Otherwise this constraint will fail.

Definition at line 412 of file CpModel.java.

◆ addCumulative() [1/4]

CumulativeConstraint com.google.ortools.sat.CpModel.addCumulative ( LinearArgument capacity)

Adds Cumulative(capacity).

This constraint enforces that:

forall t: sum(demands[i] if (start(intervals[t]) <= t < end(intervals[t])) and (t is
present)) <= capacity
.

Parameters
capacitythe maximum capacity of the cumulative constraint. It must be a positive affine expression.
Returns
an instance of the CumulativeConstraint class. this class allows adding (interval, demand) pairs incrementally.

Definition at line 879 of file CpModel.java.

◆ addCumulative() [2/4]

CumulativeConstraint com.google.ortools.sat.CpModel.addCumulative ( LinearArgument capacity)

Adds Cumulative(capacity).

This constraint enforces that:

forall t: sum(demands[i] if (start(intervals[t]) <= t < end(intervals[t])) and (t is
present)) <= capacity
.

Parameters
capacitythe maximum capacity of the cumulative constraint. It must be a positive affine expression.
Returns
an instance of the CumulativeConstraint class. this class allows adding (interval, demand) pairs incrementally.

Definition at line 879 of file CpModel.java.

◆ addCumulative() [3/4]

CumulativeConstraint com.google.ortools.sat.CpModel.addCumulative ( long capacity)

Adds Cumulative(capacity).

See also
addCumulative(LinearArgument capacity)

Definition at line 891 of file CpModel.java.

◆ addCumulative() [4/4]

CumulativeConstraint com.google.ortools.sat.CpModel.addCumulative ( long capacity)

Adds Cumulative(capacity).

See also
addCumulative(LinearArgument capacity)

Definition at line 891 of file CpModel.java.

◆ addDecisionStrategy() [1/4]

void com.google.ortools.sat.CpModel.addDecisionStrategy ( Iterable<? extends LinearArgument > expressions,
DecisionStrategyProto.VariableSelectionStrategy varStr,
DecisionStrategyProto.DomainReductionStrategy domStr )

Adds DecisionStrategy(expressions, varStr, domStr).

Definition at line 996 of file CpModel.java.

◆ addDecisionStrategy() [2/4]

void com.google.ortools.sat.CpModel.addDecisionStrategy ( Iterable<? extends LinearArgument > expressions,
DecisionStrategyProto.VariableSelectionStrategy varStr,
DecisionStrategyProto.DomainReductionStrategy domStr )

Adds DecisionStrategy(expressions, varStr, domStr).

Definition at line 996 of file CpModel.java.

◆ addDecisionStrategy() [3/4]

void com.google.ortools.sat.CpModel.addDecisionStrategy ( LinearArgument[] expressions,
DecisionStrategyProto.VariableSelectionStrategy varStr,
DecisionStrategyProto.DomainReductionStrategy domStr )

DecisionStrategy.

Adds DecisionStrategy(expressions, varStr, domStr).

Definition at line 985 of file CpModel.java.

◆ addDecisionStrategy() [4/4]

void com.google.ortools.sat.CpModel.addDecisionStrategy ( LinearArgument[] expressions,
DecisionStrategyProto.VariableSelectionStrategy varStr,
DecisionStrategyProto.DomainReductionStrategy domStr )

DecisionStrategy.

Adds DecisionStrategy(expressions, varStr, domStr).

Definition at line 985 of file CpModel.java.

◆ addDifferent() [1/4]

Constraint com.google.ortools.sat.CpModel.addDifferent ( LinearArgument expr,
long value )

Adds expr != value.

Definition at line 324 of file CpModel.java.

◆ addDifferent() [2/4]

Constraint com.google.ortools.sat.CpModel.addDifferent ( LinearArgument expr,
long value )

Adds expr != value.

Definition at line 324 of file CpModel.java.

◆ addDifferent() [3/4]

Constraint com.google.ortools.sat.CpModel.addDifferent ( LinearArgument left,
LinearArgument right )

Adds left != right.

Definition at line 331 of file CpModel.java.

◆ addDifferent() [4/4]

Constraint com.google.ortools.sat.CpModel.addDifferent ( LinearArgument left,
LinearArgument right )

Adds left != right.

Definition at line 331 of file CpModel.java.

◆ addDivisionEquality() [1/2]

Constraint com.google.ortools.sat.CpModel.addDivisionEquality ( LinearArgument target,
LinearArgument num,
LinearArgument denom )

Adds target == num / denom, rounded towards 0.

Definition at line 649 of file CpModel.java.

◆ addDivisionEquality() [2/2]

Constraint com.google.ortools.sat.CpModel.addDivisionEquality ( LinearArgument target,
LinearArgument num,
LinearArgument denom )

Adds target == num / denom, rounded towards 0.

Definition at line 649 of file CpModel.java.

◆ addElement() [1/6]

Constraint com.google.ortools.sat.CpModel.addElement ( IntVar index,
int[] values,
IntVar target )

Adds the element constraint: values[index] == target.

Definition at line 392 of file CpModel.java.

◆ addElement() [2/6]

Constraint com.google.ortools.sat.CpModel.addElement ( IntVar index,
int[] values,
IntVar target )

Adds the element constraint: values[index] == target.

Definition at line 392 of file CpModel.java.

◆ addElement() [3/6]

Constraint com.google.ortools.sat.CpModel.addElement ( IntVar index,
IntVar[] variables,
IntVar target )

Adds the element constraint: variables[index] == target.

Definition at line 368 of file CpModel.java.

◆ addElement() [4/6]

Constraint com.google.ortools.sat.CpModel.addElement ( IntVar index,
IntVar[] variables,
IntVar target )

Adds the element constraint: variables[index] == target.

Definition at line 368 of file CpModel.java.

◆ addElement() [5/6]

Constraint com.google.ortools.sat.CpModel.addElement ( IntVar index,
long[] values,
IntVar target )

Adds the element constraint: values[index] == target.

Definition at line 380 of file CpModel.java.

◆ addElement() [6/6]

Constraint com.google.ortools.sat.CpModel.addElement ( IntVar index,
long[] values,
IntVar target )

Adds the element constraint: values[index] == target.

Definition at line 380 of file CpModel.java.

◆ addEquality() [1/4]

Constraint com.google.ortools.sat.CpModel.addEquality ( LinearArgument expr,
long value )

Adds expr == value.

Definition at line 259 of file CpModel.java.

◆ addEquality() [2/4]

Constraint com.google.ortools.sat.CpModel.addEquality ( LinearArgument expr,
long value )

Adds expr == value.

Definition at line 259 of file CpModel.java.

◆ addEquality() [3/4]

Constraint com.google.ortools.sat.CpModel.addEquality ( LinearArgument left,
LinearArgument right )

Adds left == right.

Definition at line 264 of file CpModel.java.

◆ addEquality() [4/4]

Constraint com.google.ortools.sat.CpModel.addEquality ( LinearArgument left,
LinearArgument right )

Adds left == right.

Definition at line 264 of file CpModel.java.

◆ addExactlyOne() [1/4]

Constraint com.google.ortools.sat.CpModel.addExactlyOne ( Iterable< Literal > literals)

Adds ExactlyOne(literals): Sum(literals) == 1.

Definition at line 188 of file CpModel.java.

◆ addExactlyOne() [2/4]

Constraint com.google.ortools.sat.CpModel.addExactlyOne ( Iterable< Literal > literals)

Adds ExactlyOne(literals): Sum(literals) == 1.

Definition at line 188 of file CpModel.java.

◆ addExactlyOne() [3/4]

Constraint com.google.ortools.sat.CpModel.addExactlyOne ( Literal[] literals)

Adds ExactlyOne(literals): Sum(literals) == 1.

Definition at line 183 of file CpModel.java.

◆ addExactlyOne() [4/4]

Constraint com.google.ortools.sat.CpModel.addExactlyOne ( Literal[] literals)

Adds ExactlyOne(literals): Sum(literals) == 1.

Definition at line 183 of file CpModel.java.

◆ addForbiddenAssignments() [1/4]

TableConstraint com.google.ortools.sat.CpModel.addForbiddenAssignments ( IntVar[] variables)

Adds ForbiddenAssignments(variables).

A ForbiddenAssignments constraint is a constraint on an array of variables where the list of impossible combinations is provided in the tuples list.

Parameters
variablesa list of variables
Returns
an instance of the TableConstraint class without any tuples. Tuples can be added directly to the table constraint.

Definition at line 470 of file CpModel.java.

◆ addForbiddenAssignments() [2/4]

TableConstraint com.google.ortools.sat.CpModel.addForbiddenAssignments ( IntVar[] variables)

Adds ForbiddenAssignments(variables).

A ForbiddenAssignments constraint is a constraint on an array of variables where the list of impossible combinations is provided in the tuples list.

Parameters
variablesa list of variables
Returns
an instance of the TableConstraint class without any tuples. Tuples can be added directly to the table constraint.

Definition at line 470 of file CpModel.java.

◆ addForbiddenAssignments() [3/4]

TableConstraint com.google.ortools.sat.CpModel.addForbiddenAssignments ( Iterable< IntVar > variables)

Adds ForbiddenAssignments(variables).

See also
addForbiddenAssignments(IntVar[])

Definition at line 479 of file CpModel.java.

◆ addForbiddenAssignments() [4/4]

TableConstraint com.google.ortools.sat.CpModel.addForbiddenAssignments ( Iterable< IntVar > variables)

Adds ForbiddenAssignments(variables).

See also
addForbiddenAssignments(IntVar[])

Definition at line 479 of file CpModel.java.

◆ addGreaterOrEqual() [1/4]

Constraint com.google.ortools.sat.CpModel.addGreaterOrEqual ( LinearArgument expr,
long value )

Adds expr >= value.

Definition at line 298 of file CpModel.java.

◆ addGreaterOrEqual() [2/4]

Constraint com.google.ortools.sat.CpModel.addGreaterOrEqual ( LinearArgument expr,
long value )

Adds expr >= value.

Definition at line 298 of file CpModel.java.

◆ addGreaterOrEqual() [3/4]

Constraint com.google.ortools.sat.CpModel.addGreaterOrEqual ( LinearArgument left,
LinearArgument right )

Adds left >= right.

Definition at line 303 of file CpModel.java.

◆ addGreaterOrEqual() [4/4]

Constraint com.google.ortools.sat.CpModel.addGreaterOrEqual ( LinearArgument left,
LinearArgument right )

Adds left >= right.

Definition at line 303 of file CpModel.java.

◆ addGreaterThan() [1/4]

Constraint com.google.ortools.sat.CpModel.addGreaterThan ( LinearArgument expr,
long value )

Adds expr > value.

Definition at line 311 of file CpModel.java.

◆ addGreaterThan() [2/4]

Constraint com.google.ortools.sat.CpModel.addGreaterThan ( LinearArgument expr,
long value )

Adds expr > value.

Definition at line 311 of file CpModel.java.

◆ addGreaterThan() [3/4]

Constraint com.google.ortools.sat.CpModel.addGreaterThan ( LinearArgument left,
LinearArgument right )

Adds left > right.

Definition at line 316 of file CpModel.java.

◆ addGreaterThan() [4/4]

Constraint com.google.ortools.sat.CpModel.addGreaterThan ( LinearArgument left,
LinearArgument right )

Adds left > right.

Definition at line 316 of file CpModel.java.

◆ addHint() [1/2]

void com.google.ortools.sat.CpModel.addHint ( IntVar var,
long value )

Adds hinting to a variable

Definition at line 899 of file CpModel.java.

◆ addHint() [2/2]

void com.google.ortools.sat.CpModel.addHint ( IntVar var,
long value )

Adds hinting to a variable

Definition at line 899 of file CpModel.java.

◆ addImplication() [1/2]

Constraint com.google.ortools.sat.CpModel.addImplication ( Literal a,
Literal b )

Adds a => b.

Definition at line 228 of file CpModel.java.

◆ addImplication() [2/2]

Constraint com.google.ortools.sat.CpModel.addImplication ( Literal a,
Literal b )

Adds a => b.

Definition at line 228 of file CpModel.java.

◆ addInverse() [1/2]

Constraint com.google.ortools.sat.CpModel.addInverse ( IntVar[] variables,
IntVar[] inverseVariables )

Adds Inverse(variables, inverseVariables).

An inverse constraint enforces that if 'variables[i]' is assigned a value 'j', then inverseVariables[j] is assigned a value 'i'. And vice versa.

Parameters
variablesan array of integer variables
inverseVariablesan array of integer variables
Returns
an instance of the Constraint class
Exceptions
MismatchedArrayLengthsif variables and inverseVariables have different length

Definition at line 543 of file CpModel.java.

◆ addInverse() [2/2]

Constraint com.google.ortools.sat.CpModel.addInverse ( IntVar[] variables,
IntVar[] inverseVariables )

Adds Inverse(variables, inverseVariables).

An inverse constraint enforces that if 'variables[i]' is assigned a value 'j', then inverseVariables[j] is assigned a value 'i'. And vice versa.

Parameters
variablesan array of integer variables
inverseVariablesan array of integer variables
Returns
an instance of the Constraint class
Exceptions
MismatchedArrayLengthsif variables and inverseVariables have different length

Definition at line 543 of file CpModel.java.

◆ addLessOrEqual() [1/4]

Constraint com.google.ortools.sat.CpModel.addLessOrEqual ( LinearArgument expr,
long value )

Adds expr <= value.

Definition at line 272 of file CpModel.java.

◆ addLessOrEqual() [2/4]

Constraint com.google.ortools.sat.CpModel.addLessOrEqual ( LinearArgument expr,
long value )

Adds expr <= value.

Definition at line 272 of file CpModel.java.

◆ addLessOrEqual() [3/4]

Constraint com.google.ortools.sat.CpModel.addLessOrEqual ( LinearArgument left,
LinearArgument right )

Adds left <= right.

Definition at line 277 of file CpModel.java.

◆ addLessOrEqual() [4/4]

Constraint com.google.ortools.sat.CpModel.addLessOrEqual ( LinearArgument left,
LinearArgument right )

Adds left <= right.

Definition at line 277 of file CpModel.java.

◆ addLessThan() [1/4]

Constraint com.google.ortools.sat.CpModel.addLessThan ( LinearArgument expr,
long value )

Adds expr < value.

Definition at line 285 of file CpModel.java.

◆ addLessThan() [2/4]

Constraint com.google.ortools.sat.CpModel.addLessThan ( LinearArgument expr,
long value )

Adds expr < value.

Definition at line 285 of file CpModel.java.

◆ addLessThan() [3/4]

Constraint com.google.ortools.sat.CpModel.addLessThan ( LinearArgument left,
LinearArgument right )

Adds left < right.

Definition at line 290 of file CpModel.java.

◆ addLessThan() [4/4]

Constraint com.google.ortools.sat.CpModel.addLessThan ( LinearArgument left,
LinearArgument right )

Adds left < right.

Definition at line 290 of file CpModel.java.

◆ addLinearConstraint() [1/2]

Constraint com.google.ortools.sat.CpModel.addLinearConstraint ( LinearArgument expr,
long lb,
long ub )

Adds lb <= expr <= ub.

Definition at line 254 of file CpModel.java.

◆ addLinearConstraint() [2/2]

Constraint com.google.ortools.sat.CpModel.addLinearConstraint ( LinearArgument expr,
long lb,
long ub )

Adds lb <= expr <= ub.

Definition at line 254 of file CpModel.java.

◆ addLinearExpressionInDomain() [1/2]

Constraint com.google.ortools.sat.CpModel.addLinearExpressionInDomain ( LinearArgument expr,
Domain domain )

Linear constraints.

Adds expr in domain.

Definition at line 235 of file CpModel.java.

◆ addLinearExpressionInDomain() [2/2]

Constraint com.google.ortools.sat.CpModel.addLinearExpressionInDomain ( LinearArgument expr,
Domain domain )

Linear constraints.

Adds expr in domain.

Definition at line 235 of file CpModel.java.

◆ addMapDomain() [1/2]

void com.google.ortools.sat.CpModel.addMapDomain ( IntVar var,
Literal[] booleans,
long offset )

Adds var == i + offset <=> booleans[i] == true for all i in [0, booleans.length).

Definition at line 595 of file CpModel.java.

◆ addMapDomain() [2/2]

void com.google.ortools.sat.CpModel.addMapDomain ( IntVar var,
Literal[] booleans,
long offset )

Adds var == i + offset <=> booleans[i] == true for all i in [0, booleans.length).

Definition at line 595 of file CpModel.java.

◆ addMaxEquality() [1/4]

Constraint com.google.ortools.sat.CpModel.addMaxEquality ( LinearArgument target,
Iterable<? extends LinearArgument > exprs )

Adds target == Max(exprs).

Definition at line 637 of file CpModel.java.

◆ addMaxEquality() [2/4]

Constraint com.google.ortools.sat.CpModel.addMaxEquality ( LinearArgument target,
Iterable<? extends LinearArgument > exprs )

Adds target == Max(exprs).

Definition at line 637 of file CpModel.java.

◆ addMaxEquality() [3/4]

Constraint com.google.ortools.sat.CpModel.addMaxEquality ( LinearArgument target,
LinearArgument[] exprs )

Adds target == Max(vars).

Definition at line 626 of file CpModel.java.

◆ addMaxEquality() [4/4]

Constraint com.google.ortools.sat.CpModel.addMaxEquality ( LinearArgument target,
LinearArgument[] exprs )

Adds target == Max(vars).

Definition at line 626 of file CpModel.java.

◆ addMinEquality() [1/4]

Constraint com.google.ortools.sat.CpModel.addMinEquality ( LinearArgument target,
Iterable<? extends LinearArgument > exprs )

Adds target == Min(exprs).

Definition at line 614 of file CpModel.java.

◆ addMinEquality() [2/4]

Constraint com.google.ortools.sat.CpModel.addMinEquality ( LinearArgument target,
Iterable<? extends LinearArgument > exprs )

Adds target == Min(exprs).

Definition at line 614 of file CpModel.java.

◆ addMinEquality() [3/4]

Constraint com.google.ortools.sat.CpModel.addMinEquality ( LinearArgument target,
LinearArgument[] exprs )

Adds target == Min(vars).

Definition at line 603 of file CpModel.java.

◆ addMinEquality() [4/4]

Constraint com.google.ortools.sat.CpModel.addMinEquality ( LinearArgument target,
LinearArgument[] exprs )

Adds target == Min(vars).

Definition at line 603 of file CpModel.java.

◆ addModuloEquality() [1/4]

Constraint com.google.ortools.sat.CpModel.addModuloEquality ( LinearArgument target,
LinearArgument var,
LinearArgument mod )

Adds target == var % mod.

Definition at line 671 of file CpModel.java.

◆ addModuloEquality() [2/4]

Constraint com.google.ortools.sat.CpModel.addModuloEquality ( LinearArgument target,
LinearArgument var,
LinearArgument mod )

Adds target == var % mod.

Definition at line 671 of file CpModel.java.

◆ addModuloEquality() [3/4]

Constraint com.google.ortools.sat.CpModel.addModuloEquality ( LinearArgument target,
LinearArgument var,
long mod )

Adds target == var % mod.

Definition at line 683 of file CpModel.java.

◆ addModuloEquality() [4/4]

Constraint com.google.ortools.sat.CpModel.addModuloEquality ( LinearArgument target,
LinearArgument var,
long mod )

Adds target == var % mod.

Definition at line 683 of file CpModel.java.

◆ addMultipleCircuit() [1/2]

MultipleCircuitConstraint com.google.ortools.sat.CpModel.addMultipleCircuit ( )

Adds MultipleCircuit().

Adds an empty multiple circuit constraint.

A multiple circuit is set of cycles in a subgraph of the total graph. The node index by 0 must be part of all cycles of length > 1. Each node with index > 0 belongs to exactly one cycle. If such node does not belong in any cycle of length > 1, then there must be a looping arc on this node attached to a literal that will be true. Otherwise, the constraint will fail.

Definition at line 426 of file CpModel.java.

◆ addMultipleCircuit() [2/2]

MultipleCircuitConstraint com.google.ortools.sat.CpModel.addMultipleCircuit ( )

Adds MultipleCircuit().

Adds an empty multiple circuit constraint.

A multiple circuit is set of cycles in a subgraph of the total graph. The node index by 0 must be part of all cycles of length > 1. Each node with index > 0 belongs to exactly one cycle. If such node does not belong in any cycle of length > 1, then there must be a looping arc on this node attached to a literal that will be true. Otherwise, the constraint will fail.

Definition at line 426 of file CpModel.java.

◆ addMultiplicationEquality() [1/4]

Constraint com.google.ortools.sat.CpModel.addMultiplicationEquality ( LinearArgument target,
LinearArgument left,
LinearArgument right )

Adds target == left * right.

Definition at line 705 of file CpModel.java.

◆ addMultiplicationEquality() [2/4]

Constraint com.google.ortools.sat.CpModel.addMultiplicationEquality ( LinearArgument target,
LinearArgument left,
LinearArgument right )

Adds target == left * right.

Definition at line 705 of file CpModel.java.

◆ addMultiplicationEquality() [3/4]

Constraint com.google.ortools.sat.CpModel.addMultiplicationEquality ( LinearArgument target,
LinearArgument[] exprs )

Adds target == Product(exprs).

Definition at line 694 of file CpModel.java.

◆ addMultiplicationEquality() [4/4]

Constraint com.google.ortools.sat.CpModel.addMultiplicationEquality ( LinearArgument target,
LinearArgument[] exprs )

Adds target == Product(exprs).

Definition at line 694 of file CpModel.java.

◆ addNoOverlap() [1/4]

Constraint com.google.ortools.sat.CpModel.addNoOverlap ( IntervalVar[] intervalVars)

Adds NoOverlap(intervalVars).

A NoOverlap constraint ensures that all present intervals do not overlap in time.

Parameters
intervalVarsthe list of interval variables to constrain
Returns
an instance of the Constraint class

Definition at line 832 of file CpModel.java.

◆ addNoOverlap() [2/4]

Constraint com.google.ortools.sat.CpModel.addNoOverlap ( IntervalVar[] intervalVars)

Adds NoOverlap(intervalVars).

A NoOverlap constraint ensures that all present intervals do not overlap in time.

Parameters
intervalVarsthe list of interval variables to constrain
Returns
an instance of the Constraint class

Definition at line 832 of file CpModel.java.

◆ addNoOverlap() [3/4]

Constraint com.google.ortools.sat.CpModel.addNoOverlap ( Iterable< IntervalVar > intervalVars)

Adds NoOverlap(intervalVars).

See also
addNoOverlap(IntervalVar[]).

Definition at line 841 of file CpModel.java.

◆ addNoOverlap() [4/4]

Constraint com.google.ortools.sat.CpModel.addNoOverlap ( Iterable< IntervalVar > intervalVars)

Adds NoOverlap(intervalVars).

See also
addNoOverlap(IntervalVar[]).

Definition at line 841 of file CpModel.java.

◆ addNoOverlap2D() [1/2]

NoOverlap2dConstraint com.google.ortools.sat.CpModel.addNoOverlap2D ( )

Adds NoOverlap2D(xIntervals, yIntervals).

A NoOverlap2D constraint ensures that all present rectangles do not overlap on a plan. Each rectangle is aligned with the X and Y axis, and is defined by two intervals which represent its projection onto the X and Y axis.

Furthermore, one box is optional if at least one of the x or y interval is optional.

Returns
an instance of the NoOverlap2dConstraint class. This class allows adding rectangles incrementally.

Definition at line 862 of file CpModel.java.

◆ addNoOverlap2D() [2/2]

NoOverlap2dConstraint com.google.ortools.sat.CpModel.addNoOverlap2D ( )

Adds NoOverlap2D(xIntervals, yIntervals).

A NoOverlap2D constraint ensures that all present rectangles do not overlap on a plan. Each rectangle is aligned with the X and Y axis, and is defined by two intervals which represent its projection onto the X and Y axis.

Furthermore, one box is optional if at least one of the x or y interval is optional.

Returns
an instance of the NoOverlap2dConstraint class. This class allows adding rectangles incrementally.

Definition at line 862 of file CpModel.java.

◆ addReservoirConstraint() [1/2]

ReservoirConstraint com.google.ortools.sat.CpModel.addReservoirConstraint ( long minLevel,
long maxLevel )

Adds a reservoir constraint with optional refill/emptying events.

Maintain a reservoir level within bounds. The water level starts at 0, and at any time, it must be within [min_level, max_level].

Given an event (time, levelChange, active), if active is true, and if time is assigned a value t, then the level of the reservoir changes by levelChange (which is constant) at time t. Therefore, at any time t:

sum(levelChanges[i] * actives[i] if times[i] <= t) in [min_level, max_level]

Note that min level must be <= 0, and the max level must be >= 0. Please use fixed level_changes to simulate an initial state.

Parameters
minLevelat any time, the level of the reservoir must be greater of equal than the min level. minLevel must me <= 0.
maxLevelat any time, the level of the reservoir must be less or equal than the max level. maxLevel must be >= 0.
Returns
an instance of the ReservoirConstraint class
Exceptions
IllegalArgumentExceptionif minLevel > 0
IllegalArgumentExceptionif maxLevel < 0

Definition at line 581 of file CpModel.java.

◆ addReservoirConstraint() [2/2]

ReservoirConstraint com.google.ortools.sat.CpModel.addReservoirConstraint ( long minLevel,
long maxLevel )

Adds a reservoir constraint with optional refill/emptying events.

Maintain a reservoir level within bounds. The water level starts at 0, and at any time, it must be within [min_level, max_level].

Given an event (time, levelChange, active), if active is true, and if time is assigned a value t, then the level of the reservoir changes by levelChange (which is constant) at time t. Therefore, at any time t:

sum(levelChanges[i] * actives[i] if times[i] <= t) in [min_level, max_level]

Note that min level must be <= 0, and the max level must be >= 0. Please use fixed level_changes to simulate an initial state.

Parameters
minLevelat any time, the level of the reservoir must be greater of equal than the min level. minLevel must me <= 0.
maxLevelat any time, the level of the reservoir must be less or equal than the max level. maxLevel must be >= 0.
Returns
an instance of the ReservoirConstraint class
Exceptions
IllegalArgumentExceptionif minLevel > 0
IllegalArgumentExceptionif maxLevel < 0

Definition at line 581 of file CpModel.java.

◆ clearAssumptions() [1/2]

void com.google.ortools.sat.CpModel.clearAssumptions ( )

Remove all assumptions from the model

Definition at line 922 of file CpModel.java.

◆ clearAssumptions() [2/2]

void com.google.ortools.sat.CpModel.clearAssumptions ( )

Remove all assumptions from the model

Definition at line 922 of file CpModel.java.

◆ clearHints() [1/2]

void com.google.ortools.sat.CpModel.clearHints ( )

Remove all solution hints

Definition at line 905 of file CpModel.java.

◆ clearHints() [2/2]

void com.google.ortools.sat.CpModel.clearHints ( )

Remove all solution hints

Definition at line 905 of file CpModel.java.

◆ clearObjective() [1/2]

void com.google.ortools.sat.CpModel.clearObjective ( )

Clears the objective.

Definition at line 972 of file CpModel.java.

◆ clearObjective() [2/2]

void com.google.ortools.sat.CpModel.clearObjective ( )

Clears the objective.

Definition at line 972 of file CpModel.java.

◆ exportToFile() [1/2]

Boolean com.google.ortools.sat.CpModel.exportToFile ( String file)

Write the model as a protocol buffer to 'file'.

Parameters
filefile to write the model to. If the filename ends with 'txt', the model will be written as a text file, otherwise, the binary format will be used.
Returns
true if the model was correctly written.

Definition at line 1024 of file CpModel.java.

◆ exportToFile() [2/2]

Boolean com.google.ortools.sat.CpModel.exportToFile ( String file)

Write the model as a protocol buffer to 'file'.

Parameters
filefile to write the model to. If the filename ends with 'txt', the model will be written as a text file, otherwise, the binary format will be used.
Returns
true if the model was correctly written.

Definition at line 1024 of file CpModel.java.

◆ falseLiteral() [1/2]

Literal com.google.ortools.sat.CpModel.falseLiteral ( )

Returns the false literal.

Definition at line 121 of file CpModel.java.

◆ falseLiteral() [2/2]

Literal com.google.ortools.sat.CpModel.falseLiteral ( )

Returns the false literal.

Definition at line 121 of file CpModel.java.

◆ getBoolVarFromProtoIndex() [1/2]

BoolVar com.google.ortools.sat.CpModel.getBoolVarFromProtoIndex ( int index)

Rebuilds a Boolean variable from an index. Useful after cloning a model.

Definition at line 131 of file CpModel.java.

◆ getBoolVarFromProtoIndex() [2/2]

BoolVar com.google.ortools.sat.CpModel.getBoolVarFromProtoIndex ( int index)

Rebuilds a Boolean variable from an index. Useful after cloning a model.

Definition at line 131 of file CpModel.java.

◆ getBuilder() [1/2]

CpModelProto.Builder com.google.ortools.sat.CpModel.getBuilder ( )

Returns the model builder.

Definition at line 1060 of file CpModel.java.

◆ getBuilder() [2/2]

CpModelProto.Builder com.google.ortools.sat.CpModel.getBuilder ( )

Returns the model builder.

Definition at line 1060 of file CpModel.java.

◆ getClone() [1/2]

CpModel com.google.ortools.sat.CpModel.getClone ( )

Definition at line 69 of file CpModel.java.

◆ getClone() [2/2]

CpModel com.google.ortools.sat.CpModel.getClone ( )

Definition at line 69 of file CpModel.java.

◆ getIntVarFromProtoIndex() [1/2]

IntVar com.google.ortools.sat.CpModel.getIntVarFromProtoIndex ( int index)

Rebuilds an integer variable from an index. Useful after cloning a model.

Definition at line 136 of file CpModel.java.

◆ getIntVarFromProtoIndex() [2/2]

IntVar com.google.ortools.sat.CpModel.getIntVarFromProtoIndex ( int index)

Rebuilds an integer variable from an index. Useful after cloning a model.

Definition at line 136 of file CpModel.java.

◆ hasObjective() [1/2]

boolean com.google.ortools.sat.CpModel.hasObjective ( )

Checks if the model contains an objective.

Definition at line 978 of file CpModel.java.

◆ hasObjective() [2/2]

boolean com.google.ortools.sat.CpModel.hasObjective ( )

Checks if the model contains an objective.

Definition at line 978 of file CpModel.java.

◆ maximize() [1/4]

void com.google.ortools.sat.CpModel.maximize ( DoubleLinearExpr expr)

Adds a maximization objective of a linear expression.

Definition at line 962 of file CpModel.java.

◆ maximize() [2/4]

void com.google.ortools.sat.CpModel.maximize ( DoubleLinearExpr expr)

Adds a maximization objective of a linear expression.

Definition at line 962 of file CpModel.java.

◆ maximize() [3/4]

void com.google.ortools.sat.CpModel.maximize ( LinearArgument expr)

Adds a maximization objective of a linear expression.

Definition at line 950 of file CpModel.java.

◆ maximize() [4/4]

void com.google.ortools.sat.CpModel.maximize ( LinearArgument expr)

Adds a maximization objective of a linear expression.

Definition at line 950 of file CpModel.java.

◆ minimize() [1/4]

void com.google.ortools.sat.CpModel.minimize ( DoubleLinearExpr expr)

Adds a minimization objective of a linear expression.

Definition at line 940 of file CpModel.java.

◆ minimize() [2/4]

void com.google.ortools.sat.CpModel.minimize ( DoubleLinearExpr expr)

Adds a minimization objective of a linear expression.

Definition at line 940 of file CpModel.java.

◆ minimize() [3/4]

void com.google.ortools.sat.CpModel.minimize ( LinearArgument expr)

Objective.

Adds a minimization objective of a linear expression.

Definition at line 929 of file CpModel.java.

◆ minimize() [4/4]

void com.google.ortools.sat.CpModel.minimize ( LinearArgument expr)

Objective.

Adds a minimization objective of a linear expression.

Definition at line 929 of file CpModel.java.

◆ model() [1/2]

CpModelProto com.google.ortools.sat.CpModel.model ( )

Getters.

Definition at line 1051 of file CpModel.java.

◆ model() [2/2]

CpModelProto com.google.ortools.sat.CpModel.model ( )

Getters.

Definition at line 1051 of file CpModel.java.

◆ modelStats() [1/2]

String com.google.ortools.sat.CpModel.modelStats ( )

Returns some statistics on model as a string.

Definition at line 1007 of file CpModel.java.

◆ modelStats() [2/2]

String com.google.ortools.sat.CpModel.modelStats ( )

Returns some statistics on model as a string.

Definition at line 1007 of file CpModel.java.

◆ negated() [1/2]

int com.google.ortools.sat.CpModel.negated ( int index)

Definition at line 1055 of file CpModel.java.

◆ negated() [2/2]

int com.google.ortools.sat.CpModel.negated ( int index)

Definition at line 1055 of file CpModel.java.

◆ newBoolVar() [1/2]

BoolVar com.google.ortools.sat.CpModel.newBoolVar ( String name)

Creates a Boolean variable with the given name.

Definition at line 96 of file CpModel.java.

◆ newBoolVar() [2/2]

BoolVar com.google.ortools.sat.CpModel.newBoolVar ( String name)

Creates a Boolean variable with the given name.

Definition at line 96 of file CpModel.java.

◆ newConstant() [1/2]

IntVar com.google.ortools.sat.CpModel.newConstant ( long value)

Creates a constant variable.

Definition at line 101 of file CpModel.java.

◆ newConstant() [2/2]

IntVar com.google.ortools.sat.CpModel.newConstant ( long value)

Creates a constant variable.

Definition at line 101 of file CpModel.java.

◆ newFixedInterval() [1/2]

IntervalVar com.google.ortools.sat.CpModel.newFixedInterval ( long start,
long size,
String name )

Creates a fixed interval from its start and its size.

Definition at line 760 of file CpModel.java.

◆ newFixedInterval() [2/2]

IntervalVar com.google.ortools.sat.CpModel.newFixedInterval ( long start,
long size,
String name )

Creates a fixed interval from its start and its size.

Definition at line 760 of file CpModel.java.

◆ newFixedSizeIntervalVar() [1/2]

IntervalVar com.google.ortools.sat.CpModel.newFixedSizeIntervalVar ( LinearArgument start,
long size,
String name )

Creates an interval variable from an affine expression start, and a fixed size.

An interval variable is a constraint, that is itself used in other constraints like NoOverlap.

Parameters
startthe start of the interval. It needs to be an affine or constant expression.
sizethe fixed size of the interval.
namethe name of the interval variable.
Returns
An IntervalVar object

Definition at line 750 of file CpModel.java.

◆ newFixedSizeIntervalVar() [2/2]

IntervalVar com.google.ortools.sat.CpModel.newFixedSizeIntervalVar ( LinearArgument start,
long size,
String name )

Creates an interval variable from an affine expression start, and a fixed size.

An interval variable is a constraint, that is itself used in other constraints like NoOverlap.

Parameters
startthe start of the interval. It needs to be an affine or constant expression.
sizethe fixed size of the interval.
namethe name of the interval variable.
Returns
An IntervalVar object

Definition at line 750 of file CpModel.java.

◆ newIntervalVar() [1/2]

IntervalVar com.google.ortools.sat.CpModel.newIntervalVar ( LinearArgument start,
LinearArgument size,
LinearArgument end,
String name )

Scheduling support.

Creates an interval variable from three affine expressions start, size, and end.

An interval variable is a constraint, that is itself used in other constraints like NoOverlap.

Internally, it ensures that start + size == end.

Parameters
startthe start of the interval. It needs to be an affine or constant expression.
sizethe size of the interval. It needs to be an affine or constant expression.
endthe end of the interval. It needs to be an affine or constant expression.
namethe name of the interval variable
Returns
An IntervalVar object

Definition at line 731 of file CpModel.java.

◆ newIntervalVar() [2/2]

IntervalVar com.google.ortools.sat.CpModel.newIntervalVar ( LinearArgument start,
LinearArgument size,
LinearArgument end,
String name )

Scheduling support.

Creates an interval variable from three affine expressions start, size, and end.

An interval variable is a constraint, that is itself used in other constraints like NoOverlap.

Internally, it ensures that start + size == end.

Parameters
startthe start of the interval. It needs to be an affine or constant expression.
sizethe size of the interval. It needs to be an affine or constant expression.
endthe end of the interval. It needs to be an affine or constant expression.
namethe name of the interval variable
Returns
An IntervalVar object

Definition at line 731 of file CpModel.java.

◆ newIntVar() [1/2]

IntVar com.google.ortools.sat.CpModel.newIntVar ( long lb,
long ub,
String name )

Integer variables.

Creates an integer variable with domain [lb, ub].

Definition at line 80 of file CpModel.java.

◆ newIntVar() [2/2]

IntVar com.google.ortools.sat.CpModel.newIntVar ( long lb,
long ub,
String name )

Integer variables.

Creates an integer variable with domain [lb, ub].

Definition at line 80 of file CpModel.java.

◆ newIntVarFromDomain() [1/2]

IntVar com.google.ortools.sat.CpModel.newIntVarFromDomain ( Domain domain,
String name )

Creates an integer variable with given domain.

Parameters
domainan instance of the Domain class.
namethe name of the variable
Returns
a variable with the given domain.

Definition at line 91 of file CpModel.java.

◆ newIntVarFromDomain() [2/2]

IntVar com.google.ortools.sat.CpModel.newIntVarFromDomain ( Domain domain,
String name )

Creates an integer variable with given domain.

Parameters
domainan instance of the Domain class.
namethe name of the variable
Returns
a variable with the given domain.

Definition at line 91 of file CpModel.java.

◆ newOptionalFixedInterval() [1/2]

IntervalVar com.google.ortools.sat.CpModel.newOptionalFixedInterval ( long start,
long size,
Literal isPresent,
String name )

Creates an optional fixed interval from start and size, and an isPresent literal.

Definition at line 817 of file CpModel.java.

◆ newOptionalFixedInterval() [2/2]

IntervalVar com.google.ortools.sat.CpModel.newOptionalFixedInterval ( long start,
long size,
Literal isPresent,
String name )

Creates an optional fixed interval from start and size, and an isPresent literal.

Definition at line 817 of file CpModel.java.

◆ newOptionalFixedSizeIntervalVar() [1/2]

IntervalVar com.google.ortools.sat.CpModel.newOptionalFixedSizeIntervalVar ( LinearArgument start,
long size,
Literal isPresent,
String name )

Creates an optional interval variable from an affine expression start, and a fixed size.

An interval variable is a constraint, that is itself used in other constraints like NoOverlap.

Parameters
startthe start of the interval. It needs to be an affine or constant expression.
sizethe fixed size of the interval.
isPresenta literal that indicates if the interval is active or not. A inactive interval is simply ignored by all constraints.
namethe name of the interval variable.
Returns
An IntervalVar object

Definition at line 806 of file CpModel.java.

◆ newOptionalFixedSizeIntervalVar() [2/2]

IntervalVar com.google.ortools.sat.CpModel.newOptionalFixedSizeIntervalVar ( LinearArgument start,
long size,
Literal isPresent,
String name )

Creates an optional interval variable from an affine expression start, and a fixed size.

An interval variable is a constraint, that is itself used in other constraints like NoOverlap.

Parameters
startthe start of the interval. It needs to be an affine or constant expression.
sizethe fixed size of the interval.
isPresenta literal that indicates if the interval is active or not. A inactive interval is simply ignored by all constraints.
namethe name of the interval variable.
Returns
An IntervalVar object

Definition at line 806 of file CpModel.java.

◆ newOptionalIntervalVar() [1/2]

IntervalVar com.google.ortools.sat.CpModel.newOptionalIntervalVar ( LinearArgument start,
LinearArgument size,
LinearArgument end,
Literal isPresent,
String name )

Creates an optional interval variable from three affine expressions start, size, end, and isPresent.

An optional interval variable is a constraint, that is itself used in other constraints like NoOverlap. This constraint is protected by an isPresent literal that indicates if it is active or not.

Internally, it ensures that isPresent => start + size == end.

Parameters
startthe start of the interval. It needs to be an affine or constant expression.
sizethe size of the interval. It needs to be an affine or constant expression.
endthe end of the interval. It needs to be an affine or constant expression.
isPresenta literal that indicates if the interval is active or not. A inactive interval is simply ignored by all constraints.
nameThe name of the interval variable
Returns
an IntervalVar object

Definition at line 784 of file CpModel.java.

◆ newOptionalIntervalVar() [2/2]

IntervalVar com.google.ortools.sat.CpModel.newOptionalIntervalVar ( LinearArgument start,
LinearArgument size,
LinearArgument end,
Literal isPresent,
String name )

Creates an optional interval variable from three affine expressions start, size, end, and isPresent.

An optional interval variable is a constraint, that is itself used in other constraints like NoOverlap. This constraint is protected by an isPresent literal that indicates if it is active or not.

Internally, it ensures that isPresent => start + size == end.

Parameters
startthe start of the interval. It needs to be an affine or constant expression.
sizethe size of the interval. It needs to be an affine or constant expression.
endthe end of the interval. It needs to be an affine or constant expression.
isPresenta literal that indicates if the interval is active or not. A inactive interval is simply ignored by all constraints.
nameThe name of the interval variable
Returns
an IntervalVar object

Definition at line 784 of file CpModel.java.

◆ trueLiteral() [1/2]

Literal com.google.ortools.sat.CpModel.trueLiteral ( )

Returns the true literal.

Definition at line 111 of file CpModel.java.

◆ trueLiteral() [2/2]

Literal com.google.ortools.sat.CpModel.trueLiteral ( )

Returns the true literal.

Definition at line 111 of file CpModel.java.

◆ validate() [1/2]

String com.google.ortools.sat.CpModel.validate ( )

Returns a non empty string explaining the issue if the model is invalid.

Definition at line 1012 of file CpModel.java.

◆ validate() [2/2]

String com.google.ortools.sat.CpModel.validate ( )

Returns a non empty string explaining the issue if the model is invalid.

Definition at line 1012 of file CpModel.java.


The documentation for this class was generated from the following files: