java.lang.Object
org.maxicp.cp.CPFactory
Factory to create
CPSolver, CPIntVar, CPConstraint, CPSeqVar
and some modeling utility methods.
CPFactory may need to post new constraints to the solver when creating some variables. If it needs to do so, it *nevers* run the fixpoint.
Example for the n-queens problem:
Solver cp = Factory.makeSolver(false);
IntVar[] q = Factory.makeIntVarArray(cp, n, n);
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) {
cp.post(Factory.neq(q[i], q[j]));
cp.post(Factory.neqs(q[i], q[j], j - i));
cp.post(Factory.neq(q[i], q[j], i - j));
}
search.onSolution(() ->
System.out.println("solution:" + Arrays.toString(q))
);
DFSearch search = Factory.makeDfs(cp,firstFail(q));
SearchStatistics stats = search.solve();
-
Method Summary
Modifier and TypeMethodDescriptionstatic CPIntVarComputes a variable that is the absolute value of the given variable.static CPConstraintabsent(CPIntervalVar var1) Create a constraint that enforces an interval to be absentstatic CPConstraintallDifferent(CPIntVar[] x) Returns an allDifferent constraint using forward checking algostatic CPConstraintallDifferentDC(CPIntVar[] x) Returns an allDifferent constraint that enforces global arc consistency.static CPConstraintalternative(CPIntervalVar interval, CPIntervalVar[] alternatives) Returns an Alternative constraint: Enforces that if the interval variable interval is present, then one of the intervals from the array alternatives must be present and synchronized with a.static CPConstraintalternative(CPIntervalVar interval, CPIntervalVar[] alternatives, int cardinality) Returns an Alternative constraint: Enforces that if the interval variable interval is present, then cardinality intervals from the array alternatives must be present and synchronized with interval.static CPConstraintalternative(CPIntervalVar interval, CPIntervalVar[] alternatives, CPIntVar cardinality) Returns an Alternative constraint: Enforces that if the interval variable interval is present, then cardinality intervals from the array alternatives must be present and synchronized with a.static CPConstraintalwaysIn(CPCumulFunction fun, int minValue, int maxValue) Requires a cumulative function to always be within the range [minValue..maxValue] on the execution range of the cumulative function.static CPConstraintalwaysIn(CPCumulFunction fun, int minValue, int maxValue, int from, int to) Requires a cumulative function to always be within the range [minValue..maxValue] on the execution range [from..to).static CPConstraintalwaysIn(CPCumulFunction fun, int minValue, int maxValue, int from, int to, Constants.CumulativeAlgo algo) Requires a cumulative function to always be within the range [minValue..maxValue] on the execution range [from..to).static CPConstraintalwaysIn(CPCumulFunction fun, int minValue, int maxValue, Constants.CumulativeAlgo algo) Requires a cumulative function to always be within the range [minValue..maxValue] on the execution range of the cumulative function.static CPConstraintReturn a constraint that enforce that N is the number of indices i such that x[i] is in valsstatic CPConstraintatLeastNValue(CPIntVar[] x, CPIntVar nValue) Returns an atLeastNValue constraint using a forward checking algostatic CPConstraintReturns a circuit constraint (using the successor model)static CPIntervalVardelay(CPIntervalVar intervalVar, int v) A variable that is a view ofintervalVar+v, adding an offset to itstatic CPIntVarReturns a variable representing the value in a matrix at the position specified by the two given row and column index variables This relation is enforced by theElement2Dconstraint posted by calling this method.static CPIntVarReturns a variable representing the value in an array at the position specified by the given index variable This relation is enforced by theElement1Dconstraint posted by calling this method.static CPIntVarReturns a variable representing the value in an array at the position specified by the given index variable This relation is enforced by theElement1Dconstraint posted by calling this method.static CPIntVarReturns a variable representing the value in an array at the position specified by the given index variable This relation is enforced by theElement1Dconstraint posted by calling this method.static CPIntVarend(CPIntervalVar var) Returns a CPIntVar that is equal to the start of interval.static CPConstraintendAt(CPIntervalVar var1, int end) Create a constraint that enforces that var1 ends at endstatic CPConstraintendAtEnd(CPIntervalVar var1, CPIntervalVar var2) Creates a constraint that enforces that the end of var1 is equal to the end of var2static CPConstraintendAtEnd(CPIntervalVar var1, CPIntervalVar var2, int delay) Creates a constraint that enforces that the end of var1 is equal to the end of var2 + delaystatic CPConstraintendAtStart(CPIntervalVar var1, CPIntervalVar var2) Creates a constraint that enforces that the end of var1 is equal to the start of var2static CPConstraintendAtStart(CPIntervalVar var1, CPIntervalVar var2, int delay) Creates a constraint that enforces that the end of var1 is equal to the start of var2 + delaystatic CPConstraintendBeforeEnd(CPIntervalVar var1, CPIntervalVar var2) Creates a constraint that enforces that the end of var1 is lower or equal to the end of var2static CPConstraintendBeforeEnd(CPIntervalVar var1, CPIntervalVar var2, int delay) Creates a constraint that enforces that the end of var1 is lower or equal to the end of var2 + delaystatic CPConstraintendBeforeStart(CPIntervalVar var1, CPIntervalVar var2) Creates a constraint that enforces that the end of var1 is lower or equal to the start of var2static CPConstraintendBeforeStart(CPIntervalVar var1, CPIntervalVar var2, int delay) Creates a constraint that enforces that the end of var1 is lower or equal to the start of var2 + delaystatic CPIntVarendOr(CPIntervalVar interval, int val) Returns a CPIntVar that is equal to the end of interval if it is present, or equal to val if interval is absentstatic CPConstraintReturns a constraint imposing that the variable is equal to some given value.static CPConstraintReturns a constraint imposing that the two different variables must take the value.static CPConstraintReturns a constraint excluding a node from a sequencestatic CPConstraintReturns a constraint imposing that the value is excluded from the set variable.static CPCumulFunctionflat()Creates an elementary flat Cumulative Function.static CPSeqVarA variable that is a view ofseqVarin reverse orderstatic CPConstraintReturns a constraint imposing that the variable is larger or equal to some given value.static CPConstraintReturns a constraint imposing that the a first variable is larger or equal to a second one.static CPConstraintReturns a constraint imposing that the variable is larger to some given value.static CPConstraintReturns a constraint imposing that the a first variable is larger to a second one.static CPConstraintModel the logical implication constraintstatic CPConstraintReturns a constraint imposing that the value is included in the set variable.static CPConstraintReturns a constraint inserting a node within a sequencestatic CPBoolVarisEndBeforeEnd(CPIntervalVar var1, CPIntervalVar var2) Returns a boolean variable representing whether the interval variable var1 ends at or before the end of the interval variable var2.static CPBoolVarisEndBeforeStart(CPIntervalVar var1, CPIntervalVar var2) Returns a boolean variable representing whether the interval variable var1 ends at or before the start of the interval variable var2.static CPBoolVarReturns a boolean variable representing whether one variable is equal to the given constant.static CPBoolVarReturns a boolean variable representing whether two variables are equal This relation is enforced by theIsEqualVarconstraint posted by calling this method.static CPBoolVarReturns a boolean variable representing whether one variable is larger or equal to the given constant.static CPBoolVarReturns a boolean variable representing whether one variable is larger or equal to another.static CPBoolVarReturns a boolean variable representing whether one variable is larger than the given constant.static CPBoolVarReturns a boolean variable representing whether one variable is larger than the given constant.static CPBoolVarisIncluded(CPSetVar x, int v) Returns a boolean variable representing if a set variable contains a given value.static CPConstraintReturns the reified version of the constraintx <= y, i.e. the boolean variable that is set to true if and only ifx <= y.static CPBoolVarReturns a boolean variable representing whether one variable is less or equal to the given constant.static CPBoolVarReturns a boolean variable representing whether one variable is less or equal to another.static CPConstraintReturns the reified version of the constraintx < y, i.e. the boolean variable that is set to true if and only ifx < y.static CPBoolVarReturns a boolean variable representing whether one variable is less than the given constant.static CPBoolVarReturns a boolean variable representing whether one variable is less than the given constant.static CPBoolVarReturns a boolean variable representing whether one variable is not equal to the given constant.static CPBoolVarReturns a boolean variable representing whether two variables are not equalstatic CPBoolVarReturns a variable that is true if at least one variable in x is true, false otherwise.static CPBoolVarisStartBeforeEnd(CPIntervalVar var1, CPIntervalVar var2) Returns a boolean variable representing whether the interval variable var1 starts at or before the end of the interval variable var2.static CPBoolVarisStartBeforeStart(CPIntervalVar var1, CPIntervalVar var2) Returns a boolean variable representing whether the interval variable var1 starts at or before the start of the interval variable var2.static CPConstraintle(CPCumulFunction fun, int maxValue) Requires a cumulative function to always be equal or lesser than a value on the execution range [0..Constants.HORIZON).static CPConstraintle(CPCumulFunction fun, int maxValue, Constants.CumulativeAlgo algo) Requires a cumulative function to always be equal or lesser than a value on the execution range [0..Constants.HORIZON).static CPConstraintReturns a constraint imposing that the variable is less or equal to some given value.static CPConstraintReturns a constraint imposing that the first variable is less or equal to a second one.static CPIntVarlength(CPIntervalVar var) Returns a CPIntVar that is equal to the length of interval.static CPIntVarlengthOr(CPIntervalVar interval, int val) Returns a CPIntVar that is equal to the length of interval if it is present, or equal to val if interval is absentstatic CPConstraintReturns a constraint imposing that the variable is less to some given value.static CPConstraintReturns a constraint imposing that the first variable is less to a second one.static CPBoolVarmakeBoolVar(CPSolver cp) Creates a boolean variable.static CPBoolVarmakeBoolVar(CPSolver cp, boolean containsTrue, boolean containsFalse) Creates a boolean variable.static CPBoolVar[]makeBoolVarArray(int n, Function<Integer, CPBoolVar> body) Creates an array of variables with specified lambda functionstatic CPBoolVar[]makeBoolVarArray(CPSolver cp, int n) Creates an array of boolean variables with specified domain size.static DFSearchCreates a Depth First Search with custom branching heuristicstatic CPIntervalVarCreates a new optional interval variable with a startMin of 0, an unbounded end and unfixed lengthstatic CPIntervalVarmakeIntervalVar(CPSolver cp, boolean optional, int length) Creates a new interval optional or mandatory variable with a startMin of 0, an unbounded end and fixed lengthstatic CPIntervalVarmakeIntervalVar(CPSolver cp, boolean optional, int lengthMin, int lengthMax) Creates a new interval variable with a startMin of 0, a length between lengthMin and lengthMaxstatic CPIntervalVarmakeIntervalVar(CPSolver cp, int length) Creates a new optional interval variable with a startMin of 0, an unbounded end and fixed lengthstatic CPIntervalVarmakeIntervalVar(CPSolver cp, int lengthMin, int lengthMax) Creates a new optional interval variable with a startMin of 0, a length between lengthMin and lengthMaxstatic CPIntervalVar[]makeIntervalVarArray(CPSolver cp, int n) Creates an array of new interval variable with a startMin of 0, an unbounded end and unfixed lengthstatic CPIntVarmakeIntVar(CPSolver cp, int sz) Creates a variable with a domain of specified arity.static CPIntVarmakeIntVar(CPSolver cp, int min, int max) Creates a variable with a domain equal to the specified range.static CPIntVarmakeIntVar(CPSolver cp, Set<Integer> values) Creates a variable with a domain equal to the specified set of values.static CPIntVar[]makeIntVarArray(int n, Function<Integer, CPIntVar> body) Creates an array of variables with specified lambda functionstatic CPIntVar[]makeIntVarArray(CPSolver cp, int n, int sz) Creates an array of variables with specified domain size.static CPIntVar[]makeIntVarArray(CPSolver cp, int n, int min, int max) Creates an array of variables with specified domain bounds.static CPSeqVarmakeSeqVar(CPSolver cp, int nNodes, int start, int end) Creates a sequence variable.static CPSetVarmakeSetVar(CPSolver cp, int n) Creates a set variable with possible elements{0,...,n-1}static CPSolverCreates a constraint programming solverstatic CPSolvermakeSolver(boolean byCopy) Creates a constraint programming solverstatic CPIntVarmakespan(CPIntervalVar... vars) Returns a CPIntVar that is equal to the makespan (the latest end) of the intervals.static CPIntVarComputes a variable that is the maximum of a set of variables.static CPIntVarComputes a variable that is the minimum of a set of variables.static CPCumulFunctionminus(CPCumulFunction fun1, CPCumulFunction fun2) Creates a cumulative Function that is the difference of two cumulative Functions.static CPIntVarA variable that is a view of-x.static CPIntVarA variable that is a view ofx-v.static CPIntVarReturns a variable representing the multiplication of a given set of variables.static CPIntVarA variable that is a view ofx*a.static CPIntVarA variable that isx*b.static CPIntVarstatic CPConstraintReturns a short table constraintstatic CPConstraintReturns a constraint imposing that the variable is different from some given value.static CPConstraintReturns a constraint imposing that the two different variables must take different values.static CPConstraintReturns a constraint imposing that the first variable differs from the second one minus a constant value.static CPSeqVarnonOverlapSequence(CPIntervalVar[] intervals) Creates and post a non-overlap constraint on the intervals in vars and create a sequence variable linked with these intervals representing the order of the intervals in time.static NoOverlapnoOverlap(CPIntervalVar... vars) Creates a constraint that enforces that there is no overlap between the intervals in vars.static CPBoolVarA boolean variable that is a view of!b.static CPConstraintnotBetween(CPSeqVar seqVar, int prev, int node, int succ) Forbids a subsequence of length 3 to appear in aCPSeqVar, removing from the domain all sequences containing the sub-sequence given as input.static CPConstraintReturns an or constraint.static CPCumulFunctionplus(CPCumulFunction fun1, CPCumulFunction fun2) Creates a cumulative Function that is the sum of two cumulative Functions.static CPIntVarA variable that is a view ofx+v.static CPConstraintpresent(CPIntervalVar var1) Create a constraint that enforces an interval to be presentstatic CPCumulFunctionpulse(CPIntervalVar var, int h) Creates an elementary Cumulative Function that is a pulse of height h that happen when the Interval variable var is present.static CPCumulFunctionpulse(CPIntervalVar var, int hMin, int hMax) Creates an elementary Cumulative Function that is a pulse that happen when the Interval variable var is present.static CPCumulFunctionCreates an elementary Cumulative Function that is a pulse of height h that happen at time from.static CPConstraintReturns a constraint requiring a node within a sequencestatic CPConstraintshortTable(CPIntVar[] x, int[][] table, int star) Returns a short table constraintstatic CPIntVarstart(CPIntervalVar var) Returns a CPIntVar that is equal to the start of interval.static CPConstraintstartAfter(CPIntervalVar var1, int start) Create a constraint that enforces the start of var1 to be at or after startstatic CPConstraintstartAt(CPIntervalVar var1, int start) Create a constraint that enforces the start of var1 to be equal to startstatic CPConstraintstartAtEnd(CPIntervalVar var1, CPIntervalVar var2) Creates a constraint that enforces that the start of var1 is equal to the end of var2static CPConstraintstartAtEnd(CPIntervalVar var1, CPIntervalVar var2, int delay) Creates a constraint that enforces that the start of var1 is equal to the end of var2 + delaystatic CPConstraintstartAtStart(CPIntervalVar var1, CPIntervalVar var2) Creates a constraint that enforces that the start of var1 is equal to the start of var2static CPConstraintstartAtStart(CPIntervalVar var1, CPIntervalVar var2, int delay) Creates a constraint that enforces that the start of var1 is equal to the start of var2 + delaystatic CPConstraintstartBefore(CPIntervalVar var1, int start) Create a constraint that enforces the start of var1 to be before or at startstatic CPConstraintstartBeforeEnd(CPIntervalVar var1, CPIntervalVar var2) Creates a constraint that enforces that the start of var1 is lower or equal to the end of var2static CPConstraintstartBeforeEnd(CPIntervalVar var1, CPIntervalVar var2, int delay) Creates a constraint that enforces that the start of var1 is lower or equal to the end of var2 + delaystatic CPConstraintstartBeforeStart(CPIntervalVar var1, CPIntervalVar var2) Creates a constraint that enforces that the start of var1 is lower or equal to the start of var2static CPConstraintstartBeforeStart(CPIntervalVar var1, CPIntervalVar var2, int delay) Creates a constraint that enforces that the start of var1 is lower or equal to the start of var2 + delaystatic CPIntVarstartOr(CPIntervalVar interval, int val) Returns a CPIntVar that is equal to the start of interval if it is present, or equal to val if interval is absentstatic CPIntVarstatus(CPIntervalVar var) Returns a CPBoolVar that is equal to the status of the interval.static CPCumulFunctionCreates an elementary Cumulative Function that is a step of height h that happen at time from.static CPCumulFunctionstepAtEnd(CPIntervalVar var, int h) Creates an elementary Cumulative Function that is a step of height h that happen at the end of the Interval variable var if it is present.static CPCumulFunctionstepAtEnd(CPIntervalVar var, int hMin, int hMax) Creates an elementary Cumulative Function that is a step that happen at the end of the Interval variable var if it is present.static CPCumulFunctionstepAtStart(CPIntervalVar var, int h) Creates an elementary Cumulative Function that is a step of height h that happen at the start of the Interval variable var if it is present.static CPCumulFunctionstepAtStart(CPIntervalVar var, int hMin, int hMax) Creates an elementary Cumulative Function that is a step that happen at the start of the Interval variable var if it is present.static CPBoolVarstrictOrder(CPIntVar x, CPIntVar y) Creates a Boolean variable b encoding the strict ordering between x and y.static CPConstraintReturns a sum constraint.static CPCumulFunctionsum(CPCumulFunction... fun) Creates a cumulative Function that is the sum of zero or more cumulative Functions.static CPIntVarReturns a variable representing the sum of a given set of variables.static CPConstraintReturns a sum constraint.static CPConstraintReturns a sum constraint.static CPConstraintReturns a table constraint
-
Method Details
-
makeSolver
Creates a constraint programming solver- Returns:
- a constraint programming solver with trail-based memory management
-
makeSolver
Creates a constraint programming solver- Parameters:
byCopy- a value that should be true to specify copy-based state management or falso for a trail-based memory management- Returns:
- a constraint programming solver
-
makeSetVar
Creates a set variable with possible elements{0,...,n-1}- Parameters:
cp- the solver in which the variable is createdn- the number of possible values withn > 0- Returns:
- a set variable without required elements, and possible elements
{0,...,n-1}
-
makeIntVar
Creates a variable with a domain of specified arity.- Parameters:
cp- the solver in which the variable is createdsz- a positive value that is the size of the domain- Returns:
- a variable with domain equal to the set {0,...,sz-1}
-
makeIntVar
Creates a variable with a domain equal to the specified range.- Parameters:
cp- the solver in which the variable is createdmin- the lower bound of the domain (included)max- the upper bound of the domain (included)max > min- Returns:
- a variable with domain equal to the set {min,...,max}
-
makeIntVar
Creates a variable with a domain equal to the specified set of values.- Parameters:
cp- the solver in which the variable is createdvalues- a set of values- Returns:
- a variable with domain equal to the set of values
-
makeIntVarArray
Creates an array of variables with specified lambda function- Parameters:
n- the number of variables to createbody- the function that given the index i in the array creates/map the correspondingCPIntVar- Returns:
- an array of n variables
with variable at index i generated as
body.get(i)
-
makeIntVarArray
Creates an array of variables with specified domain size.- Parameters:
cp- the solver in which the variables are createdn- the number of variables to createsz- a positive value that is the size of the domain- Returns:
- an array of n variables, each with domain equal to the set {0,...,sz-1}
-
makeIntVarArray
Creates an array of variables with specified domain bounds.- Parameters:
cp- the solver in which the variables are createdn- the number of variables to createmin- the lower bound of the domain (included)max- the upper bound of the domain (included)max > min- Returns:
- an array of n variables each with a domain equal to the set {min,...,max}
-
makeBoolVar
Creates a boolean variable.- Parameters:
cp- the solver in which the variable is created- Returns:
- an uninstantiated boolean variable
-
makeBoolVar
Creates a boolean variable.- Parameters:
cp- the solver in which the variable is createdcontainsTrue- whether the value true is contained within the domaincontainsFalse- whether the value false is contained within the domain- Returns:
- an uninstantiated boolean variable
-
makeBoolVarArray
Creates an array of variables with specified lambda function- Parameters:
n- the number of variables to createbody- the function that given the index i in the array creates/map the correspondingCPBoolVar- Returns:
- an array of n variables
with variable at index i generated as
body.get(i)
-
makeBoolVarArray
Creates an array of boolean variables with specified domain size.- Parameters:
cp- the solver in which the variables are createdn- the number of variables to create- Returns:
- an array of n boolean variables
-
makeSeqVar
Creates a sequence variable.- Parameters:
cp- the solver in which the variable is created- Returns:
- an uninstantiated boolean variable
-
makeIntervalVar
Creates a new optional interval variable with a startMin of 0, an unbounded end and unfixed length- Parameters:
cp- the solver- Returns:
- a new interval variable
-
makeIntervalVar
Creates a new optional interval variable with a startMin of 0, an unbounded end and fixed length- Parameters:
cp- the solverlength- the length of the interval variable- Returns:
- a new interval variable
-
makeIntervalVar
Creates a new interval optional or mandatory variable with a startMin of 0, an unbounded end and fixed length- Parameters:
cp- the solveroptional- whether the interval variable is optional (true), or mandatory (false)length- the length of the interval variable- Returns:
- a new interval variable
-
makeIntervalVar
Creates a new optional interval variable with a startMin of 0, a length between lengthMin and lengthMax- Parameters:
cp- the solverlengthMin- the length of the interval variablelengthMax- the length of the interval variable- Returns:
- a new interval variable
-
makeIntervalVar
public static CPIntervalVar makeIntervalVar(CPSolver cp, boolean optional, int lengthMin, int lengthMax) Creates a new interval variable with a startMin of 0, a length between lengthMin and lengthMax- Parameters:
cp- the solveroptional- whether the interval variable is optionallengthMin- the length of the interval variablelengthMax- the length of the interval variable- Returns:
- a new interval variable
-
makeIntervalVarArray
Creates an array of new interval variable with a startMin of 0, an unbounded end and unfixed length- Parameters:
cp- the solvern- the number of interval variables- Returns:
- an array of new interval variables each with a startMin of 0 and an unbounded end
-
makeDfs
Creates a Depth First Search with custom branching heuristic// Example of binary search: At each node it selects // the first free variable qi from the array q, // and creates two branches qi=v, qi!=v where v is the min value domain
DFSearch search = Factory.makeDfs(cp, () -> { IntVar qi = Arrays.stream(q).reduce(null, (a, b) -> b.size() > 1 && a == null ? b : a); if (qi == null) { return return EMPTY; } else { int v = qi.min(); Procedure left = () -> eq(qi, v); // left branch Procedure right = () -> neq(qi, v); // right branch return branch(left, right); } });- Parameters:
cp- the solver that will be used for the searchbranching- a generator that is called at each node of the depth first search tree to generate an array ofRunnableobjects that will be used to commit to child nodes. It should returnSearches.EMPTYwhenever the current state is a solution.- Returns:
- the depth first search object ready to execute with
AbstractSearchMethod.solve()orAbstractSearchMethod.optimize(Objective)using the given branching scheme - See Also:
-
plus
A variable that is a view ofx+v.- Parameters:
x- a variablev- a value- Returns:
- a variable that is a view of
x+v
-
minus
A variable that is a view of-x.- Parameters:
x- a variable- Returns:
- a variable that is a view of
-x
-
minus
A variable that is a view ofx-v.- Parameters:
x- a variablev- a value- Returns:
- a variable that is a view of
x-v
-
mul
A variable that is a view ofx*a.- Parameters:
x- a variablea- a constant to multiply x with- Returns:
- a variable that is a view of
x*a
-
flip
A variable that is a view ofseqVarin reverse order- Parameters:
seqVar- a variable- Returns:
- a variable that is a view of
seqVarin reverse order
-
mul
A variable that isx*b.- Parameters:
x- a variableb- a boolvar to multiply x with- Returns:
- a variable that is equal to
x*b
-
abs
Computes a variable that is the absolute value of the given variable. This relation is enforced by theAbsoluteconstraint posted by calling this method.- Parameters:
x- a variable- Returns:
- a variable that represents the absolute value of x
-
sum
Returns a variable representing the sum of a given set of variables. This relation is enforced by theSumconstraint posted by calling this method.- Parameters:
x- the n variables to sum- Returns:
- a variable equal to
x[0]+x[1]+...+x[n-1]
-
sum
Returns a sum constraint.- Parameters:
x- an array of variablesy- a variable- Returns:
- a constraint so that
y = x[0]+x[1]+...+x[n-1]
-
sum
Returns a sum constraint.- Parameters:
x- an array of variablesy- a constant- Returns:
- a constraint so that
y = x[0]+x[1]+...+x[n-1]
-
sum
Returns a sum constraint.Uses a _parameter pack_ to automatically bundle a list of IntVar as an array
- Parameters:
y- the target value for the sum (a constant)x- array of variables- Returns:
- a constraint so that
y = x[0] + ... + x[n-1]
-
mul
Returns a variable representing the multiplication of a given set of variables. This relation is enforced by theMulbinary constraint posted by calling this method.- Parameters:
x- the n variables to multiply- Returns:
- a variable equal to
x[0]*x[1]*...*x[n-1]
-
mul
- Parameters:
x- a variable in the same store as yy- a variable in the same store as x- Returns:
- a variable in the same store representing: x * y
-
max
Computes a variable that is the maximum of a set of variables. This relation is enforced by theMaximumconstraint posted by calling this method.- Parameters:
x- the variables on which to compute the maximum- Returns:
- a variable that represents the maximum on x
- See Also:
-
minimum
Computes a variable that is the minimum of a set of variables. This relation is enforced by theMaximumconstraint posted by calling this method.- Parameters:
x- the variables on which to compute the minimum- Returns:
- a variable that represents the minimum on x
- See Also:
-
eq
Returns a constraint imposing that the variable is equal to some given value.- Parameters:
x- the variable to be assigned to vv- the value that must be assigned to x- Returns:
- a constraint so that
x = v
-
include
Returns a constraint imposing that the value is included in the set variable.- Parameters:
x- the set variable that is constrained to include vv- the value that must be included in x- Returns:
- a constraint so that
v in x
-
exclude
Returns a constraint imposing that the value is excluded from the set variable.- Parameters:
x- the set variable that is constrained to exclude vv- the value that must be excluded from x- Returns:
- a constraint so that
v not in x
-
eq
Returns a constraint imposing that the two different variables must take the value.- Parameters:
x- a variabley- a variable- Returns:
- a constraint so that
x = y
-
neq
Returns a constraint imposing that the variable is different from some given value.- Parameters:
x- the variable that is constrained bo be different from vv- the value that must be different from x- Returns:
- a constraint so that
x != y
-
neq
Returns a constraint imposing that the two different variables must take different values.- Parameters:
x- a variabley- a variable- Returns:
- a constraint so that
x != y
-
neq
Returns a constraint imposing that the first variable differs from the second one minus a constant value.- Parameters:
x- a variabley- a variablec- a constant- Returns:
- a constraint so that
x != y+c
-
le
Returns a constraint imposing that the variable is less or equal to some given value.- Parameters:
x- the variable that is constrained bo be less or equal to vv- the value that must be the upper bound on x- Returns:
- a constraint so that
x <= v
-
le
Returns a constraint imposing that the first variable is less or equal to a second one.- Parameters:
x- a variabley- a variable- Returns:
- a constraint so that
x <= y
-
lt
Returns a constraint imposing that the variable is less to some given value.- Parameters:
x- the variable that is constrained bo be less to vv- the value that must be the upper bound on x- Returns:
- a constraint so that
x < v
-
lt
Returns a constraint imposing that the first variable is less to a second one.- Parameters:
x- a variabley- a variable- Returns:
- a constraint so that
x < y
-
ge
Returns a constraint imposing that the variable is larger or equal to some given value.- Parameters:
x- the variable that is constrained bo be larger or equal to vv- the value that must be the lower bound on x- Returns:
- a constraint so that
x >= v
-
ge
Returns a constraint imposing that the a first variable is larger or equal to a second one.- Parameters:
x- a variabley- a variable- Returns:
- a constraint so that
x >= y
-
gt
Returns a constraint imposing that the variable is larger to some given value.- Parameters:
x- the variable that is constrained bo be larger to vv- the value that must be the lower bound on x- Returns:
- a constraint so that
x > v
-
gt
Returns a constraint imposing that the a first variable is larger to a second one.- Parameters:
x- a variabley- a variable- Returns:
- a constraint so that
x > y
-
isEq
Returns a boolean variable representing whether one variable is equal to the given constant. This relation is enforced by theIsEqualconstraint posted by calling this method.- Parameters:
x- the variablec- the constant- Returns:
- a boolean variable that is true if and only if x takes the value c
- See Also:
-
isEq
Returns a boolean variable representing whether two variables are equal This relation is enforced by theIsEqualVarconstraint posted by calling this method.- Parameters:
x- first variabley- second variable- Returns:
- boolean variable that is set to true if and only if x == y
- See Also:
-
isNeq
Returns a boolean variable representing whether one variable is not equal to the given constant.- Parameters:
x- the variablec- the constant- Returns:
- a boolean variable that is true if and only if x don't take the value c
-
isNeq
Returns a boolean variable representing whether two variables are not equal- Parameters:
x- first variabley- second variable- Returns:
- boolean variable that is set to true if and only if x != y
-
isLe
Returns a boolean variable representing whether one variable is less or equal to the given constant. This relation is enforced by theIsLessOrEqualconstraint posted by calling this method.- Parameters:
x- the variablec- the constant- Returns:
- a boolean variable that is true if and only if x takes a value less or equal to c
-
isLe
Returns a boolean variable representing whether one variable is less or equal to another. This relation is enforced by theIsLessOrEqualVarconstraint posted by calling this method.- Parameters:
x- the variabley- the variable- Returns:
- a boolean variable that is true if and only if x takes a value less or equal to y
-
isLe
Returns the reified version of the constraintx <= y, i.e. the boolean variable that is set to true if and only ifx <= y.- Parameters:
b- the boolean variable that will be set to true if and only ifx <= yx- left hand side of less or equal operatory- right hand side of less or equal operator- Returns:
- the reified constraint
b <-> x <= yx <= y, false otherwise
-
isLt
Returns the reified version of the constraintx < y, i.e. the boolean variable that is set to true if and only ifx < y.- Parameters:
b- the boolean variable that will be set to true if and only ifx < yx- left hand side of less or equal operatory- right hand side of less or equal operator- Returns:
- the reified constraint
b <-> x < yx < y, false otherwise
-
strictOrder
Creates a Boolean variable b encoding the strict ordering between x and y. The constraint enforces x ≠y and links b to the ordering as follows: - b = true if and only if x invalid input: '<' y - b = false if and only if x > y- Parameters:
x- the first integer variabley- the second integer variable- Returns:
- a Boolean variable representing the strict order between x and y
-
isLt
Returns a boolean variable representing whether one variable is less than the given constant. This relation is enforced by theIsLessOrEqualconstraint posted by calling this method.- Parameters:
x- the variablec- the constant- Returns:
- a boolean variable that is true if and only if x takes a value less than c
-
isLt
Returns a boolean variable representing whether one variable is less than the given constant. This relation is enforced by theIsLessOrEqualconstraint posted by calling this method.- Parameters:
x- the variabley- second variable- Returns:
- a boolean variable that is true if and only if x takes a value less than y
-
isGe
Returns a boolean variable representing whether one variable is larger or equal to the given constant. This relation is enforced by theIsLessOrEqualconstraint posted by calling this method.- Parameters:
x- the variablec- the constant- Returns:
- a boolean variable that is true if and only if x takes a value larger or equal to c
-
isGe
Returns a boolean variable representing whether one variable is larger or equal to another. This relation is enforced by theIsLessOrEqualVarconstraint posted by calling this method.- Parameters:
x- left hand side of less or equal operatory- right hand side of less or equal operator- Returns:
- boolean variable value that will be set to true if
x >= y, false otherwise
-
isGt
Returns a boolean variable representing whether one variable is larger than the given constant. This relation is enforced by theIsLessOrEqualconstraint posted by calling this method.- Parameters:
x- the variablec- the constant- Returns:
- a boolean variable that is true if and only if x takes a value larger than c
-
isGt
Returns a boolean variable representing whether one variable is larger than the given constant. This relation is enforced by theIsLessOrEqualconstraint posted by calling this method.- Parameters:
x- the variabley- second variable- Returns:
- a boolean variable that is true if and only if x takes a value larger than y
-
isIncluded
Returns a boolean variable representing if a set variable contains a given value.- Parameters:
x- the set variablev- the value- Returns:
- a boolean variable that is true if and only if x contains v
-
not
A boolean variable that is a view of!b.- Parameters:
b- a boolean variable- Returns:
- a boolean variable that is a view of
!b
-
or
Returns an or constraint.Uses a _parameter pack_ to automatically bundle a list of IntVar as an array
- Parameters:
x- array of variables- Returns:
- a constraint so that
x[0] or ... or x[n-1]
-
implies
Model the logical implication constraint- Parameters:
b1- left-hand side of the implicationb2- right-hand side of the implication- Returns:
- a constraint enforcing "b1 implies b2".
-
isOr
Returns a variable that is true if at least one variable in x is true, false otherwise.- Parameters:
x- an array of variables
-
element
Returns a variable representing the value in an array at the position specified by the given index variable This relation is enforced by theElement1Dconstraint posted by calling this method.- Parameters:
array- the array of valuesy- the variable- Returns:
- a variable equal to
array[y]
-
elementDC
Returns a variable representing the value in an array at the position specified by the given index variable This relation is enforced by theElement1Dconstraint posted by calling this method. This constraint is Domain consistent.- Parameters:
array- the array of valuesy- the variable- Returns:
- a variable equal to
array[y]
-
element
Returns a variable representing the value in an array at the position specified by the given index variable This relation is enforced by theElement1Dconstraint posted by calling this method.- Parameters:
array- the array of valuesy- the variable- Returns:
- a variable equal to
array[y]
-
element
Returns a variable representing the value in a matrix at the position specified by the two given row and column index variables This relation is enforced by theElement2Dconstraint posted by calling this method.- Parameters:
matrix- the n x m 2D array of valuesx- the row variable with domain included in 0..n-1y- the column variable with domain included in 0..m-1- Returns:
- a variable equal to
matrix[x][y]
-
allDifferent
Returns an allDifferent constraint using forward checking algo- Parameters:
x- an array of variables- Returns:
- a constraint so that
x[i] != x[j] for all i < j
-
allDifferentDC
Returns an allDifferent constraint that enforces global arc consistency.- Parameters:
x- an array of variables- Returns:
- a constraint so that
x[i] != x[j] for all i < j
-
atLeastNValue
Returns an atLeastNValue constraint using a forward checking algo- Parameters:
x- an array of variablesnValue- the number of values- Returns:
- a constraint so that
#{x[i] | i in 0..x.length-1} >= nValue
-
among
Return a constraint that enforce that N is the number of indices i such that x[i] is in vals- Parameters:
x- an array of variablesvals- a set of valuesN- a variable- Returns:
- a constraint so that
N = #{i | x[i] in vals}
-
circuit
Returns a circuit constraint (using the successor model)- Parameters:
x- an array of variables (successor array)- Returns:
- a constraint so that the path described by the successor array forms an hamiltonian circuit
-
table
Returns a table constraint- Parameters:
x- an array of variablestable- an array of tuples- Returns:
- a constraint the value taken by the variables in x are from a tuple from the table
-
shortTable
Returns a short table constraint- Parameters:
x- an array of variablestable- an array of tuplesstar- the value symbolizing the * (i.e. universal value) in the table- Returns:
- a constraint the value taken by the variables in x are from a tuple from the table
-
negTable
Returns a short table constraint- Parameters:
x- an array of variablestable- an array of tuples- Returns:
- a constraint the value taken by the variables in x are not from a tuple from the table
-
insert
Returns a constraint inserting a node within a sequence- Parameters:
seqVar- sequence is which the node must be insertedprev- predecessor of the node to insertnode- node that must be inserted- Returns:
- a constraint so that
seqVar.memberAfter(prev) == node
-
require
Returns a constraint requiring a node within a sequence- Parameters:
seqVar- sequence is which the node must be requirednode- node to require- Returns:
- a constraint so that
seqVar.isNode(node, REQUIRED)holds
-
exclude
Returns a constraint excluding a node from a sequence- Parameters:
seqVar- sequence is which the node must be excludednode- node to exclude- Returns:
- a constraint so that
seqVar.isNode(node, EXCLUDED)holds
-
notBetween
Forbids a subsequence of length 3 to appear in aCPSeqVar, removing from the domain all sequences containing the sub-sequence given as input.For technical reasons, the two endpoints of the subsequence must belong to the current partial sequence.
- Parameters:
seqVar- sequence in which the subsequence must be removedprev- origin of the subsequence, a member nodenode- node in the middle of the subsequencesucc- end of the subsequence, a member node- Returns:
- a constraint applying a
seqVar.notBetween(prev, node, succ)
-
status
Returns a CPBoolVar that is equal to the status of the interval.- Parameters:
var- the interval variable- Returns:
- a CPBoolVar that is equal to the status of the interval
-
present
Create a constraint that enforces an interval to be present- Parameters:
var1- the interval variable- Returns:
- a constraint that enforces the interval to be present
-
absent
Create a constraint that enforces an interval to be absent- Parameters:
var1- the interval variable- Returns:
- a constraint that enforces the interval to be absent
-
delay
A variable that is a view ofintervalVar+v, adding an offset to it- Parameters:
intervalVar- a variablev- a value- Returns:
- a variable that is a view of
intervalVar+v
-
start
Returns a CPIntVar that is equal to the start of interval.- Parameters:
var- the interval variable, it must be present at the time of the posting- Returns:
- a CPIntVar that is equal to the start of interval
-
startOr
Returns a CPIntVar that is equal to the start of interval if it is present, or equal to val if interval is absent- Parameters:
interval- the interval variableval- the value taken by the returned variable if interval is absent- Returns:
- a CPIntVar that is equal to the start of interval if it is present, or equal to val if interval is absent
-
startAt
Create a constraint that enforces the start of var1 to be equal to start- Parameters:
var1- the interval variablestart- the start value- Returns:
- a constraint that enforces the start of var1 to be equal to start
-
startAfter
Create a constraint that enforces the start of var1 to be at or after start- Parameters:
var1- the interval variablestart- the start value- Returns:
- a constraint that enforces the start of var1 to be at or after start
-
startBefore
Create a constraint that enforces the start of var1 to be before or at start- Parameters:
var1- the interval variablestart- the start value- Returns:
- a constraint that enforces the start of var1 to be before or at start
-
startAtStart
Creates a constraint that enforces that the start of var1 is equal to the start of var2- Parameters:
var1- an interval variablevar2- an interval variable- Returns:
- a constraint that enforces the start of var1 to be equal to the start of var2
-
startAtStart
Creates a constraint that enforces that the start of var1 is equal to the start of var2 + delay- Parameters:
var1- an interval variablevar2- an interval variabledelay- a value- Returns:
- a constraint that enforces the start of var1 to be equal to the start of var2 + delay
-
startAtEnd
Creates a constraint that enforces that the start of var1 is equal to the end of var2- Parameters:
var1- an interval variablevar2- an interval variable- Returns:
- a constraint that enforces the start of var1 to be equal to the end of var2
-
startAtEnd
Creates a constraint that enforces that the start of var1 is equal to the end of var2 + delay- Parameters:
var1- an interval variablevar2- an interval variabledelay- a value- Returns:
- a constraint that enforces the start of var1 to be equal to the end of var2 + delay
-
startBeforeStart
Creates a constraint that enforces that the start of var1 is lower or equal to the start of var2- Parameters:
var1- an interval variablevar2- an interval variable- Returns:
- a constraint that enforces
var1.start <= var2.start
-
startBeforeStart
Creates a constraint that enforces that the start of var1 is lower or equal to the start of var2 + delay- Parameters:
var1- an interval variablevar2- an interval variabledelay- a value- Returns:
- a constraint that enforces
var1.start <= var2.start
-
startBeforeEnd
Creates a constraint that enforces that the start of var1 is lower or equal to the end of var2- Parameters:
var1- an interval variablevar2- an interval variable- Returns:
- a constraint that enforces
var1.start <= var2.end
-
startBeforeEnd
Creates a constraint that enforces that the start of var1 is lower or equal to the end of var2 + delay- Parameters:
var1- an interval variablevar2- an interval variabledelay- a value- Returns:
- a constraint that enforces
var1.start <= var2.end + delay
-
isStartBeforeStart
Returns a boolean variable representing whether the interval variable var1 starts at or before the start of the interval variable var2. This relation is enforced by theIsStartBeforeStartconstraint posted by calling this method.- Parameters:
var1- An interval variablevar2- An interval variable- Returns:
- a boolean variable which is a reification of the constraint
var1.start <= var2.start
-
isStartBeforeEnd
Returns a boolean variable representing whether the interval variable var1 starts at or before the end of the interval variable var2. This relation is enforced by theIsStartBeforeEndconstraint posted by calling this method.- Parameters:
var1- An interval variablevar2- An interval variable- Returns:
- a boolean variable which is a reification of the constraint
var1.start <= var2.end
-
end
Returns a CPIntVar that is equal to the start of interval.- Parameters:
var- the interval variable, it must be present at the time of the posting- Returns:
- a CPIntVar that is equal to the end of interval
-
endOr
Returns a CPIntVar that is equal to the end of interval if it is present, or equal to val if interval is absent- Parameters:
interval- the interval variableval- the value taken by the returned variable if interval is absent- Returns:
- a CPIntVar that is equal to the end of interval if it is present, or equal to val if interval is absent
-
endAt
Create a constraint that enforces that var1 ends at end- Parameters:
var1- the interval variableend- the end value- Returns:
- a constraint that enforces that var1 ends at end
-
endAtStart
Creates a constraint that enforces that the end of var1 is equal to the start of var2- Parameters:
var1- an interval variablevar2- an interval variable- Returns:
- a constraint that enforces the end of var1 to be equal to the start of var2
-
endAtStart
Creates a constraint that enforces that the end of var1 is equal to the start of var2 + delay- Parameters:
var1- an interval variablevar2- an interval variabledelay- a value- Returns:
- a constraint that enforces the end of var1 to be equal to the start of var2 + delay
-
endAtEnd
Creates a constraint that enforces that the end of var1 is equal to the end of var2- Parameters:
var1- an interval variablevar2- an interval variable- Returns:
- a constraint that enforces the end of var1 to be equal to the end of var2
-
endAtEnd
Creates a constraint that enforces that the end of var1 is equal to the end of var2 + delay- Parameters:
var1- an interval variablevar2- an interval variabledelay- a value- Returns:
- a constraint that enforces the end of var1 to be equal to the end of var2 + delay
-
endBeforeStart
Creates a constraint that enforces that the end of var1 is lower or equal to the start of var2- Parameters:
var1- an interval variablevar2- an interval variable- Returns:
- a constraint that enforces
var1.end <= var2.start
-
endBeforeStart
Creates a constraint that enforces that the end of var1 is lower or equal to the start of var2 + delay- Parameters:
var1- an interval variablevar2- an interval variabledelay- a value- Returns:
- a constraint that enforces
var1.end <= var2.start + delay
-
endBeforeEnd
Creates a constraint that enforces that the end of var1 is lower or equal to the end of var2- Parameters:
var1- an interval variablevar2- an interval variable- Returns:
- a constraint that enforces
var1.end <= var2.end
-
endBeforeEnd
Creates a constraint that enforces that the end of var1 is lower or equal to the end of var2 + delay- Parameters:
var1- an interval variablevar2- an interval variabledelay- a value- Returns:
- a constraint that enforces
var1.end <= var2.end
-
isEndBeforeStart
Returns a boolean variable representing whether the interval variable var1 ends at or before the start of the interval variable var2. This relation is enforced by theIsEndBeforeStartconstraint posted by calling this method.- Parameters:
var1- An interval variablevar2- An interval variable- Returns:
- a boolean variable which is a reification of the constraint
var1.end <= var2.start
-
isEndBeforeEnd
Returns a boolean variable representing whether the interval variable var1 ends at or before the end of the interval variable var2. This relation is enforced by theIsEndBeforeEndconstraint posted by calling this method.- Parameters:
var1- An interval variablevar2- An interval variable- Returns:
- a boolean variable which is a reification of the constraint
var1.end <= var2.end
-
length
Returns a CPIntVar that is equal to the length of interval.- Parameters:
var- the interval variable, it must be present at the time of the posting- Returns:
- a CPIntVar that is equal to the length of interval
-
lengthOr
Returns a CPIntVar that is equal to the length of interval if it is present, or equal to val if interval is absent- Parameters:
interval- the interval variableval- the value taken by the returned variable if interval is absent- Returns:
- a CPIntVar that is equal to the length of interval if it is present, or equal to val if interval is absent
-
makespan
Returns a CPIntVar that is equal to the makespan (the latest end) of the intervals.- Parameters:
vars- the interval vars- Returns:
- a CPIntVar that is equal to the makespan of the intervals
-
noOverlap
Creates a constraint that enforces that there is no overlap between the intervals in vars.- Parameters:
vars- one or more interval variables- Returns:
- a noOverlap constraint on the elements of vars.
-
nonOverlapSequence
Creates and post a non-overlap constraint on the intervals in vars and create a sequence variable linked with these intervals representing the order of the intervals in time. The id of an interval is its index in the array vars. The intervals cannot overlap.- Parameters:
intervals- intervals that must be linked with a sequence variable- Returns:
- sequence variable linked with the intervals
-
alternative
public static CPConstraint alternative(CPIntervalVar interval, CPIntervalVar[] alternatives, CPIntVar cardinality) Returns an Alternative constraint: Enforces that if the interval variable interval is present, then cardinality intervals from the array alternatives must be present and synchronized with a. If a is not present, then all the intervals of alternatives must be absent.- Parameters:
interval- an interval variablealternatives- an array of interval variablescardinality- the cardinality- Returns:
- an
Alternativeconstraint
-
alternative
public static CPConstraint alternative(CPIntervalVar interval, CPIntervalVar[] alternatives, int cardinality) Returns an Alternative constraint: Enforces that if the interval variable interval is present, then cardinality intervals from the array alternatives must be present and synchronized with interval. If a is not present, then all the intervals of alternatives must be absent.- Parameters:
interval- an interval variablealternatives- an array of interval variablescardinality- the cardinality- Returns:
- an
Alternativeconstraint
-
alternative
Returns an Alternative constraint: Enforces that if the interval variable interval is present, then one of the intervals from the array alternatives must be present and synchronized with a. If a is not present, then all the intervals of alternatives must be absent.- Parameters:
interval- an interval variablealternatives- an array of interval variables- Returns:
- an
Alternativeconstraint
-
flat
Creates an elementary flat Cumulative Function.- Returns:
- a cumulative function that is flat
-
pulse
Creates an elementary Cumulative Function that is a pulse of height h that happen when the Interval variable var is present.- Parameters:
var- an interval variableh- an int value- Returns:
- a cumulative function that is a pulse of height h when var is present
-
pulse
Creates an elementary Cumulative Function that is a pulse that happen when the Interval variable var is present. Its height is set in the interval[hMin, hMax].- Parameters:
var- an interval variablehMin- an int valuehMax- an int value- Returns:
- a cumulative function that is a pulse of height
[hMin, hMax]when var is present
-
stepAtStart
Creates an elementary Cumulative Function that is a step of height h that happen at the start of the Interval variable var if it is present.- Parameters:
var- an interval variableh- an int value- Returns:
- a cumulative function that is a step of height h at the start of var if it is present
-
stepAtStart
Creates an elementary Cumulative Function that is a step that happen at the start of the Interval variable var if it is present. Its height is set in the interval [hMin, hMax].- Parameters:
var- an interval variablehMin- an int valuehMax- an int value- Returns:
- a cumulative function that is a step of height [hMin, hMax] at the start of var if it is present
-
stepAtEnd
Creates an elementary Cumulative Function that is a step of height h that happen at the end of the Interval variable var if it is present.- Parameters:
var- an interval variableh- an int value- Returns:
- a cumulative function that is a step of height h at the end of var if it is present
-
stepAtEnd
Creates an elementary Cumulative Function that is a step that happen at the end of the Interval variable var if it is present. Its height is set in the interval [hMin, hMax].- Parameters:
var- an interval variablehMin- an int valuehMax- an int value- Returns:
- a cumulative function that is a step of height [hMin, hMax] at the end of var if it is present
-
step
Creates an elementary Cumulative Function that is a step of height h that happen at time from.- Parameters:
from- an int valueh- an int value- Returns:
- a cumulative function that is a step of height h at time from
-
pulse
Creates an elementary Cumulative Function that is a pulse of height h that happen at time from.- Parameters:
from- an int valueh- an int value- Returns:
- a cumulative function that is a step of height h at time from
-
plus
Creates a cumulative Function that is the sum of two cumulative Functions.- Parameters:
fun1- a cumulative Functionfun2- a cumulative Function- Returns:
- a cumulative function that is the sum of fun1 and fun2
-
minus
Creates a cumulative Function that is the difference of two cumulative Functions.- Parameters:
fun1- a cumulative Functionfun2- a cumulative Function- Returns:
- a cumulative function that is the difference of fun1 and fun2
-
sum
Creates a cumulative Function that is the sum of zero or more cumulative Functions.- Parameters:
fun- a cumulative Function- Returns:
- a cumulative function that is the sum of the cumulative Functions in fun
-
alwaysIn
public static CPConstraint alwaysIn(CPCumulFunction fun, int minValue, int maxValue, Constants.CumulativeAlgo algo) Requires a cumulative function to always be within the range [minValue..maxValue] on the execution range of the cumulative function.- Parameters:
fun- a cumulative functionminValue- an int valuemaxValue- an int valuealgo- a cumulative algorithm- Returns:
- a constraint which enforces the cumulative function fun to stay within the range [minValue..maxValue]
-
alwaysIn
Requires a cumulative function to always be within the range [minValue..maxValue] on the execution range of the cumulative function.- Parameters:
fun- a cumulative functionminValue- an int valuemaxValue- an int value- Returns:
- a constraint which enforces the cumulative function fun to stay within the range [minValue..maxValue]
-
alwaysIn
public static CPConstraint alwaysIn(CPCumulFunction fun, int minValue, int maxValue, int from, int to, Constants.CumulativeAlgo algo) Requires a cumulative function to always be within the range [minValue..maxValue] on the execution range [from..to).- Parameters:
fun- a cumulative functionminValue- an int valuemaxValue- an int valuefrom- an int valueto- an int value- Returns:
- a constraint which enforces the cumulative function fun to stay within the range [minValue..maxValue]
-
alwaysIn
public static CPConstraint alwaysIn(CPCumulFunction fun, int minValue, int maxValue, int from, int to) Requires a cumulative function to always be within the range [minValue..maxValue] on the execution range [from..to).- Parameters:
fun- a cumulative functionminValue- an int valuemaxValue- an int valuefrom- an int valueto- an int value- Returns:
- a constraint which enforces the cumulative function fun to stay within the range [minValue..maxValue]
-
le
Requires a cumulative function to always be equal or lesser than a value on the execution range [0..Constants.HORIZON).- Parameters:
fun- a cumulative functionmaxValue- an int valuealgo- a cumulative algorithm- Returns:
- a constraint which ensures that fun is always lesser or equal to maxVal
-
le
Requires a cumulative function to always be equal or lesser than a value on the execution range [0..Constants.HORIZON).- Parameters:
fun- a cumulative functionmaxValue- an int value- Returns:
- a constraint which ensures that fun is always lesser or equal to maxVal
-