java.lang.Object
org.maxicp.modeling.Factory
Modeling factory providing static helper methods to create model dispatchers, objectives,
symbolic integer/boolean/cumulative expressions, and high-level modeling constraints.
-
Method Summary
Modifier and TypeMethodDescriptionstatic IntExpressionabs(IntExpression x) Returns an integer expression representing the absolute value|x|.static ConstraintallDifferent(IntExpression... x) Creates anAllDifferentconstraint ensuring that all expressions inxtake pairwise distinct values.static Constraintalternative(IntervalVar real, IntExpression n, IntervalVar... alternatives) static Constraintalternative(IntervalVar real, IntervalVar... alternatives) static ConstraintalwaysIn(CumulFunction expression, int heightMin, int heightMax) static Constraintamong(IntExpression[] x, Set<Integer> values, IntExpression count) static BoolExpressionand(BoolExpression... t) Returns the logical conjunction (AND) of the given boolean expressions.static ConstraintbinPacking(IntExpression[] x, int[] weights, IntExpression[] loads) static ConstraintcardinalityMax(IntExpression[] x, int[] maxCard) Creates aCardinalityMaxconstraint ensuring that each valuevappears at mostmaxCard[v]times inx.static ConstraintcardinalityMin(IntExpression[] x, int[] minCard) Creates aCardinalityMinconstraint ensuring that each valuevappears at leastminCard[v]times inx.static Constraintcircuit(IntExpression... x) Creates aCircuitconstraint ensuring that the successor arrayxforms a single Hamiltonian circuit.static IntExpressioncst(ModelProxy modelProxy, int v) Creates a constant integer expression with valuev.static Constraintcumulative(IntExpression[] start, int[] duration, int[] demand, int capa) Creates aCumulativescheduling constraint with constant durations, demands, and capacity.static Constraintcumulative(IntExpression[] start, IntExpression[] duration, IntExpression[] end, IntExpression[] demand, IntExpression capa) Creates aCumulativescheduling constraint with variable durations, ends, demands, and capacity.static Constraintcumulative(SeqVar seqVar, int[] starts, int[] ends, int[] load, int capacity) Creates aCumulativeconstraint on a sequence variable.static Constraintdisjunctive(IntExpression[] start, int[] duration) Creates aDisjunctivescheduling constraint with constant activity durations.static Constraintdisjunctive(IntExpression[] start, IntExpression[] duration) Creates aDisjunctivescheduling constraint with variable activity durations.static Constraintdistance(SeqVar seqVar, int[][] distanceMatrix, IntExpression distance) Creates aDistanceconstraint on a sequence variable maintaining the total travel distance.static IntExpressiondiv(IntExpression a, int b) Returns an integer expression representing the integer divisiona / b.static IntExpressiondiv(IntExpression x, IntExpression y) Returns an integer expression representing the integer divisionx / y.static IntExpressionend(IntervalVar interval) static BoolExpressionendAfter(IntervalVar intervalVar, int value) static BoolExpressionendAfter(IntervalVar intervalVar, IntExpression value) static BoolExpressionendBefore(IntervalVar intervalVar, IntExpression value) static BoolExpressionReturns a boolean expression representing whether intervalaends at or before the start ofb.static IntExpressionendOr(IntervalVar interval, int v) static BoolExpressioneq(int a, IntExpression b) Returns a boolean expression representinga == b.static BoolExpressioneq(IntExpression a, int b) Returns a boolean expression representinga == b.static BoolExpressioneq(IntExpression a, IntExpression b) Returns a boolean expression representinga == b.static Constraintstatic CumulFunctionflat()static BoolExpressionge(int a, IntExpression b) Returns a boolean expression representinga >= b.static BoolExpressionge(IntExpression a, int b) Returns a boolean expression representinga >= b.static BoolExpressionge(IntExpression a, IntExpression b) Returns a boolean expression representinga >= b.static IntExpressionget(int[][] T, IntExpression x, IntExpression y) Returns an integer expression representingT[x][y].static IntExpressionget(int[] T, IntExpression y) Returns an integer expression representingT[y].static IntExpressionget(IntExpression[][] T, IntExpression x, IntExpression y) Returns an integer expression representingT[x][y].static IntExpressionget(IntExpression[] T, IntExpression y) Returns an integer expression representingT[y].static BoolExpressiongt(int a, IntExpression b) Returns a boolean expression representinga > b.static BoolExpressiongt(IntExpression a, int b) Returns a boolean expression representinga > b.static BoolExpressiongt(IntExpression a, IntExpression b) Returns a boolean expression representinga > b.static BoolExpressionReturns the logical implication of a and bstatic Constraintstatic BoolExpressionle(int a, IntExpression b) Returns a boolean expression representinga <= b.static BoolExpressionle(IntExpression a, int b) Returns a boolean expression representinga <= b.static BoolExpressionle(IntExpression a, IntExpression b) Returns a boolean expression representinga <= b.static Constraintle(CumulFunction function, int limit) static IntExpressionlength(IntervalVar interval) static Constraintlength(IntervalVar var, int length) static IntExpressionlengthOr(IntervalVar interval, int v) static ConstraintlexLe(IntExpression[] x, IntExpression[] y) Creates a non-strict lexicographic ordering constraintx <=_lex y.static ConstraintlexLt(IntExpression[] x, IntExpression[] y) Creates a strict lexicographic ordering constraintx <_lex y.static BoolExpressionlt(int a, IntExpression b) Returns a boolean expression representinga < b.static BoolExpressionlt(IntExpression a, int b) Returns a boolean expression representinga < b.static BoolExpressionlt(IntExpression a, IntExpression b) Returns a boolean expression representinga < b.static ModelDispatcherCreates a newModelDispatcherto build and solve constraint programming models.static IntExpressionmax(IntExpression... x) Returns an integer expression representing the maximum of the given expressions.static ObjectiveCreates a maximization objective for the given integer expression.static Objectivemaximize(IntExpression x, boolean shared) Creates a maximization objective for the given integer expression.static IntExpressionmin(IntExpression... x) Returns an integer expression representing the minimum of the given expressions.static ObjectiveCreates a minimization objective for the given integer expression.static Objectiveminimize(IntExpression x, boolean shared) Creates a minimization objective for the given integer expression.static IntExpressionReturns an integer expression representing the unary negation-a.static IntExpressionminus(IntExpression a, int v) Returns an integer expression representinga - v.static IntExpressionminus(IntExpression a, IntExpression b) Returns an integer expression representinga - b.static CumulFunctionminus(CumulFunction left, CumulFunction right) static IntExpressionmul(int b, IntExpression a) Returns an integer expression representingb * a.static IntExpressionmul(IntExpression... x) Returns an integer expression representing the product of the given expressions.static IntExpressionmul(IntExpression a, int b) Returns an integer expression representinga * b.static IntExpressionmul(IntExpression x, BoolExpression b) Returns an integer expression representingx * bwherebis a boolean expression.static ConstraintnegTable(IntExpression[] x, int[][] array, Optional<Integer> starred) Creates a negativeNegTableconstraint ensuring that the tuple assigned toxdoes not match any tuple inarray.static BoolExpressionneq(int a, IntExpression b) Returns a boolean expression representinga != b.static BoolExpressionneq(IntExpression a, int b) Returns a boolean expression representinga != b.static BoolExpressionneq(IntExpression a, IntExpression b) Returns a boolean expression representinga != b.static ConstraintnoOverlap(IntervalVar... intervals) Creates aNoOverlapconstraint ensuring that the given interval variables do not overlap in time.static ConstraintnoOverlap(IntervalVar[] intervals, IntExpression[] posOfInterval, IntExpression[] intervalInPos) Creates a noOverlap constraint with position variables and zero transition times.static ConstraintnoOverlap(IntervalVar[] intervals, IntExpression[] posOfInterval, IntExpression[] intervalInPos, int[][] minTransition) Creates a noOverlap constraint with position variables and minimum transition times.static BoolExpressionReturns the logical negation!a.static ConstraintnotBetween(SeqVar seqVar, int pred, int node, int succ) Creates aNotBetweenconstraint forbiddingnodefrom being placed immediately betweenpredandsuccinseqVar.static BoolExpressionor(BoolExpression... t) Returns the logical disjunction (OR) of the given boolean expressions.static IntExpressionplus(IntExpression a, int v) Returns an integer expression representinga + v.static IntExpressionplus(IntExpression a, IntExpression b) Returns an integer expression representinga + b.static BoolExpressionpresent(IntervalVar var) static CumulFunctionpulse(IntervalVar interval, int height) static CumulFunctionpulse(IntervalVar interval, int hMin, int hMax) static CumulFunctionpulse(IntervalVar interval, IntExpression height) static Constraintstatic IntExpressionstart(IntervalVar interval) static Constraintstart(IntervalVar var, int start) static BoolExpressionstartAfter(IntervalVar intervalVar, int value) static BoolExpressionstartAfter(IntervalVar intervalVar, IntExpression value) static BoolExpressionstartBefore(IntervalVar intervalVar, int value) static BoolExpressionstartBefore(IntervalVar intervalVar, IntExpression value) static IntExpressionstartOr(IntervalVar interval, int v) static CumulFunctionstep(ModelDispatcher m, int from, int h) static CumulFunctionstepAtEnd(IntervalVar interval, int height) static CumulFunctionstepAtEnd(IntervalVar interval, int hMin, int hMax) static CumulFunctionstepAtStart(IntervalVar interval, int height) static CumulFunctionstepAtStart(IntervalVar interval, int hMin, int hMax) static ConstraintsubCircuit(IntExpression... x) Creates aSubCircuitconstraint ensuring that the successor arrayxforms at most one circuit.static IntExpressionsum(IntExpression... x) Returns an integer expression representing the sum of the given expressions.static CumulFunctionsum(CumulFunction... functions) static Constrainttable(IntExpression[] x, int[][] array, Optional<Integer> starred) static ConstrainttransitionTimes(SeqVar seqVar, IntExpression[] time, int[][] dist) Creates aTransitionTimesconstraint linking visit times with transition distances inseqVar.static ConstrainttransitionTimes(SeqVar seqVar, IntExpression[] time, int[][] dist, int[] serviceTime) Creates aTransitionTimesconstraint linking visit times with transition distances and service durations inseqVar.
-
Method Details
-
makeModelDispatcher
Creates a newModelDispatcherto build and solve constraint programming models.- Returns:
- a new
ModelDispatcherinstance
-
minimize
Creates a minimization objective for the given integer expression.- Parameters:
x- the expression to minimizeshared-trueif the objective bound should be shared across parallel searches- Returns:
- the minimization
Objective
-
minimize
Creates a minimization objective for the given integer expression.- Parameters:
x- the expression to minimize- Returns:
- the minimization
Objective
-
maximize
Creates a maximization objective for the given integer expression.- Parameters:
x- the expression to maximizeshared-trueif the objective bound should be shared across parallel searches- Returns:
- the maximization
Objective
-
maximize
Creates a maximization objective for the given integer expression.- Parameters:
x- the expression to maximize- Returns:
- the maximization
Objective
-
cst
Creates a constant integer expression with valuev.- Parameters:
modelProxy- the model proxyv- the constant integer value- Returns:
- a constant
IntExpressionequal tov
-
plus
Returns an integer expression representinga + v.- Parameters:
a- an integer expressionv- a constant offset- Returns:
- the expression
a + v
-
plus
Returns an integer expression representinga + b.- Parameters:
a- the first integer expressionb- the second integer expression- Returns:
- the expression
a + b
-
minus
Returns an integer expression representinga - v.- Parameters:
a- an integer expressionv- a constant offset to subtract- Returns:
- the expression
a - v
-
minus
Returns an integer expression representinga - b.- Parameters:
a- the first integer expressionb- the second integer expression- Returns:
- the expression
a - b
-
minus
Returns an integer expression representing the unary negation-a.- Parameters:
a- an integer expression- Returns:
- the expression
-a
-
mul
Returns an integer expression representinga * b.- Parameters:
a- an integer expressionb- a constant multiplier- Returns:
- the expression
a * b
-
div
Returns an integer expression representing the integer divisiona / b.- Parameters:
a- the dividend expressionb- the constant divisor- Returns:
- the expression
a / b
-
mul
Returns an integer expression representingb * a.- Parameters:
b- a constant multipliera- an integer expression- Returns:
- the expression
b * a
-
mul
Returns an integer expression representingx * bwherebis a boolean expression.- Parameters:
x- an integer expressionb- a boolean expression (0 or 1)- Returns:
- the expression
x * b
-
mul
Returns an integer expression representing the product of the given expressions.- Parameters:
x- the integer expressions to multiply- Returns:
- the product expression
x[0] * x[1] * ... * x[n-1]
-
abs
Returns an integer expression representing the absolute value|x|.- Parameters:
x- an integer expression- Returns:
- the expression
|x|
-
div
Returns an integer expression representing the integer divisionx / y.- Parameters:
x- the dividend expressiony- the divisor expression- Returns:
- the expression
x / y
-
sum
Returns an integer expression representing the sum of the given expressions.- Parameters:
x- the integer expressions to sum- Returns:
- the sum expression
x[0] + x[1] + ... + x[n-1]
-
max
Returns an integer expression representing the maximum of the given expressions.- Parameters:
x- the integer expressions- Returns:
- the maximum expression
max(x)
-
min
Returns an integer expression representing the minimum of the given expressions.- Parameters:
x- the integer expressions- Returns:
- the minimum expression
min(x)
-
eq
Returns a boolean expression representinga == b.- Parameters:
a- an integer expressionb- a constant value- Returns:
- a boolean expression true iff
a == b
-
eq
Returns a boolean expression representinga == b.- Parameters:
a- a constant valueb- an integer expression- Returns:
- a boolean expression true iff
a == b
-
eq
Returns a boolean expression representinga == b.- Parameters:
a- the first integer expressionb- the second integer expression- Returns:
- a boolean expression true iff
a == b
-
neq
Returns a boolean expression representinga != b.- Parameters:
a- an integer expressionb- a constant value- Returns:
- a boolean expression true iff
a != b
-
neq
Returns a boolean expression representinga != b.- Parameters:
a- a constant valueb- an integer expression- Returns:
- a boolean expression true iff
a != b
-
neq
Returns a boolean expression representinga != b.- Parameters:
a- the first integer expressionb- the second integer expression- Returns:
- a boolean expression true iff
a != b
-
le
Returns a boolean expression representinga <= b.- Parameters:
a- an integer expressionb- a constant value- Returns:
- a boolean expression true iff
a <= b
-
le
Returns a boolean expression representinga <= b.- Parameters:
a- a constant valueb- an integer expression- Returns:
- a boolean expression true iff
a <= b
-
le
Returns a boolean expression representinga <= b.- Parameters:
a- the first integer expressionb- the second integer expression- Returns:
- a boolean expression true iff
a <= b
-
lt
Returns a boolean expression representinga < b.- Parameters:
a- a constant valueb- an integer expression- Returns:
- a boolean expression true iff
a < b
-
lt
Returns a boolean expression representinga < b.- Parameters:
a- an integer expressionb- a constant value- Returns:
- a boolean expression true iff
a < b
-
lt
Returns a boolean expression representinga < b.- Parameters:
a- the first integer expressionb- the second integer expression- Returns:
- a boolean expression true iff
a < b
-
ge
Returns a boolean expression representinga >= b.- Parameters:
a- an integer expressionb- a constant value- Returns:
- a boolean expression true iff
a >= b
-
ge
Returns a boolean expression representinga >= b.- Parameters:
a- a constant valueb- an integer expression- Returns:
- a boolean expression true iff
a >= b
-
ge
Returns a boolean expression representinga >= b.- Parameters:
a- the first integer expressionb- the second integer expression- Returns:
- a boolean expression true iff
a >= b
-
gt
Returns a boolean expression representinga > b.- Parameters:
a- an integer expressionb- a constant value- Returns:
- a boolean expression true iff
a > b
-
gt
Returns a boolean expression representinga > b.- Parameters:
a- a constant valueb- an integer expression- Returns:
- a boolean expression true iff
a > b
-
gt
Returns a boolean expression representinga > b.- Parameters:
a- the first integer expressionb- the second integer expression- Returns:
- a boolean expression true iff
a > b
-
not
Returns the logical negation!a.- Parameters:
a- a boolean expression- Returns:
- the negated boolean expression
!a
-
and
Returns the logical conjunction (AND) of the given boolean expressions.- Parameters:
t- the boolean expressions- Returns:
- a boolean expression true iff all expressions in
tare true
-
or
Returns the logical disjunction (OR) of the given boolean expressions.- Parameters:
t- the boolean expressions- Returns:
- a boolean expression true iff at least one expression in
tis true
-
implies
Returns the logical implication of a and b- Parameters:
a- a boolean expressionb- a boolean expression- Returns:
a => b
-
endBeforeStart
Returns a boolean expression representing whether intervalaends at or before the start ofb.- Parameters:
a- the first interval variableb- the second interval variable- Returns:
- a boolean expression true iff
end(a) <= start(b)when both are present
-
get
Returns an integer expression representingT[y].- Parameters:
T- the array of constant valuesy- the index expression- Returns:
- the element expression
T[y]
-
get
Returns an integer expression representingT[y].- Parameters:
T- the array of integer expressionsy- the index expression- Returns:
- the element expression
T[y]
-
get
Returns an integer expression representingT[x][y].- Parameters:
T- the 2D matrix of constant valuesx- the row index expressiony- the column index expression- Returns:
- the element expression
T[x][y]
-
get
Returns an integer expression representingT[x][y].- Parameters:
T- the 2D matrix of integer expressionsx- the row index expressiony- the column index expression- Returns:
- the element expression
T[x][y]
-
lexLe
Creates a non-strict lexicographic ordering constraintx <=_lex y.- Parameters:
x- the first array of integer expressionsy- the second array of integer expressions- Returns:
- a
LexLeconstraint enforcingx <=_lex y
-
lexLt
Creates a strict lexicographic ordering constraintx <_lex y.- Parameters:
x- the first array of integer expressionsy- the second array of integer expressions- Returns:
- a
LexLeconstraint enforcingx <_lex y
-
among
- Parameters:
x- the array of integer expressionsvalues- the set of target valuescount- the expression counting how many elements ofxbelong tovalues- Returns:
- an
Amongconstraint
-
subCircuit
Creates aSubCircuitconstraint ensuring that the successor arrayxforms at most one circuit.- Parameters:
x- the array of successor expressions- Returns:
- a
SubCircuitconstraint
-
cardinalityMin
Creates aCardinalityMinconstraint ensuring that each valuevappears at leastminCard[v]times inx.- Parameters:
x- the array of integer expressionsminCard- the minimum number of occurrences for each value0..minCard.length - 1- Returns:
- a
CardinalityMinconstraint
-
cardinalityMax
Creates aCardinalityMaxconstraint ensuring that each valuevappears at mostmaxCard[v]times inx.- Parameters:
x- the array of integer expressionsmaxCard- the maximum number of occurrences for each value0..maxCard.length - 1- Returns:
- a
CardinalityMaxconstraint
-
allDifferent
Creates anAllDifferentconstraint ensuring that all expressions inxtake pairwise distinct values.- Parameters:
x- the integer expressions that must be pairwise distinct- Returns:
- an
AllDifferentconstraint
-
binPacking
- Parameters:
x- the bin assignment expression for each itemweights- the weight of each itemloads- the total load expression for each bin- Returns:
- a
BinPackingconstraint
-
circuit
Creates aCircuitconstraint ensuring that the successor arrayxforms a single Hamiltonian circuit.- Parameters:
x- the array of successor expressions- Returns:
- a
Circuitconstraint
-
table
- Parameters:
x- the array of integer expressionsarray- the table of allowed tuplesstarred- optional wildcard value representing any value in a tuple- Returns:
- a
Tableconstraint
-
negTable
Creates a negativeNegTableconstraint ensuring that the tuple assigned toxdoes not match any tuple inarray.- Parameters:
x- the array of integer expressionsarray- the table of forbidden tuplesstarred- optional wildcard value representing any value in a tuple- Returns:
- a
NegTableconstraint
-
cumulative
Creates aCumulativescheduling constraint with constant durations, demands, and capacity.- Parameters:
start- the start time expressions of the activitiesduration- the durations of the activitiesdemand- the resource demands of the activitiescapa- the resource capacity- Returns:
- a
Cumulativeconstraint
-
cumulative
public static Constraint cumulative(IntExpression[] start, IntExpression[] duration, IntExpression[] end, IntExpression[] demand, IntExpression capa) Creates aCumulativescheduling constraint with variable durations, ends, demands, and capacity.- Parameters:
start- the start time expressions of the activitiesduration- the duration expressions of the activitiesend- the end time expressions of the activitiesdemand- the resource demand expressions of the activitiescapa- the resource capacity expression- Returns:
- a
Cumulativeconstraint
-
disjunctive
Creates aDisjunctivescheduling constraint with constant activity durations.- Parameters:
start- the start time expressions of the activitiesduration- the durations of the activities- Returns:
- a
Disjunctiveconstraint
-
disjunctive
Creates aDisjunctivescheduling constraint with variable activity durations.- Parameters:
start- the start time expressions of the activitiesduration- the duration expressions of the activities- Returns:
- a
Disjunctiveconstraint
-
distance
Creates aDistanceconstraint on a sequence variable maintaining the total travel distance.- Parameters:
seqVar- the sequence variabledistanceMatrix- the distance matrix between nodesdistance- the total distance expression- Returns:
- a
Distanceconstraint
-
require
- Parameters:
seqVar- the sequence variablenode- the node to require- Returns:
- a
Requireconstraint
-
insert
- Parameters:
seqVar- the sequence variableprev- the predecessor nodenode- the node to insert- Returns:
- an
Insertconstraint
-
exclude
- Parameters:
seqVar- the sequence variablenode- the node to exclude- Returns:
- an
Excludeconstraint
-
notBetween
Creates aNotBetweenconstraint forbiddingnodefrom being placed immediately betweenpredandsuccinseqVar.- Parameters:
seqVar- the sequence variablepred- the predecessor nodenode- the node whose insertion is forbiddensucc- the successor node- Returns:
- a
NotBetweenconstraint
-
transitionTimes
Creates aTransitionTimesconstraint linking visit times with transition distances inseqVar.- Parameters:
seqVar- the sequence variabletime- the visit time expression for each nodedist- the transition distance matrix between nodes- Returns:
- a
TransitionTimesconstraint
-
transitionTimes
public static Constraint transitionTimes(SeqVar seqVar, IntExpression[] time, int[][] dist, int[] serviceTime) Creates aTransitionTimesconstraint linking visit times with transition distances and service durations inseqVar.- Parameters:
seqVar- the sequence variabletime- the visit time expression for each nodedist- the transition distance matrix between nodesserviceTime- the service duration at each node- Returns:
- a
TransitionTimesconstraint
-
cumulative
public static Constraint cumulative(SeqVar seqVar, int[] starts, int[] ends, int[] load, int capacity) Creates aCumulativeconstraint on a sequence variable.- Parameters:
seqVar- the sequence variablestarts- the start nodes of the activitiesends- the end nodes of the activitiesload- the load of each activitycapacity- the maximum resource capacity along the sequence- Returns:
- a sequence
Cumulativeconstraint
-
noOverlap
Creates aNoOverlapconstraint ensuring that the given interval variables do not overlap in time.- Parameters:
intervals- the interval variables- Returns:
- a
NoOverlapconstraint
-
noOverlap
public static Constraint noOverlap(IntervalVar[] intervals, IntExpression[] posOfInterval, IntExpression[] intervalInPos) Creates a noOverlap constraint with position variables and zero transition times.- Parameters:
intervals- the interval variablesposOfInterval- position of each intervalintervalInPos- interval at each position- Returns:
- a NoOverlapWithPosition constraint
-
noOverlap
public static Constraint noOverlap(IntervalVar[] intervals, IntExpression[] posOfInterval, IntExpression[] intervalInPos, int[][] minTransition) Creates a noOverlap constraint with position variables and minimum transition times.- Parameters:
intervals- the interval variablesposOfInterval- position of each intervalintervalInPos- interval at each positionminTransition- n×n transition time matrix- Returns:
- a NoOverlapWithPosition constraint with transition times
-
alternative
-
alternative
public static Constraint alternative(IntervalVar real, IntExpression n, IntervalVar... alternatives) -
length
-
present
-
start
-
startOr
-
start
-
endOr
-
end
-
length
-
lengthOr
-
endBefore
-
endAfter
-
endAfter
-
startBefore
-
startBefore
-
startAfter
-
startAfter
-
flat
-
pulse
-
pulse
-
pulse
-
sum
-
minus
-
stepAtEnd
-
stepAtEnd
-
step
-
stepAtStart
-
stepAtStart
-
le
-
alwaysIn
-