Java Reference

Java Reference

Detailed Description

Main modeling class.

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

Definition at line 41 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...
 
Literal trueLiteral ()
 Returns the true literal. More...
 
Literal falseLiteral ()
 Returns the false literal. 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)
 Adds. More...
 
Constraint addAllowedAssignments (IntVar[] variables, long[][] tuplesList)
 Adds. More...
 
Constraint addAllowedAssignments (IntVar[] variables, int[][] tuplesList)
 Adds. More...
 
Constraint addForbiddenAssignments (IntVar[] variables, long[][] tuplesList)
 Adds. More...
 
Constraint addForbiddenAssignments (IntVar[] variables, int[][] tuplesList)
 Adds. More...
 
Constraint addAutomaton (IntVar[] transitionVariables, long startingState, long[] finalStates, long[][] transitions)
 Adds an automaton constraint. More...
 
Constraint addInverse (IntVar[] variables, IntVar[] inverseVariables)
 Adds. More...
 
Constraint addReservoirConstraint (IntVar[] times, long[] demands, long minLevel, long maxLevel)
 Adds. More...
 
Constraint addReservoirConstraint (IntVar[] times, int[] demands, long minLevel, long maxLevel)
 Adds. More...
 
Constraint addReservoirConstraintWithActive (IntVar[] times, long[] demands, IntVar[] actives, long minLevel, long maxLevel)
 Adds. More...
 
Constraint addReservoirConstraintWithActive (IntVar[] times, int[] demands, IntVar[] actives, long minLevel, long maxLevel)
 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 clearHints ()
 Remove all solution hints. More...
 
void addAssumption (Literal lit)
 Adds a literal to the model as assumption. More...
 
void addAssumptions (Literal[] literals)
 Adds multiple literals to the model as assumptions. More...
 
void clearAssumptions ()
 Remove all assumptions from the model. 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...
 
Boolean exportToFile (String file)
 Write the model as a ascii protocol buffer to 'file'. More...
 
CpModelProto model ()
 
int negated (int index)
 
CpModelProto.Builder getBuilder ()
 Returns the model builder. More...
 

Constructor & Destructor Documentation

◆ CpModel()

CpModel ( )

Definition at line 62 of file CpModel.java.

Member Function Documentation

◆ addAbsEquality()

Constraint addAbsEquality ( IntVar  target,
IntVar  var 
)

Adds.

target == Abs(var)

.

Definition at line 680 of file CpModel.java.

◆ addAllDifferent()

Constraint addAllDifferent ( IntVar[]  variables)

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

◆ addAllowedAssignments() [1/2]

Constraint addAllowedAssignments ( IntVar[]  variables,
int  tuplesList[][] 
)

Adds.

AllowedAssignments(variables, tuplesList)

.

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

Definition at line 387 of file CpModel.java.

◆ addAllowedAssignments() [2/2]

Constraint addAllowedAssignments ( IntVar[]  variables,
long  tuplesList[][] 
)

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

◆ addAssumption()

void addAssumption ( Literal  lit)

Adds a literal to the model as assumption.

Definition at line 994 of file CpModel.java.

◆ addAssumptions()

void addAssumptions ( Literal[]  literals)

Adds multiple literals to the model as assumptions.

Definition at line 999 of file CpModel.java.

◆ addAutomaton()

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

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

◆ addBoolAnd()

Constraint addBoolAnd ( Literal[]  literals)

Adds.

And(literals) == true

.

Definition at line 123 of file CpModel.java.

◆ addBoolOr()

Constraint addBoolOr ( Literal[]  literals)

Adds.

Or(literals) == true

.

Definition at line 113 of file CpModel.java.

◆ addBoolXor()

Constraint addBoolXor ( Literal[]  literals)

Adds.

XOr(literals) == true

.

Definition at line 133 of file CpModel.java.

◆ addCircuit()

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

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

◆ addCumulative() [1/6]

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

Adds.

Cumulative(intervals, demands, capacity)

with fixed demands.

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

Definition at line 933 of file CpModel.java.

◆ addCumulative() [2/6]

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

Adds.

Cumulative(intervals, demands, capacity)

with fixed demands and fixed capacity.

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

Definition at line 978 of file CpModel.java.

◆ addCumulative() [3/6]

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

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

◆ addCumulative() [4/6]

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

Adds.

Cumulative(intervals, demands, capacity)

with fixed capacity.

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

Definition at line 942 of file CpModel.java.

◆ addCumulative() [5/6]

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

Adds.

Cumulative(intervals, demands, capacity)

with fixed demands.

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

Definition at line 915 of file CpModel.java.

◆ addCumulative() [6/6]

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

Adds.

Cumulative(intervals, demands, capacity)

with fixed demands and fixed capacity.

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

Definition at line 960 of file CpModel.java.

◆ addDecisionStrategy()

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

Adds.

DecisionStrategy(variables, varStr, domStr)

.

Definition at line 1034 of file CpModel.java.

◆ addDifferent() [1/2]

Constraint addDifferent ( IntVar  left,
IntVar  right 
)

Adds.

left != right

.

Definition at line 246 of file CpModel.java.

◆ addDifferent() [2/2]

Constraint addDifferent ( LinearExpr  expr,
long  value 
)

Adds.

expr != value

.

Definition at line 239 of file CpModel.java.

◆ addDifferentWithOffset()

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

Adds.

left + offset != right

.

Definition at line 252 of file CpModel.java.

◆ addDivisionEquality()

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

Adds.

target == num / denom

, rounded towards 0.

Definition at line 669 of file CpModel.java.

◆ addElement() [1/3]

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

Adds the element constraint:

values[index] == target

.

Definition at line 302 of file CpModel.java.

◆ addElement() [2/3]

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

Adds the element constraint:

variables[index] == target

.

Definition at line 278 of file CpModel.java.

◆ addElement() [3/3]

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

Adds the element constraint:

values[index] == target

.

Definition at line 290 of file CpModel.java.

◆ addEquality() [1/2]

Constraint addEquality ( LinearExpr  expr,
long  value 
)

Adds.

expr == value

.

Definition at line 172 of file CpModel.java.

◆ addEquality() [2/2]

Constraint addEquality ( LinearExpr  left,
LinearExpr  right 
)

Adds.

left == right

.

Definition at line 177 of file CpModel.java.

◆ addEqualityWithOffset()

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

Adds.

left + offset == right

.

Definition at line 182 of file CpModel.java.

◆ addForbiddenAssignments() [1/2]

Constraint addForbiddenAssignments ( IntVar[]  variables,
int  tuplesList[][] 
)

Adds.

ForbiddenAssignments(variables, tuplesList)

.

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

Definition at line 430 of file CpModel.java.

◆ addForbiddenAssignments() [2/2]

Constraint addForbiddenAssignments ( IntVar[]  variables,
long  tuplesList[][] 
)

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

◆ addGreaterOrEqual() [1/2]

Constraint addGreaterOrEqual ( LinearExpr  expr,
long  value 
)

Adds.

expr >= value

.

Definition at line 213 of file CpModel.java.

◆ addGreaterOrEqual() [2/2]

Constraint addGreaterOrEqual ( LinearExpr  left,
LinearExpr  right 
)

Adds.

left >= right

.

Definition at line 218 of file CpModel.java.

◆ addGreaterOrEqualWithOffset()

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

Adds.

left + offset >= right

.

Definition at line 233 of file CpModel.java.

◆ addGreaterThan() [1/2]

Constraint addGreaterThan ( LinearExpr  expr,
long  value 
)

Adds.

expr > value

.

Definition at line 223 of file CpModel.java.

◆ addGreaterThan() [2/2]

Constraint addGreaterThan ( LinearExpr  left,
LinearExpr  right 
)

Adds.

left > right

.

Definition at line 228 of file CpModel.java.

◆ addHint()

void addHint ( IntVar  var,
long  value 
)

Adds hinting to a variable.

Definition at line 983 of file CpModel.java.

◆ addImplication()

Constraint addImplication ( Literal  a,
Literal  b 
)

Adds.

a => b

.

Definition at line 143 of file CpModel.java.

◆ addInverse()

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

◆ addLessOrEqual() [1/2]

Constraint addLessOrEqual ( LinearExpr  expr,
long  value 
)

Adds.

expr <= value

.

Definition at line 187 of file CpModel.java.

◆ addLessOrEqual() [2/2]

Constraint addLessOrEqual ( LinearExpr  left,
LinearExpr  right 
)

Adds.

left <= right

.

Definition at line 192 of file CpModel.java.

◆ addLessOrEqualWithOffset()

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

Adds.

left + offset <= right

.

Definition at line 207 of file CpModel.java.

◆ addLessThan() [1/2]

Constraint addLessThan ( LinearExpr  expr,
long  value 
)

Adds.

expr < value

.

Definition at line 197 of file CpModel.java.

◆ addLessThan() [2/2]

Constraint addLessThan ( LinearExpr  left,
LinearExpr  right 
)

Adds.

left < right

.

Definition at line 202 of file CpModel.java.

◆ addLinearConstraint()

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

Adds.

lb <= expr <= ub

.

Definition at line 167 of file CpModel.java.

◆ addLinearExpressionInDomain()

Constraint addLinearExpressionInDomain ( LinearExpr  expr,
Domain  domain 
)

Adds.

expr in domain

.

Definition at line 150 of file CpModel.java.

◆ addMapDomain()

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

Adds.

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

.

Definition at line 639 of file CpModel.java.

◆ addMaxEquality()

Constraint addMaxEquality ( IntVar  target,
IntVar[]  vars 
)

Adds.

target == Max(vars)

.

Definition at line 658 of file CpModel.java.

◆ addMinEquality()

Constraint addMinEquality ( IntVar  target,
IntVar[]  vars 
)

Adds.

target == Min(vars)

.

Definition at line 647 of file CpModel.java.

◆ addModuloEquality() [1/2]

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

Adds.

target == var % mod

.

Definition at line 691 of file CpModel.java.

◆ addModuloEquality() [2/2]

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

Adds.

target == var % mod

.

Definition at line 702 of file CpModel.java.

◆ addNoOverlap()

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

◆ addNoOverlap2D()

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

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

◆ addProductEquality()

Constraint addProductEquality ( IntVar  target,
IntVar[]  vars 
)

Adds.

target == Product(vars)

.

Definition at line 713 of file CpModel.java.

◆ addReservoirConstraint() [1/2]

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

Adds.

Reservoir(times, demands, minLevel, maxLevel)

.

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

Definition at line 565 of file CpModel.java.

◆ addReservoirConstraint() [2/2]

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

Adds.

Reservoir(times, demands, minLevel, maxLevel)

.

Maintains a reservoir level within bounds. The water level starts at 0, and at any times, it must be between minLevel and maxLevel. If the variable

times[i]

is assigned a value t, and if

actives[i]

is true, then the current level changes by

demands[i]

(which is constant) at the time t.

Note that

minLevel

must be less than 0, and

maxLevel

must be greater than 0. Therefore,

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

.

Parameters
timesa list of 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 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 Constraint class
Exceptions
MismatchedArrayLengthsif times and demands have different length
IllegalArgumentExceptionif minLevel > 0
IllegalArgumentExceptionif maxLevel < 0

Definition at line 537 of file CpModel.java.

◆ addReservoirConstraintWithActive() [1/2]

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

Adds.

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

.

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

Definition at line 632 of file CpModel.java.

◆ addReservoirConstraintWithActive() [2/2]

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

Adds.

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

.

Maintains a reservoir level within bounds. The water level starts at 0, and at any time, it must be between minLevel and maxLevel. 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

must be less than 0, and

maxLevel

must be greater than 0. Therefore,

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

.

Parameters
timesa list of 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 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 Constraint class
Exceptions
MismatchedArrayLengthsif times, demands, or actives have different length
IllegalArgumentExceptionif minLevel > 0
IllegalArgumentExceptionif maxLevel < 0

Definition at line 593 of file CpModel.java.

◆ clearAssumptions()

void clearAssumptions ( )

Remove all assumptions from the model.

Definition at line 1006 of file CpModel.java.

◆ clearHints()

void clearHints ( )

Remove all solution hints.

Definition at line 989 of file CpModel.java.

◆ exportToFile()

Boolean exportToFile ( String  file)

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

Definition at line 1055 of file CpModel.java.

◆ falseLiteral()

Literal falseLiteral ( )

Returns the false literal.

Definition at line 106 of file CpModel.java.

◆ getBuilder()

CpModelProto.Builder getBuilder ( )

Returns the model builder.

Definition at line 1086 of file CpModel.java.

◆ maximize()

void maximize ( LinearExpr  expr)

Adds a maximization objective of a linear expression.

Definition at line 1022 of file CpModel.java.

◆ minimize()

void minimize ( LinearExpr  expr)

Adds a minimization objective of a linear expression.

Definition at line 1013 of file CpModel.java.

◆ model()

CpModelProto model ( )

Definition at line 1077 of file CpModel.java.

◆ modelStats()

String modelStats ( )

Returns some statistics on model as a string.

Definition at line 1045 of file CpModel.java.

◆ negated()

int negated ( int  index)

Definition at line 1081 of file CpModel.java.

◆ newBoolVar()

IntVar newBoolVar ( String  name)

Creates a Boolean variable with the given name.

Definition at line 86 of file CpModel.java.

◆ newConstant()

IntVar newConstant ( long  value)

Creates a constant variable.

Definition at line 91 of file CpModel.java.

◆ newFixedInterval()

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

Creates a fixed interval from its start and its size.

Definition at line 774 of file CpModel.java.

◆ newIntervalVar() [1/4]

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

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

◆ newIntervalVar() [2/4]

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

Creates an interval variable with a fixed end.

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

Definition at line 748 of file CpModel.java.

◆ newIntervalVar() [3/4]

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

Creates an interval variable with a fixed size.

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

Definition at line 758 of file CpModel.java.

◆ newIntervalVar() [4/4]

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

Creates an interval variable with a fixed start.

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

Definition at line 768 of file CpModel.java.

◆ newIntVar()

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

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

Definition at line 70 of file CpModel.java.

◆ newIntVarFromDomain()

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

◆ newOptionalFixedInterval()

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

Creates an optional fixed interval from start and size.

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

Definition at line 836 of file CpModel.java.

◆ newOptionalIntervalVar() [1/4]

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

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

◆ newOptionalIntervalVar() [2/4]

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

Creates an optional interval with a fixed end.

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

Definition at line 807 of file CpModel.java.

◆ newOptionalIntervalVar() [3/4]

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

Creates an optional interval with a fixed size.

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

Definition at line 818 of file CpModel.java.

◆ newOptionalIntervalVar() [4/4]

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

Creates an optional interval with a fixed start.

Definition at line 825 of file CpModel.java.

◆ trueLiteral()

Literal trueLiteral ( )

Returns the true literal.

Definition at line 101 of file CpModel.java.

◆ validate()

String validate ( )

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

Definition at line 1050 of file CpModel.java.


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