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 43 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 Or(literals) == true. More...
 
Constraint addBoolOr (Iterable< Literal > literals)
 Adds Or(literals) == true. More...
 
Constraint addAtLeastOne (Literal[] literals)
 Same as addBoolOr. More...
 
Constraint addAtLeastOne (Iterable< Literal > literals)
 Same as addBoolOr. More...
 
Constraint addAtMostOne (Literal[] literals)
 Adds AtMostOne(literals): Sum(literals) <= 1. More...
 
Constraint addAtMostOne (Iterable< Literal > literals)
 Adds AtMostOne(literals): Sum(literals) <= 1. More...
 
Constraint addExactlyOne (Literal[] literals)
 Adds ExactlyOne(literals): Sum(literals) == 1. More...
 
Constraint addExactlyOne (Iterable< Literal > literals)
 Adds ExactlyOne(literals): Sum(literals) == 1. More...
 
Constraint addBoolAnd (Literal[] literals)
 Adds And(literals) == true. More...
 
Constraint addBoolAnd (Iterable< Literal > literals)
 Adds And(literals) == true. More...
 
Constraint addBoolXor (Literal[] literals)
 Adds XOr(literals) == true. More...
 
Constraint addBoolXor (Iterable< Literal > literals)
 Adds XOr(literals) == true. More...
 
Constraint addImplication (Literal a, Literal b)
 Adds a => b. More...
 
Constraint addLinearExpressionInDomain (LinearArgument expr, Domain domain)
 Adds expr in domain. More...
 
Constraint addLinearConstraint (LinearArgument expr, long lb, long ub)
 Adds lb <= expr <= ub. More...
 
Constraint addEquality (LinearArgument expr, long value)
 Adds expr == value. More...
 
Constraint addEquality (LinearArgument left, LinearArgument right)
 Adds left == right. More...
 
Constraint addLessOrEqual (LinearArgument expr, long value)
 Adds expr <= value. More...
 
Constraint addLessOrEqual (LinearArgument left, LinearArgument right)
 Adds left <= right. More...
 
Constraint addLessThan (LinearArgument expr, long value)
 Adds expr < value. More...
 
Constraint addLessThan (LinearArgument left, LinearArgument right)
 Adds left < right. More...
 
Constraint addGreaterOrEqual (LinearArgument expr, long value)
 Adds expr >= value. More...
 
Constraint addGreaterOrEqual (LinearArgument left, LinearArgument right)
 Adds left >= right. More...
 
Constraint addGreaterThan (LinearArgument expr, long value)
 Adds expr > value. More...
 
Constraint addGreaterThan (LinearArgument left, LinearArgument right)
 Adds left > right. More...
 
Constraint addDifferent (LinearArgument expr, long value)
 Adds expr != value. More...
 
Constraint addDifferent (LinearArgument left, LinearArgument right)
 Adds left != right. More...
 
Constraint addAllDifferent (LinearArgument[] expressions)
 Adds AllDifferent(expressions). More...
 
Constraint addAllDifferent (Iterable<? extends LinearArgument > expressions)
 Adds AllDifferent(expressions). More...
 
Constraint addElement (IntVar index, IntVar[] variables, IntVar target)
 Adds the element constraint: variables[index] == target. More...
 
Constraint addElement (IntVar index, long[] values, IntVar target)
 Adds the element constraint: values[index] == target. More...
 
Constraint addElement (IntVar index, int[] values, IntVar target)
 Adds the element constraint: values[index] == target. More...
 
CircuitConstraint addCircuit ()
 Adds Circuit(). More...
 
MultipleCircuitConstraint addMultipleCircuit ()
 Adds MultipleCircuit(). More...
 
TableConstraint addAllowedAssignments (IntVar[] variables)
 Adds AllowedAssignments(variables). More...
 
TableConstraint addAllowedAssignments (Iterable< IntVar > variables)
 Adds AllowedAssignments(variables). More...
 
TableConstraint addForbiddenAssignments (IntVar[] variables)
 Adds ForbiddenAssignments(variables). More...
 
TableConstraint addForbiddenAssignments (Iterable< IntVar > variables)
 Adds ForbiddenAssignments(variables). More...
 
AutomatonConstraint addAutomaton (IntVar[] transitionVariables, long startingState, long[] finalStates)
 Adds an automaton constraint. More...
 
Constraint addInverse (IntVar[] variables, IntVar[] inverseVariables)
 Adds Inverse(variables, inverseVariables). 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 var == i + offset <=> booleans[i] == true for all i in [0, booleans.length). More...
 
Constraint addMinEquality (LinearArgument target, LinearArgument[] exprs)
 Adds target == Min(vars). More...
 
Constraint addMinEquality (LinearArgument target, Iterable<? extends LinearArgument > exprs)
 Adds target == Min(exprs). More...
 
Constraint addMaxEquality (LinearArgument target, LinearArgument[] exprs)
 Adds target == Max(vars). More...
 
Constraint addMaxEquality (LinearArgument target, Iterable<? extends LinearArgument > exprs)
 Adds target == Max(exprs). More...
 
Constraint addDivisionEquality (LinearArgument target, LinearArgument num, LinearArgument denom)
 Adds target == num / denom, rounded towards 0. More...
 
Constraint addAbsEquality (LinearArgument target, LinearArgument expr)
 Adds target == Abs(expr). More...
 
Constraint addModuloEquality (LinearArgument target, LinearArgument var, LinearArgument mod)
 Adds target == var % mod. More...
 
Constraint addModuloEquality (LinearArgument target, LinearArgument var, long mod)
 Adds target == var % mod. More...
 
Constraint addMultiplicationEquality (LinearArgument target, LinearArgument[] exprs)
 Adds target == Product(exprs). More...
 
Constraint addMultiplicationEquality (LinearArgument target, LinearArgument left, LinearArgument right)
 Adds target == left * right. 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 NoOverlap(intervalVars). More...
 
Constraint addNoOverlap (Iterable< IntervalVar > intervalVars)
 Adds NoOverlap(intervalVars). More...
 
NoOverlap2dConstraint addNoOverlap2D ()
 Adds NoOverlap2D(xIntervals, yIntervals). More...
 
CumulativeConstraint addCumulative (LinearArgument capacity)
 Adds Cumulative(capacity). More...
 
CumulativeConstraint addCumulative (long capacity)
 Adds Cumulative(capacity). 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)
 
void maximize (LinearArgument expr)
 Adds a maximization objective of a linear expression. More...
 
void maximize (DoubleLinearExpr expr)
 
void addDecisionStrategy (IntVar[] variables, DecisionStrategyProto.VariableSelectionStrategy varStr, DecisionStrategyProto.DomainReductionStrategy domStr)
 Adds DecisionStrategy(variables, varStr, domStr). 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 65 of file CpModel.java.

Member Function Documentation

◆ addAbsEquality()

Constraint addAbsEquality ( LinearArgument  target,
LinearArgument  expr 
)

Adds target == Abs(expr).

Definition at line 644 of file CpModel.java.

◆ addAllDifferent() [1/2]

Constraint addAllDifferent ( Iterable<? extends LinearArgument expressions)

Adds AllDifferent(expressions).

See also
addAllDifferent(LinearArgument[]).

Definition at line 341 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 332 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 424 of file CpModel.java.

◆ addAllowedAssignments() [2/2]

TableConstraint addAllowedAssignments ( Iterable< IntVar variables)

Adds AllowedAssignments(variables).

See also
addAllowedAssignments(IntVar[])

Definition at line 433 of file CpModel.java.

◆ addAssumption()

void addAssumption ( Literal  lit)

Adds a literal to the model as assumption.

Definition at line 895 of file CpModel.java.

◆ addAssumptions()

void addAssumptions ( Literal[]  literals)

Adds multiple literals to the model as assumptions.

Definition at line 900 of file CpModel.java.

◆ addAtLeastOne() [1/2]

Constraint addAtLeastOne ( Iterable< Literal literals)

Same as addBoolOr.

Sum(literals) >= 1.

Definition at line 146 of file CpModel.java.

◆ addAtLeastOne() [2/2]

Constraint addAtLeastOne ( Literal[]  literals)

Same as addBoolOr.

Sum(literals) >= 1.

Definition at line 141 of file CpModel.java.

◆ addAtMostOne() [1/2]

Constraint addAtMostOne ( Iterable< Literal literals)

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

Definition at line 156 of file CpModel.java.

◆ addAtMostOne() [2/2]

Constraint addAtMostOne ( Literal[]  literals)

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

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

◆ addBoolAnd() [1/2]

Constraint addBoolAnd ( Iterable< Literal literals)

Adds And(literals) == true.

Definition at line 186 of file CpModel.java.

◆ addBoolAnd() [2/2]

Constraint addBoolAnd ( Literal[]  literals)

Adds And(literals) == true.

Definition at line 181 of file CpModel.java.

◆ addBoolOr() [1/2]

Constraint addBoolOr ( Iterable< Literal literals)

Adds Or(literals) == true.

Definition at line 131 of file CpModel.java.

◆ addBoolOr() [2/2]

Constraint addBoolOr ( Literal[]  literals)

Adds Or(literals) == true.

Definition at line 126 of file CpModel.java.

◆ addBoolXor() [1/2]

Constraint addBoolXor ( Iterable< Literal literals)

Adds XOr(literals) == true.

Definition at line 201 of file CpModel.java.

◆ addBoolXor() [2/2]

Constraint addBoolXor ( Literal[]  literals)

Adds XOr(literals) == true.

Definition at line 196 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 395 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 864 of file CpModel.java.

◆ addCumulative() [2/2]

CumulativeConstraint addCumulative ( long  capacity)

Adds Cumulative(capacity).

See also
addCumulative(LinearArgument capacity)

Definition at line 876 of file CpModel.java.

◆ addDecisionStrategy()

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

Adds DecisionStrategy(variables, varStr, domStr).

Definition at line 961 of file CpModel.java.

◆ addDifferent() [1/2]

Constraint addDifferent ( LinearArgument  expr,
long  value 
)

Adds expr != value.

Definition at line 307 of file CpModel.java.

◆ addDifferent() [2/2]

Constraint addDifferent ( LinearArgument  left,
LinearArgument  right 
)

Adds left != right.

Definition at line 314 of file CpModel.java.

◆ addDivisionEquality()

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

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

Definition at line 632 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 375 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 351 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 363 of file CpModel.java.

◆ addEquality() [1/2]

Constraint addEquality ( LinearArgument  expr,
long  value 
)

Adds expr == value.

Definition at line 242 of file CpModel.java.

◆ addEquality() [2/2]

Constraint addEquality ( LinearArgument  left,
LinearArgument  right 
)

Adds left == right.

Definition at line 247 of file CpModel.java.

◆ addExactlyOne() [1/2]

Constraint addExactlyOne ( Iterable< Literal literals)

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

Definition at line 171 of file CpModel.java.

◆ addExactlyOne() [2/2]

Constraint addExactlyOne ( Literal[]  literals)

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

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

◆ addForbiddenAssignments() [2/2]

TableConstraint addForbiddenAssignments ( Iterable< IntVar variables)

Adds ForbiddenAssignments(variables).

See also
addForbiddenAssignments(IntVar[])

Definition at line 462 of file CpModel.java.

◆ addGreaterOrEqual() [1/2]

Constraint addGreaterOrEqual ( LinearArgument  expr,
long  value 
)

Adds expr >= value.

Definition at line 281 of file CpModel.java.

◆ addGreaterOrEqual() [2/2]

Constraint addGreaterOrEqual ( LinearArgument  left,
LinearArgument  right 
)

Adds left >= right.

Definition at line 286 of file CpModel.java.

◆ addGreaterThan() [1/2]

Constraint addGreaterThan ( LinearArgument  expr,
long  value 
)

Adds expr > value.

Definition at line 294 of file CpModel.java.

◆ addGreaterThan() [2/2]

Constraint addGreaterThan ( LinearArgument  left,
LinearArgument  right 
)

Adds left > right.

Definition at line 299 of file CpModel.java.

◆ addHint()

void addHint ( IntVar  var,
long  value 
)

Adds hinting to a variable.

Definition at line 884 of file CpModel.java.

◆ addImplication()

Constraint addImplication ( Literal  a,
Literal  b 
)

Adds a => b.

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

◆ addLessOrEqual() [1/2]

Constraint addLessOrEqual ( LinearArgument  expr,
long  value 
)

Adds expr <= value.

Definition at line 255 of file CpModel.java.

◆ addLessOrEqual() [2/2]

Constraint addLessOrEqual ( LinearArgument  left,
LinearArgument  right 
)

Adds left <= right.

Definition at line 260 of file CpModel.java.

◆ addLessThan() [1/2]

Constraint addLessThan ( LinearArgument  expr,
long  value 
)

Adds expr < value.

Definition at line 268 of file CpModel.java.

◆ addLessThan() [2/2]

Constraint addLessThan ( LinearArgument  left,
LinearArgument  right 
)

Adds left < right.

Definition at line 273 of file CpModel.java.

◆ addLinearConstraint()

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

Adds lb <= expr <= ub.

Definition at line 237 of file CpModel.java.

◆ addLinearExpressionInDomain()

Constraint addLinearExpressionInDomain ( LinearArgument  expr,
Domain  domain 
)

Adds expr in domain.

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

◆ addMaxEquality() [1/2]

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

Adds target == Max(exprs).

Definition at line 620 of file CpModel.java.

◆ addMaxEquality() [2/2]

Constraint addMaxEquality ( LinearArgument  target,
LinearArgument[]  exprs 
)

Adds target == Max(vars).

Definition at line 609 of file CpModel.java.

◆ addMinEquality() [1/2]

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

Adds target == Min(exprs).

Definition at line 597 of file CpModel.java.

◆ addMinEquality() [2/2]

Constraint addMinEquality ( LinearArgument  target,
LinearArgument[]  exprs 
)

Adds target == Min(vars).

Definition at line 586 of file CpModel.java.

◆ addModuloEquality() [1/2]

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

Adds target == var % mod.

Definition at line 654 of file CpModel.java.

◆ addModuloEquality() [2/2]

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

Adds target == var % mod.

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

◆ addMultiplicationEquality() [1/2]

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

Adds target == left * right.

Definition at line 688 of file CpModel.java.

◆ addMultiplicationEquality() [2/2]

Constraint addMultiplicationEquality ( LinearArgument  target,
LinearArgument[]  exprs 
)

Adds target == Product(exprs).

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

◆ addNoOverlap() [2/2]

Constraint addNoOverlap ( Iterable< IntervalVar intervalVars)

Adds NoOverlap(intervalVars).

See also
addNoOverlap(IntervalVar[]).

Definition at line 826 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 847 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 564 of file CpModel.java.

◆ clearAssumptions()

void clearAssumptions ( )

Remove all assumptions from the model.

Definition at line 907 of file CpModel.java.

◆ clearHints()

void clearHints ( )

Remove all solution hints.

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

◆ falseLiteral()

Literal falseLiteral ( )

Returns the false literal.

Definition at line 114 of file CpModel.java.

◆ getBuilder()

CpModelProto.Builder getBuilder ( )

Returns the model builder.

Definition at line 1025 of file CpModel.java.

◆ maximize() [1/2]

void maximize ( DoubleLinearExpr  expr)

Definition at line 948 of file CpModel.java.

◆ maximize() [2/2]

void maximize ( LinearArgument  expr)

Adds a maximization objective of a linear expression.

Definition at line 936 of file CpModel.java.

◆ minimize() [1/2]

void minimize ( DoubleLinearExpr  expr)

Definition at line 925 of file CpModel.java.

◆ minimize() [2/2]

void minimize ( LinearArgument  expr)

Adds a minimization objective of a linear expression.

Definition at line 914 of file CpModel.java.

◆ model()

CpModelProto model ( )

Definition at line 1016 of file CpModel.java.

◆ modelStats()

String modelStats ( )

Returns some statistics on model as a string.

Definition at line 972 of file CpModel.java.

◆ negated()

int negated ( int  index)

Definition at line 1020 of file CpModel.java.

◆ newBoolVar()

BoolVar newBoolVar ( String  name)

Creates a Boolean variable with the given name.

Definition at line 89 of file CpModel.java.

◆ newConstant()

IntVar newConstant ( long  value)

Creates a constant variable.

Definition at line 94 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 744 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 734 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 714 of file CpModel.java.

◆ newIntVar()

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

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

Definition at line 73 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 84 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 802 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 791 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 768 of file CpModel.java.

◆ trueLiteral()

Literal trueLiteral ( )

Returns the true literal.

Definition at line 104 of file CpModel.java.

◆ validate()

String validate ( )

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

Definition at line 977 of file CpModel.java.


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