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 42 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...
 
BoolVar 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 addBoolOr (Iterable< Literal > literals)
 Adds. More...
 
Constraint addAtLeastOne (Literal[] literals)
 Same as addBoolOr. More...
 
Constraint addAtLeastOne (Iterable< Literal > literals)
 Same as addBoolOr. More...
 
Constraint addAtMostOne (Literal[] literals)
 Adds. More...
 
Constraint addAtMostOne (Iterable< Literal > literals)
 Adds. More...
 
Constraint addExactlyOne (Literal[] literals)
 Adds. More...
 
Constraint addExactlyOne (Iterable< Literal > literals)
 Adds. More...
 
Constraint addBoolAnd (Literal[] literals)
 Adds. More...
 
Constraint addBoolAnd (Iterable< Literal > literals)
 Adds. More...
 
Constraint addBoolXor (Literal[] literals)
 Adds. More...
 
Constraint addBoolXor (Iterable< Literal > literals)
 Adds. More...
 
Constraint addImplication (Literal a, Literal b)
 Adds. More...
 
Constraint addLinearExpressionInDomain (LinearArgument expr, Domain domain)
 Adds. More...
 
Constraint addLinearConstraint (LinearArgument expr, long lb, long ub)
 Adds. More...
 
Constraint addEquality (LinearArgument expr, long value)
 Adds. More...
 
Constraint addEquality (LinearArgument left, LinearArgument right)
 Adds. More...
 
Constraint addLessOrEqual (LinearArgument expr, long value)
 Adds. More...
 
Constraint addLessOrEqual (LinearArgument left, LinearArgument right)
 Adds. More...
 
Constraint addLessThan (LinearArgument expr, long value)
 Adds. More...
 
Constraint addLessThan (LinearArgument left, LinearArgument right)
 Adds. More...
 
Constraint addGreaterOrEqual (LinearArgument expr, long value)
 Adds. More...
 
Constraint addGreaterOrEqual (LinearArgument left, LinearArgument right)
 Adds. More...
 
Constraint addGreaterThan (LinearArgument expr, long value)
 Adds. More...
 
Constraint addGreaterThan (LinearArgument left, LinearArgument right)
 Adds. More...
 
Constraint addDifferent (LinearArgument expr, long value)
 Adds. More...
 
Constraint addDifferent (LinearArgument left, LinearArgument right)
 Adds. More...
 
Constraint addAllDifferent (LinearArgument[] expressions)
 Adds. More...
 
Constraint addAllDifferent (Iterable<? extends LinearArgument > expressions)
 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...
 
CircuitConstraint addCircuit ()
 Adds. More...
 
MultipleCircuitConstraint addMultipleCircuit ()
 Adds. More...
 
TableConstraint addAllowedAssignments (IntVar[] variables)
 Adds. More...
 
TableConstraint addAllowedAssignments (Iterable< IntVar > variables)
 Adds. More...
 
TableConstraint addForbiddenAssignments (IntVar[] variables)
 Adds. More...
 
TableConstraint addForbiddenAssignments (Iterable< IntVar > variables)
 Adds. More...
 
AutomatonConstraint addAutomaton (IntVar[] transitionVariables, long startingState, long[] finalStates)
 Adds an automaton constraint. More...
 
Constraint addInverse (IntVar[] variables, IntVar[] inverseVariables)
 Adds. More...
 
ReservoirConstraint addReservoirConstraint (long minLevel, long maxLevel)
 Adds a reservoir constraint with optional refill/emptying events. More...
 
void addMapDomain (IntVar var, Literal[] booleans, long offset)
 Adds. More...
 
Constraint addMinEquality (LinearArgument target, LinearArgument[] exprs)
 Adds. More...
 
Constraint addMinEquality (LinearArgument target, Iterable<? extends LinearArgument > exprs)
 Adds. More...
 
Constraint addMaxEquality (LinearArgument target, LinearArgument[] exprs)
 Adds. More...
 
Constraint addMaxEquality (LinearArgument target, Iterable<? extends LinearArgument > exprs)
 Adds. More...
 
Constraint addDivisionEquality (LinearArgument target, LinearArgument num, LinearArgument denom)
 Adds. More...
 
Constraint addAbsEquality (LinearArgument target, LinearArgument expr)
 Adds. More...
 
Constraint addModuloEquality (LinearArgument target, LinearArgument var, LinearArgument mod)
 Adds. More...
 
Constraint addModuloEquality (LinearArgument target, LinearArgument var, long mod)
 Adds. More...
 
Constraint addMultiplicationEquality (LinearArgument target, LinearArgument[] exprs)
 Adds. More...
 
Constraint addMultiplicationEquality (LinearArgument target, LinearArgument left, LinearArgument right)
 Adds. More...
 
IntervalVar newIntervalVar (LinearArgument start, LinearArgument size, LinearArgument end, String name)
 Creates an interval variable from three affine expressions start, size, and end. More...
 
IntervalVar newFixedSizeIntervalVar (LinearArgument start, long size, String name)
 Creates an interval variable from an affine expression start, and a fixed size. More...
 
IntervalVar newFixedInterval (long start, long size, String name)
 Creates a fixed interval from its start and its size. More...
 
IntervalVar 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. More...
 
IntervalVar newOptionalFixedSizeIntervalVar (LinearArgument start, long size, Literal isPresent, String name)
 Creates an optional interval variable from an affine expression start, and a fixed size. More...
 
IntervalVar newOptionalFixedInterval (long start, long size, Literal isPresent, String name)
 Creates an optional fixed interval from start and size, and an isPresent literal. More...
 
Constraint addNoOverlap (IntervalVar[] intervalVars)
 Adds. More...
 
Constraint addNoOverlap (Iterable< IntervalVar > intervalVars)
 Adds. More...
 
NoOverlap2dConstraint addNoOverlap2D ()
 Adds. More...
 
CumulativeConstraint addCumulative (LinearArgument capacity)
 Adds. More...
 
CumulativeConstraint addCumulative (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 (LinearArgument expr)
 Adds a minimization objective of a linear expression. More...
 
void minimize (DoubleLinearExpr expr)
 Adds a minimization objective of a linear expression. More...
 
void maximize (LinearArgument expr)
 Adds a maximization objective of a linear expression. More...
 
void maximize (DoubleLinearExpr expr)
 Adds a maximization objective of a linear expression. More...
 
void clearObjective ()
 Clears the objective. More...
 
boolean hasObjective ()
 Checks if the model contains an objective. 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 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 64 of file CpModel.java.

Member Function Documentation

◆ addAbsEquality()

Constraint addAbsEquality ( LinearArgument  target,
LinearArgument  expr 
)

Adds.

target == Abs(expr)

.

Definition at line 643 of file CpModel.java.

◆ addAllDifferent() [1/2]

Constraint addAllDifferent ( Iterable<? extends LinearArgument expressions)

Adds.

AllDifferent(expressions)

.

See also
addAllDifferent(LinearArgument[]).

Definition at line 340 of file CpModel.java.

◆ addAllDifferent() [2/2]

Constraint addAllDifferent ( LinearArgument[]  expressions)

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

◆ addAllowedAssignments() [1/2]

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

◆ addAllowedAssignments() [2/2]

TableConstraint addAllowedAssignments ( Iterable< IntVar variables)

Adds.

AllowedAssignments(variables)

.

See also
addAllowedAssignments(IntVar[])

Definition at line 432 of file CpModel.java.

◆ addAssumption()

void addAssumption ( Literal  lit)

Adds a literal to the model as assumption.

Definition at line 894 of file CpModel.java.

◆ addAssumptions()

void addAssumptions ( Literal[]  literals)

Adds multiple literals to the model as assumptions.

Definition at line 899 of file CpModel.java.

◆ addAtLeastOne() [1/2]

Constraint addAtLeastOne ( Iterable< Literal literals)

Same as addBoolOr.

Sum(literals) >= 1

.

Definition at line 145 of file CpModel.java.

◆ addAtLeastOne() [2/2]

Constraint addAtLeastOne ( Literal[]  literals)

Same as addBoolOr.

Sum(literals) >= 1

.

Definition at line 140 of file CpModel.java.

◆ addAtMostOne() [1/2]

Constraint addAtMostOne ( Iterable< Literal literals)

Adds.

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

.

Definition at line 155 of file CpModel.java.

◆ addAtMostOne() [2/2]

Constraint addAtMostOne ( Literal[]  literals)

Adds.

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

.

Definition at line 150 of file CpModel.java.

◆ addAutomaton()

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

◆ addBoolAnd() [1/2]

Constraint addBoolAnd ( Iterable< Literal literals)

Adds.

And(literals) == true

.

Definition at line 185 of file CpModel.java.

◆ addBoolAnd() [2/2]

Constraint addBoolAnd ( Literal[]  literals)

Adds.

And(literals) == true

.

Definition at line 180 of file CpModel.java.

◆ addBoolOr() [1/2]

Constraint addBoolOr ( Iterable< Literal literals)

Adds.

Or(literals) == true

.

Definition at line 130 of file CpModel.java.

◆ addBoolOr() [2/2]

Constraint addBoolOr ( Literal[]  literals)

Adds.

Or(literals) == true

.

Definition at line 125 of file CpModel.java.

◆ addBoolXor() [1/2]

Constraint addBoolXor ( Iterable< Literal literals)

Adds.

XOr(literals) == true

.

Definition at line 200 of file CpModel.java.

◆ addBoolXor() [2/2]

Constraint addBoolXor ( Literal[]  literals)

Adds.

XOr(literals) == true

.

Definition at line 195 of file CpModel.java.

◆ addCircuit()

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

◆ addCumulative() [1/2]

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

◆ addCumulative() [2/2]

CumulativeConstraint addCumulative ( long  capacity)

Adds.

Cumulative(capacity)

.

See also
addCumulative(LinearArgument capacity)

Definition at line 875 of file CpModel.java.

◆ addDecisionStrategy()

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

Adds.

DecisionStrategy(variables, varStr, domStr)

.

Definition at line 969 of file CpModel.java.

◆ addDifferent() [1/2]

Constraint addDifferent ( LinearArgument  expr,
long  value 
)

Adds.

expr != value

.

Definition at line 306 of file CpModel.java.

◆ addDifferent() [2/2]

Constraint addDifferent ( LinearArgument  left,
LinearArgument  right 
)

Adds.

left != right

.

Definition at line 313 of file CpModel.java.

◆ addDivisionEquality()

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

Adds.

target == num / denom

, rounded towards 0.

Definition at line 631 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 374 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 350 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 362 of file CpModel.java.

◆ addEquality() [1/2]

Constraint addEquality ( LinearArgument  expr,
long  value 
)

Adds.

expr == value

.

Definition at line 241 of file CpModel.java.

◆ addEquality() [2/2]

Constraint addEquality ( LinearArgument  left,
LinearArgument  right 
)

Adds.

left == right

.

Definition at line 246 of file CpModel.java.

◆ addExactlyOne() [1/2]

Constraint addExactlyOne ( Iterable< Literal literals)

Adds.

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

.

Definition at line 170 of file CpModel.java.

◆ addExactlyOne() [2/2]

Constraint addExactlyOne ( Literal[]  literals)

Adds.

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

.

Definition at line 165 of file CpModel.java.

◆ addForbiddenAssignments() [1/2]

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

◆ addForbiddenAssignments() [2/2]

TableConstraint addForbiddenAssignments ( Iterable< IntVar variables)

Adds.

ForbiddenAssignments(variables)

.

See also
addForbiddenAssignments(IntVar[])

Definition at line 461 of file CpModel.java.

◆ addGreaterOrEqual() [1/2]

Constraint addGreaterOrEqual ( LinearArgument  expr,
long  value 
)

Adds.

expr >= value

.

Definition at line 280 of file CpModel.java.

◆ addGreaterOrEqual() [2/2]

Constraint addGreaterOrEqual ( LinearArgument  left,
LinearArgument  right 
)

Adds.

left >= right

.

Definition at line 285 of file CpModel.java.

◆ addGreaterThan() [1/2]

Constraint addGreaterThan ( LinearArgument  expr,
long  value 
)

Adds.

expr > value

.

Definition at line 293 of file CpModel.java.

◆ addGreaterThan() [2/2]

Constraint addGreaterThan ( LinearArgument  left,
LinearArgument  right 
)

Adds.

left > right

.

Definition at line 298 of file CpModel.java.

◆ addHint()

void addHint ( IntVar  var,
long  value 
)

Adds hinting to a variable.

Definition at line 883 of file CpModel.java.

◆ addImplication()

Constraint addImplication ( Literal  a,
Literal  b 
)

Adds.

a => b

.

Definition at line 210 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 525 of file CpModel.java.

◆ addLessOrEqual() [1/2]

Constraint addLessOrEqual ( LinearArgument  expr,
long  value 
)

Adds.

expr <= value

.

Definition at line 254 of file CpModel.java.

◆ addLessOrEqual() [2/2]

Constraint addLessOrEqual ( LinearArgument  left,
LinearArgument  right 
)

Adds.

left <= right

.

Definition at line 259 of file CpModel.java.

◆ addLessThan() [1/2]

Constraint addLessThan ( LinearArgument  expr,
long  value 
)

Adds.

expr < value

.

Definition at line 267 of file CpModel.java.

◆ addLessThan() [2/2]

Constraint addLessThan ( LinearArgument  left,
LinearArgument  right 
)

Adds.

left < right

.

Definition at line 272 of file CpModel.java.

◆ addLinearConstraint()

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

Adds.

lb <= expr <= ub

.

Definition at line 236 of file CpModel.java.

◆ addLinearExpressionInDomain()

Constraint addLinearExpressionInDomain ( LinearArgument  expr,
Domain  domain 
)

Adds.

expr in domain

.

Definition at line 217 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 577 of file CpModel.java.

◆ addMaxEquality() [1/2]

Constraint addMaxEquality ( LinearArgument  target,
Iterable<? extends LinearArgument exprs 
)

Adds.

target == Max(exprs)

.

Definition at line 619 of file CpModel.java.

◆ addMaxEquality() [2/2]

Constraint addMaxEquality ( LinearArgument  target,
LinearArgument[]  exprs 
)

Adds.

target == Max(vars)

.

Definition at line 608 of file CpModel.java.

◆ addMinEquality() [1/2]

Constraint addMinEquality ( LinearArgument  target,
Iterable<? extends LinearArgument exprs 
)

Adds.

target == Min(exprs)

.

Definition at line 596 of file CpModel.java.

◆ addMinEquality() [2/2]

Constraint addMinEquality ( LinearArgument  target,
LinearArgument[]  exprs 
)

Adds.

target == Min(vars)

.

Definition at line 585 of file CpModel.java.

◆ addModuloEquality() [1/2]

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

Adds.

target == var % mod

.

Definition at line 653 of file CpModel.java.

◆ addModuloEquality() [2/2]

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

Adds.

target == var % mod

.

Definition at line 665 of file CpModel.java.

◆ addMultipleCircuit()

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

◆ addMultiplicationEquality() [1/2]

Constraint addMultiplicationEquality ( LinearArgument  target,
LinearArgument  left,
LinearArgument  right 
)

Adds.

target == left * right

.

Definition at line 687 of file CpModel.java.

◆ addMultiplicationEquality() [2/2]

Constraint addMultiplicationEquality ( LinearArgument  target,
LinearArgument[]  exprs 
)

Adds.

target == Product(exprs)

.

Definition at line 676 of file CpModel.java.

◆ addNoOverlap() [1/2]

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

◆ addNoOverlap() [2/2]

Constraint addNoOverlap ( Iterable< IntervalVar intervalVars)

Adds.

NoOverlap(intervalVars)

.

See also
addNoOverlap(IntervalVar[]).

Definition at line 825 of file CpModel.java.

◆ addNoOverlap2D()

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

◆ addReservoirConstraint()

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

◆ clearAssumptions()

void clearAssumptions ( )

Remove all assumptions from the model.

Definition at line 906 of file CpModel.java.

◆ clearHints()

void clearHints ( )

Remove all solution hints.

Definition at line 889 of file CpModel.java.

◆ clearObjective()

void clearObjective ( )

Clears the objective.

Definition at line 956 of file CpModel.java.

◆ exportToFile()

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

◆ falseLiteral()

Literal falseLiteral ( )

Returns the false literal.

Definition at line 113 of file CpModel.java.

◆ getBuilder()

CpModelProto.Builder getBuilder ( )

Returns the model builder.

Definition at line 1033 of file CpModel.java.

◆ hasObjective()

boolean hasObjective ( )

Checks if the model contains an objective.

Definition at line 962 of file CpModel.java.

◆ maximize() [1/2]

void maximize ( DoubleLinearExpr  expr)

Adds a maximization objective of a linear expression.

Definition at line 946 of file CpModel.java.

◆ maximize() [2/2]

void maximize ( LinearArgument  expr)

Adds a maximization objective of a linear expression.

Definition at line 934 of file CpModel.java.

◆ minimize() [1/2]

void minimize ( DoubleLinearExpr  expr)

Adds a minimization objective of a linear expression.

Definition at line 924 of file CpModel.java.

◆ minimize() [2/2]

void minimize ( LinearArgument  expr)

Adds a minimization objective of a linear expression.

Definition at line 913 of file CpModel.java.

◆ model()

CpModelProto model ( )

Definition at line 1024 of file CpModel.java.

◆ modelStats()

String modelStats ( )

Returns some statistics on model as a string.

Definition at line 980 of file CpModel.java.

◆ negated()

int negated ( int  index)

Definition at line 1028 of file CpModel.java.

◆ newBoolVar()

BoolVar newBoolVar ( String  name)

Creates a Boolean variable with the given name.

Definition at line 88 of file CpModel.java.

◆ newConstant()

IntVar newConstant ( long  value)

Creates a constant variable.

Definition at line 93 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 743 of file CpModel.java.

◆ newFixedSizeIntervalVar()

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

◆ newIntervalVar()

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

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

◆ newIntVar()

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

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

Definition at line 72 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 83 of file CpModel.java.

◆ newOptionalFixedInterval()

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

◆ newOptionalFixedSizeIntervalVar()

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

◆ newOptionalIntervalVar()

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

◆ trueLiteral()

Literal trueLiteral ( )

Returns the true literal.

Definition at line 103 of file CpModel.java.

◆ validate()

String validate ( )

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

Definition at line 985 of file CpModel.java.


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