Java Reference

Java Reference

CpModel

Detailed Description

Main modeling class.

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

Definition at line 40 of file CpModel.java.

Classes

class  CpModelException
 
class  MismatchedArrayLengths
 Exception thrown when parallel arrays have mismatched lengths. More...
 
class  WrongLength
 Exception thrown when an array has a wrong length. More...
 

Public Member Functions

 CpModel ()
 
IntVar newIntVar (long lb, long ub, String name)
 Creates an integer variable with domain [lb, ub]. More...
 
IntVar newIntVarFromDomain (Domain domain, String name)
 Creates an integer variable with given domain. More...
 
IntVar newBoolVar (String name)
 Creates a Boolean variable with the given name. More...
 
IntVar newConstant (long value)
 Creates a constant variable. More...
 
Constraint addBoolOr (Literal[] literals)
 Adds. More...
 
Constraint addBoolAnd (Literal[] literals)
 Adds. More...
 
Constraint addBoolXor (Literal[] literals)
 Adds. More...
 
Constraint addImplication (Literal a, Literal b)
 Adds. More...
 
Constraint addLinearExpressionInDomain (LinearExpr expr, Domain domain)
 Adds. More...
 
Constraint addLinearConstraint (LinearExpr expr, long lb, long ub)
 Adds. More...
 
Constraint addEquality (LinearExpr expr, long value)
 Adds. More...
 
Constraint addEquality (LinearExpr left, LinearExpr right)
 Adds. More...
 
Constraint addEqualityWithOffset (LinearExpr left, LinearExpr right, long offset)
 Adds. More...
 
Constraint addLessOrEqual (LinearExpr expr, long value)
 Adds. More...
 
Constraint addLessOrEqual (LinearExpr left, LinearExpr right)
 Adds. More...
 
Constraint addLessThan (LinearExpr expr, long value)
 Adds. More...
 
Constraint addLessThan (LinearExpr left, LinearExpr right)
 Adds. More...
 
Constraint addLessOrEqualWithOffset (LinearExpr left, LinearExpr right, long offset)
 Adds. More...
 
Constraint addGreaterOrEqual (LinearExpr expr, long value)
 Adds. More...
 
Constraint addGreaterOrEqual (LinearExpr left, LinearExpr right)
 Adds. More...
 
Constraint addGreaterThan (LinearExpr expr, long value)
 Adds. More...
 
Constraint addGreaterThan (LinearExpr left, LinearExpr right)
 Adds. More...
 
Constraint addGreaterOrEqualWithOffset (LinearExpr left, LinearExpr right, long offset)
 Adds. More...
 
Constraint addDifferent (LinearExpr expr, long value)
 Adds. More...
 
Constraint addDifferent (IntVar left, IntVar right)
 Adds. More...
 
Constraint addDifferentWithOffset (IntVar left, IntVar right, long offset)
 Adds. More...
 
Constraint addAllDifferent (IntVar[] variables)
 Adds. More...
 
Constraint addElement (IntVar index, IntVar[] variables, IntVar target)
 Adds the element constraint: More...
 
Constraint addElement (IntVar index, long[] values, IntVar target)
 Adds the element constraint: More...
 
Constraint addElement (IntVar index, int[] values, IntVar target)
 Adds the element constraint: More...
 
Constraint addCircuit (int[] tails, int[] heads, Literal[] literals) throws MismatchedArrayLengths
 Adds. More...
 
Constraint addAllowedAssignments (IntVar[] variables, long[][] tuplesList) throws WrongLength
 Adds. More...
 
Constraint addAllowedAssignments (IntVar[] variables, int[][] tuplesList) throws WrongLength
 Adds. More...
 
Constraint addForbiddenAssignments (IntVar[] variables, long[][] tuplesList) throws WrongLength
 Adds. More...
 
Constraint addForbiddenAssignments (IntVar[] variables, int[][] tuplesList) throws WrongLength
 Adds. More...
 
Constraint addAutomaton (IntVar[] transitionVariables, long startingState, long[] finalStates, long[][] transitions) throws WrongLength
 Adds an automaton constraint. More...
 
Constraint addInverse (IntVar[] variables, IntVar[] inverseVariables) throws MismatchedArrayLengths
 Adds. More...
 
Constraint addReservoirConstraint (IntVar[] times, long[] demands, long minLevel, long maxLevel) throws MismatchedArrayLengths
 Adds. More...
 
Constraint addReservoirConstraint (IntVar[] times, int[] demands, long minLevel, long maxLevel) throws MismatchedArrayLengths
 Adds. More...
 
Constraint addReservoirConstraintWithActive (IntVar[] times, long[] demands, IntVar[] actives, long minLevel, long maxLevel) throws MismatchedArrayLengths
 Adds. More...
 
Constraint addReservoirConstraintWithActive (IntVar[] times, int[] demands, IntVar[] actives, long minLevel, long maxLevel) throws MismatchedArrayLengths
 Adds. More...
 
void addMapDomain (IntVar var, Literal[] booleans, long offset)
 Adds. More...
 
Constraint addMinEquality (IntVar target, IntVar[] vars)
 Adds. More...
 
Constraint addMaxEquality (IntVar target, IntVar[] vars)
 Adds. More...
 
Constraint addDivisionEquality (IntVar target, IntVar num, IntVar denom)
 Adds. More...
 
Constraint addAbsEquality (IntVar target, IntVar var)
 Adds. More...
 
Constraint addModuloEquality (IntVar target, IntVar var, IntVar mod)
 Adds. More...
 
Constraint addModuloEquality (IntVar target, IntVar var, long mod)
 Adds. More...
 
Constraint addProductEquality (IntVar target, IntVar[] vars)
 Adds. More...
 
IntervalVar newIntervalVar (IntVar start, IntVar size, IntVar end, String name)
 Creates an interval variable from start, size, and end. More...
 
IntervalVar newIntervalVar (IntVar start, IntVar size, long end, String name)
 Creates an interval variable with a fixed end. More...
 
IntervalVar newIntervalVar (IntVar start, long size, IntVar end, String name)
 Creates an interval variable with a fixed size. More...
 
IntervalVar newIntervalVar (long start, IntVar size, IntVar end, String name)
 Creates an interval variable with a fixed start. More...
 
IntervalVar newFixedInterval (long start, long size, String name)
 Creates a fixed interval from its start and its size. More...
 
IntervalVar newOptionalIntervalVar (IntVar start, IntVar size, IntVar end, Literal isPresent, String name)
 Creates an optional interval variable from start, size, end, and isPresent. More...
 
IntervalVar newOptionalIntervalVar (IntVar start, IntVar size, long end, Literal isPresent, String name)
 Creates an optional interval with a fixed end. More...
 
IntervalVar newOptionalIntervalVar (IntVar start, long size, IntVar end, Literal isPresent, String name)
 Creates an optional interval with a fixed size. More...
 
IntervalVar newOptionalIntervalVar (long start, IntVar size, IntVar end, Literal isPresent, String name)
 Creates an optional interval with a fixed start. More...
 
IntervalVar newOptionalFixedInterval (long start, long size, Literal isPresent, String name)
 Creates an optional fixed interval from start and size. More...
 
Constraint addNoOverlap (IntervalVar[] intervalVars)
 Adds. More...
 
Constraint addNoOverlap2D (IntervalVar[] xIntervals, IntervalVar[] yIntervals)
 Adds. More...
 
Constraint addCumulative (IntervalVar[] intervals, IntVar[] demands, IntVar capacity)
 Adds. More...
 
Constraint addCumulative (IntervalVar[] intervals, long[] demands, IntVar capacity)
 Adds. More...
 
Constraint addCumulative (IntervalVar[] intervals, int[] demands, IntVar capacity)
 Adds. More...
 
Constraint addCumulative (IntervalVar[] intervals, IntVar[] demands, long capacity)
 Adds. More...
 
Constraint addCumulative (IntervalVar[] intervals, long[] demands, long capacity)
 Adds. More...
 
Constraint addCumulative (IntervalVar[] intervals, int[] demands, long capacity)
 Adds. More...
 
void addHint (IntVar var, long value)
 Adds hinting to a variable. More...
 
void minimize (LinearExpr expr)
 Adds a minimization objective of a linear expression. More...
 
void maximize (LinearExpr expr)
 Adds a maximization objective of a linear expression. More...
 
void addDecisionStrategy (IntVar[] variables, DecisionStrategyProto.VariableSelectionStrategy varStr, DecisionStrategyProto.DomainReductionStrategy domStr)
 Adds. More...
 
String modelStats ()
 Returns some statistics on model as a string. More...
 
String validate ()
 Returns a non empty string explaining the issue if the model is invalid. More...
 
CpModelProto model ()
 
int negated (int index)
 
CpModelProto.Builder getBuilder ()
 Returns the model builder. More...
 

Constructor & Destructor Documentation

◆ CpModel()

CpModel ( )
inline

Definition at line 62 of file CpModel.java.

Member Function Documentation

◆ addAbsEquality()

Constraint addAbsEquality ( IntVar  target,
IntVar  var 
)
inline

Adds.

target == Abs(var)

.

Definition at line 656 of file CpModel.java.

◆ addAllDifferent()

Constraint addAllDifferent ( IntVar[]  variables)
inline

Adds.

AllDifferent(variables)

.

This constraint forces all variables to have different values.

Parameters
variablesa list of integer variables
Returns
an instance of the Constraint class

Definition at line 249 of file CpModel.java.

◆ addAllowedAssignments() [1/2]

Constraint addAllowedAssignments ( IntVar[]  variables,
int  tuplesList[][] 
) throws WrongLength
inline

Adds.

AllowedAssignments(variables, tuplesList)

.

See also
addAllowedAssignments(IntVar[], long[][]) addAllowedAssignments

Definition at line 370 of file CpModel.java.

◆ addAllowedAssignments() [2/2]

Constraint addAllowedAssignments ( IntVar[]  variables,
long  tuplesList[][] 
) throws WrongLength
inline

Adds.

AllowedAssignments(variables, tuplesList)

.

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
tuplesLista list of admissible tuples. Each tuple must have the same length as the variables, and the ith value of a tuple corresponds to the ith variable.
Returns
an instance of the Constraint class
Exceptions
WrongLengthif one tuple does not have the same length as the variables

Definition at line 345 of file CpModel.java.

◆ addAutomaton()

Constraint addAutomaton ( IntVar[]  transitionVariables,
long  startingState,
long[]  finalStates,
long  transitions[][] 
) throws WrongLength
inline

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. 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
transitionsa list of transition for the automaton, in the following format (currentState, variableValue, nextState)
Returns
an instance of the Constraint class
Exceptions
WrongLengthif one transition does not have a length of 3

Definition at line 454 of file CpModel.java.

◆ addBoolAnd()

Constraint addBoolAnd ( Literal[]  literals)
inline

Adds.

And(literals) == true

.

Definition at line 107 of file CpModel.java.

◆ addBoolOr()

Constraint addBoolOr ( Literal[]  literals)
inline

Adds.

Or(literals) == true

.

Definition at line 97 of file CpModel.java.

◆ addBoolXor()

Constraint addBoolXor ( Literal[]  literals)
inline

Adds.

XOr(literals) == true

.

Definition at line 117 of file CpModel.java.

◆ addCircuit()

Constraint addCircuit ( int[]  tails,
int[]  heads,
Literal[]  literals 
) throws MismatchedArrayLengths
inline

Adds.

Circuit(tails, heads, literals)

.

Adds a circuit constraint from a sparse list of arcs that encode the graph.

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.

Parameters
tailsthe tails of all arcs
headsthe heads of all arcs
literalsthe literals that control whether an arc is selected or not
Returns
an instance of the Constraint class
Exceptions
MismatchedArrayLengthsif the arrays have different sizes

Definition at line 309 of file CpModel.java.

◆ addCumulative() [1/6]

Constraint addCumulative ( IntervalVar[]  intervals,
int[]  demands,
IntVar  capacity 
)
inline

Adds.

Cumulative(intervals, demands, capacity)

with fixed demands.

See also
addCumulative(IntervalVar[], IntVar[], IntVar) AddCumulative

Definition at line 906 of file CpModel.java.

◆ addCumulative() [2/6]

Constraint addCumulative ( IntervalVar[]  intervals,
int[]  demands,
long  capacity 
)
inline

Adds.

Cumulative(intervals, demands, capacity)

with fixed demands and fixed capacity.

See also
addCumulative(IntervalVar[], IntVar[], IntVar) AddCumulative

Definition at line 951 of file CpModel.java.

◆ addCumulative() [3/6]

Constraint addCumulative ( IntervalVar[]  intervals,
IntVar[]  demands,
IntVar  capacity 
)
inline

Adds.

Cumulative(intervals, demands, capacity)

.

This constraint enforces that:

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

.

Parameters
intervalsthe list of intervals
demandsthe list of demands for each interval. Each demand must be a positive integer variable.
capacitythe maximum capacity of the cumulative constraint. It must be a positive integer variable.
Returns
an instance of the Constraint class

Definition at line 870 of file CpModel.java.

◆ addCumulative() [4/6]

Constraint addCumulative ( IntervalVar[]  intervals,
IntVar[]  demands,
long  capacity 
)
inline

Adds.

Cumulative(intervals, demands, capacity)

with fixed capacity.

See also
addCumulative(IntervalVar[], IntVar[], IntVar) AddCumulative

Definition at line 915 of file CpModel.java.

◆ addCumulative() [5/6]

Constraint addCumulative ( IntervalVar[]  intervals,
long[]  demands,
IntVar  capacity 
)
inline

Adds.

Cumulative(intervals, demands, capacity)

with fixed demands.

See also
addCumulative(IntervalVar[], IntVar[], IntVar) AddCumulative

Definition at line 888 of file CpModel.java.

◆ addCumulative() [6/6]

Constraint addCumulative ( IntervalVar[]  intervals,
long[]  demands,
long  capacity 
)
inline

Adds.

Cumulative(intervals, demands, capacity)

with fixed demands and fixed capacity.

See also
addCumulative(IntervalVar[], IntVar[], IntVar) AddCumulative

Definition at line 933 of file CpModel.java.

◆ addDecisionStrategy()

void addDecisionStrategy ( IntVar[]  variables,
DecisionStrategyProto.VariableSelectionStrategy  varStr,
DecisionStrategyProto.DomainReductionStrategy  domStr 
)
inline

Adds.

DecisionStrategy(variables, varStr, domStr)

.

Definition at line 985 of file CpModel.java.

◆ addDifferent() [1/2]

Constraint addDifferent ( IntVar  left,
IntVar  right 
)
inline

Adds.

left != right

.

Definition at line 227 of file CpModel.java.

◆ addDifferent() [2/2]

Constraint addDifferent ( LinearExpr  expr,
long  value 
)
inline

Adds.

expr != value

.

Definition at line 220 of file CpModel.java.

◆ addDifferentWithOffset()

Constraint addDifferentWithOffset ( IntVar  left,
IntVar  right,
long  offset 
)
inline

Adds.

left + offset != right

.

Definition at line 233 of file CpModel.java.

◆ addDivisionEquality()

Constraint addDivisionEquality ( IntVar  target,
IntVar  num,
IntVar  denom 
)
inline

Adds.

target == num / denom

, rounded towards 0.

Definition at line 646 of file CpModel.java.

◆ addElement() [1/3]

Constraint addElement ( IntVar  index,
int[]  values,
IntVar  target 
)
inline

Adds the element constraint:

values[index] == target

.

Definition at line 283 of file CpModel.java.

◆ addElement() [2/3]

Constraint addElement ( IntVar  index,
IntVar[]  variables,
IntVar  target 
)
inline

Adds the element constraint:

variables[index] == target

.

Definition at line 259 of file CpModel.java.

◆ addElement() [3/3]

Constraint addElement ( IntVar  index,
long[]  values,
IntVar  target 
)
inline

Adds the element constraint:

values[index] == target

.

Definition at line 271 of file CpModel.java.

◆ addEquality() [1/2]

Constraint addEquality ( LinearExpr  expr,
long  value 
)
inline

Adds.

expr == value

.

Definition at line 153 of file CpModel.java.

◆ addEquality() [2/2]

Constraint addEquality ( LinearExpr  left,
LinearExpr  right 
)
inline

Adds.

left == right

.

Definition at line 158 of file CpModel.java.

◆ addEqualityWithOffset()

Constraint addEqualityWithOffset ( LinearExpr  left,
LinearExpr  right,
long  offset 
)
inline

Adds.

left + offset == right

.

Definition at line 163 of file CpModel.java.

◆ addForbiddenAssignments() [1/2]

Constraint addForbiddenAssignments ( IntVar[]  variables,
int  tuplesList[][] 
) throws WrongLength
inline

Adds.

ForbiddenAssignments(variables, tuplesList)

.

See also
addForbiddenAssignments(IntVar[], long[][]) addForbiddenAssignments

Definition at line 415 of file CpModel.java.

◆ addForbiddenAssignments() [2/2]

Constraint addForbiddenAssignments ( IntVar[]  variables,
long  tuplesList[][] 
) throws WrongLength
inline

Adds.

ForbiddenAssignments(variables, tuplesList)

.

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
tuplesLista list of forbidden tuples. Each tuple must have the same length as the variables, and the ith value of a tuple corresponds to the ith variable.
Returns
an instance of the Constraint class
Exceptions
WrongLengthif one tuple does not have the same length as the variables

Definition at line 402 of file CpModel.java.

◆ addGreaterOrEqual() [1/2]

Constraint addGreaterOrEqual ( LinearExpr  expr,
long  value 
)
inline

Adds.

expr >= value

.

Definition at line 194 of file CpModel.java.

◆ addGreaterOrEqual() [2/2]

Constraint addGreaterOrEqual ( LinearExpr  left,
LinearExpr  right 
)
inline

Adds.

left >= right

.

Definition at line 199 of file CpModel.java.

◆ addGreaterOrEqualWithOffset()

Constraint addGreaterOrEqualWithOffset ( LinearExpr  left,
LinearExpr  right,
long  offset 
)
inline

Adds.

left + offset >= right

.

Definition at line 214 of file CpModel.java.

◆ addGreaterThan() [1/2]

Constraint addGreaterThan ( LinearExpr  expr,
long  value 
)
inline

Adds.

expr > value

.

Definition at line 204 of file CpModel.java.

◆ addGreaterThan() [2/2]

Constraint addGreaterThan ( LinearExpr  left,
LinearExpr  right 
)
inline

Adds.

left > right

.

Definition at line 209 of file CpModel.java.

◆ addHint()

void addHint ( IntVar  var,
long  value 
)
inline

Adds hinting to a variable.

Definition at line 956 of file CpModel.java.

◆ addImplication()

Constraint addImplication ( Literal  a,
Literal  b 
)
inline

Adds.

a => b

.

Definition at line 127 of file CpModel.java.

◆ addInverse()

Constraint addInverse ( IntVar[]  variables,
IntVar[]  inverseVariables 
) throws MismatchedArrayLengths
inline

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 487 of file CpModel.java.

◆ addLessOrEqual() [1/2]

Constraint addLessOrEqual ( LinearExpr  expr,
long  value 
)
inline

Adds.

expr <= value

.

Definition at line 168 of file CpModel.java.

◆ addLessOrEqual() [2/2]

Constraint addLessOrEqual ( LinearExpr  left,
LinearExpr  right 
)
inline

Adds.

left <= right

.

Definition at line 173 of file CpModel.java.

◆ addLessOrEqualWithOffset()

Constraint addLessOrEqualWithOffset ( LinearExpr  left,
LinearExpr  right,
long  offset 
)
inline

Adds.

left + offset <= right

.

Definition at line 188 of file CpModel.java.

◆ addLessThan() [1/2]

Constraint addLessThan ( LinearExpr  expr,
long  value 
)
inline

Adds.

expr < value

.

Definition at line 178 of file CpModel.java.

◆ addLessThan() [2/2]

Constraint addLessThan ( LinearExpr  left,
LinearExpr  right 
)
inline

Adds.

left < right

.

Definition at line 183 of file CpModel.java.

◆ addLinearConstraint()

Constraint addLinearConstraint ( LinearExpr  expr,
long  lb,
long  ub 
)
inline

Adds.

lb <= expr <= ub

.

Definition at line 148 of file CpModel.java.

◆ addLinearExpressionInDomain()

Constraint addLinearExpressionInDomain ( LinearExpr  expr,
Domain  domain 
)
inline

Adds.

expr in domain

.

Definition at line 134 of file CpModel.java.

◆ addMapDomain()

void addMapDomain ( IntVar  var,
Literal[]  booleans,
long  offset 
)
inline

Adds.

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

.

Definition at line 616 of file CpModel.java.

◆ addMaxEquality()

Constraint addMaxEquality ( IntVar  target,
IntVar[]  vars 
)
inline

Adds.

target == Max(vars)

.

Definition at line 635 of file CpModel.java.

◆ addMinEquality()

Constraint addMinEquality ( IntVar  target,
IntVar[]  vars 
)
inline

Adds.

target == Min(vars)

.

Definition at line 624 of file CpModel.java.

◆ addModuloEquality() [1/2]

Constraint addModuloEquality ( IntVar  target,
IntVar  var,
IntVar  mod 
)
inline

Adds.

target == var % mod

.

Definition at line 666 of file CpModel.java.

◆ addModuloEquality() [2/2]

Constraint addModuloEquality ( IntVar  target,
IntVar  var,
long  mod 
)
inline

Adds.

target == var % mod

.

Definition at line 676 of file CpModel.java.

◆ addNoOverlap()

Constraint addNoOverlap ( IntervalVar[]  intervalVars)
inline

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 823 of file CpModel.java.

◆ addNoOverlap2D()

Constraint addNoOverlap2D ( IntervalVar[]  xIntervals,
IntervalVar[]  yIntervals 
)
inline

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.

Parameters
xIntervalsthe X coordinates of the rectangles
yIntervalsthe Y coordinates of the rectangles
Returns
an instance of the Constraint class

Definition at line 843 of file CpModel.java.

◆ addProductEquality()

Constraint addProductEquality ( IntVar  target,
IntVar[]  vars 
)
inline

Adds.

target == Product(vars)

.

Definition at line 686 of file CpModel.java.

◆ addReservoirConstraint() [1/2]

Constraint addReservoirConstraint ( IntVar[]  times,
int[]  demands,
long  minLevel,
long  maxLevel 
) throws MismatchedArrayLengths
inline

Adds.

Reservoir(times, demands, minLevel, maxLevel)

.

See also
addReservoirConstraint(IntVar[], long[], long, long) Reservoir

Definition at line 549 of file CpModel.java.

◆ addReservoirConstraint() [2/2]

Constraint addReservoirConstraint ( IntVar[]  times,
long[]  demands,
long  minLevel,
long  maxLevel 
) throws MismatchedArrayLengths
inline

Adds.

Reservoir(times, demands, minLevel, maxLevel)

.

Maintains a reservoir level within bounds. The water level starts at 0, and at any non negative time , it must be between minLevel and maxLevel. Furthermore, this constraints expect all times variables to be non negative. If the variable times[i] is assigned a value t, then the current level changes by demands[i] (which is constant) at the time t.

Note that

minLevel

can be greater than 0, or

maxLevel

can be less than 0. It just forces some demands to be executed at time 0 to make sure that we are within those bounds with the executed demands. Therefore,

forall t >= 0: minLevel <= sum(demands[i] if
times[i] <= t) <= maxLevel

.

Parameters
timesa list of positive integer variables which specify the time of the filling or emptying the reservoir
demandsa list of integer values that specifies the amount of the emptying or feeling
minLevelat any non negative time, the level of the reservoir must be greater of equal than the min level
maxLevelat any non negative time, the level of the reservoir must be less or equal than the max level
Returns
an instance of the Constraint class
Exceptions
MismatchedArrayLengthsif times and demands have different length

Definition at line 526 of file CpModel.java.

◆ addReservoirConstraintWithActive() [1/2]

Constraint addReservoirConstraintWithActive ( IntVar[]  times,
int[]  demands,
IntVar[]  actives,
long  minLevel,
long  maxLevel 
) throws MismatchedArrayLengths
inline

Adds.

Reservoir(times, demands, actives, minLevel, maxLevel)

.

See also
addReservoirConstraintWithActive(IntVar[], long[], IntVar[], long, long) Reservoir

Definition at line 609 of file CpModel.java.

◆ addReservoirConstraintWithActive() [2/2]

Constraint addReservoirConstraintWithActive ( IntVar[]  times,
long[]  demands,
IntVar[]  actives,
long  minLevel,
long  maxLevel 
) throws MismatchedArrayLengths
inline

Adds.

Reservoir(times, demands, actives, minLevel, maxLevel)

.

Maintains a reservoir level within bounds. The water level starts at 0, and at any non negative time , it must be between minLevel and maxLevel. Furthermore, this constraints expect all times variables to be non negative. If actives[i] is true, and if times[i] is assigned a value t, then the current level changes by demands[i] (which is constant) at the time t.

Note that

minLevel

can be greater than 0, or

maxLevel

can be less than 0. It just forces some demands to be executed at time 0 to make sure that we are within those bounds with the executed demands. Therefore,

forall t >= 0: minLevel <= sum(demands[i] *
actives[i] if times[i] <= t) <= maxLevel

.

Parameters
timesa list of positive integer variables which specify the time of the filling or emptying the reservoir
demandsa list of integer values that specifies the amount of the emptying or feeling
activesa list of integer variables that specifies if the operation actually takes place.
minLevelat any non negative time, the level of the reservoir must be greater of equal than the min level
maxLevelat any non negative time, the level of the reservoir must be less or equal than the max level
Returns
an instance of the Constraint class
Exceptions
MismatchedArrayLengthsif times, demands, or actives have different length

Definition at line 579 of file CpModel.java.

◆ getBuilder()

CpModelProto.Builder getBuilder ( )
inline

Returns the model builder.

Definition at line 1035 of file CpModel.java.

◆ maximize()

void maximize ( LinearExpr  expr)
inline

Adds a maximization objective of a linear expression.

Definition at line 973 of file CpModel.java.

◆ minimize()

void minimize ( LinearExpr  expr)
inline

Adds a minimization objective of a linear expression.

Definition at line 964 of file CpModel.java.

◆ model()

CpModelProto model ( )
inline

Definition at line 1026 of file CpModel.java.

◆ modelStats()

String modelStats ( )
inline

Returns some statistics on model as a string.

Definition at line 997 of file CpModel.java.

◆ negated()

int negated ( int  index)
inline

Definition at line 1030 of file CpModel.java.

◆ newBoolVar()

IntVar newBoolVar ( String  name)
inline

Creates a Boolean variable with the given name.

Definition at line 85 of file CpModel.java.

◆ newConstant()

IntVar newConstant ( long  value)
inline

Creates a constant variable.

Definition at line 90 of file CpModel.java.

◆ newFixedInterval()

IntervalVar newFixedInterval ( long  start,
long  size,
String  name 
)
inline

Creates a fixed interval from its start and its size.

Definition at line 747 of file CpModel.java.

◆ newIntervalVar() [1/4]

IntervalVar newIntervalVar ( IntVar  start,
IntVar  size,
IntVar  end,
String  name 
)
inline

Creates an interval variable from 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
sizethe size of the interval
endthe end of the interval
namethe name of the interval variable
Returns
An IntervalVar object

Definition at line 712 of file CpModel.java.

◆ newIntervalVar() [2/4]

IntervalVar newIntervalVar ( IntVar  start,
IntVar  size,
long  end,
String  name 
)
inline

Creates an interval variable with a fixed end.

See also
newIntervalVar(IntVar, IntVar, IntVar, String) newIntervalVar

Definition at line 721 of file CpModel.java.

◆ newIntervalVar() [3/4]

IntervalVar newIntervalVar ( IntVar  start,
long  size,
IntVar  end,
String  name 
)
inline

Creates an interval variable with a fixed size.

See also
newIntervalVar(IntVar, IntVar, IntVar, String) newIntervalVar

Definition at line 731 of file CpModel.java.

◆ newIntervalVar() [4/4]

IntervalVar newIntervalVar ( long  start,
IntVar  size,
IntVar  end,
String  name 
)
inline

Creates an interval variable with a fixed start.

See also
newIntervalVar(IntVar, IntVar, IntVar, String) newIntervalVar

Definition at line 741 of file CpModel.java.

◆ newIntVar()

IntVar newIntVar ( long  lb,
long  ub,
String  name 
)
inline

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

Definition at line 69 of file CpModel.java.

◆ newIntVarFromDomain()

IntVar newIntVarFromDomain ( Domain  domain,
String  name 
)
inline

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 80 of file CpModel.java.

◆ newOptionalFixedInterval()

IntervalVar newOptionalFixedInterval ( long  start,
long  size,
Literal  isPresent,
String  name 
)
inline

Creates an optional fixed interval from start and size.

See also
newOptionalIntervalVar(IntVar, IntVar, IntVar, Literal, String) newOptionalIntervalVar

Definition at line 809 of file CpModel.java.

◆ newOptionalIntervalVar() [1/4]

IntervalVar newOptionalIntervalVar ( IntVar  start,
IntVar  size,
IntVar  end,
Literal  isPresent,
String  name 
)
inline

Creates an optional interval variable from 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 can be an integer value, or an integer variable.
sizethe size of the interval. It can be an integer value, or an integer variable.
endthe end of the interval. It can be an integer value, or an integer variable.
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 769 of file CpModel.java.

◆ newOptionalIntervalVar() [2/4]

IntervalVar newOptionalIntervalVar ( IntVar  start,
IntVar  size,
long  end,
Literal  isPresent,
String  name 
)
inline

Creates an optional interval with a fixed end.

See also
newOptionalIntervalVar(IntVar, IntVar, IntVar, Literal, String) newOptionalIntervalVar

Definition at line 780 of file CpModel.java.

◆ newOptionalIntervalVar() [3/4]

IntervalVar newOptionalIntervalVar ( IntVar  start,
long  size,
IntVar  end,
Literal  isPresent,
String  name 
)
inline

Creates an optional interval with a fixed size.

See also
newOptionalIntervalVar(IntVar, IntVar, IntVar, Literal, String) newOptionalIntervalVar

Definition at line 791 of file CpModel.java.

◆ newOptionalIntervalVar() [4/4]

IntervalVar newOptionalIntervalVar ( long  start,
IntVar  size,
IntVar  end,
Literal  isPresent,
String  name 
)
inline

Creates an optional interval with a fixed start.

Definition at line 798 of file CpModel.java.

◆ validate()

String validate ( )
inline

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

Definition at line 1002 of file CpModel.java.


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