A.5 Global constraints

x1 + x2 + ⋅⋅⋅ + xn = sum

IntVar[] x = {x1, x2, …, xn};
IntVar sum = new IntVar(…)
Sum(x, sum);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
IntVar sum = new IntVar(…)
Sum(x, sum);

w1 x1 + w2 x2 + ⋅⋅⋅ + wn xn = sum

IntVar[] x = {x1, x2, …, xn};
IntVar sum = new IntVar(…)
int[] w = {w1, w2, …, wn};
SumWeight(x, w, sum);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
IntVar sum = new IntVar(…)
ArrayList w=new ArrayList();
w.add(w1); w.add(w1); …w.add(wn);
SumWeight(x, w, sum);

alldifferent([x1,x2,,xn])

IntVar[] x = {x1, x2, …, xn};
Alldifferent(x);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
Alldifferent(x);

alldiff([x1,x2,,xn])

IntVar[] x = {x1, x2, …, xn};
Alldiff(x);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
Alldiff(x);

alldistinct([x1,x2,,xn])

IntVar[] x = {x1, x2, …, xn};
Alldistinct(x);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
Alldistinct(x);

among([x1,x2,,xn],val,count)

IntVar[] x = {x1, x2, …, xn};
IntervalDomain val = new IntervalDomain(k,l);
IntVar count = new IntVar(…);
Among(x, val, count);

amongVar([x1,x2,,xn],[y1,y2,,ym],count)

IntVar[] x = {x1, x2, …, xn};
IntVar[] y = {y1, y2, …, ym};
IntVar count = new IntVar(…);
Among(x, y, count);

assignment([x1,x2,,xn],[y1,y2,,yn])

IntVar[] x = {x1, x2, …, xn};
IntVar[] y = {y1, y2, …, yn};
Assignment(x, y);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
ArrayList y = new ArrayList();
y.add(y1); y.add(y2); …y.add(yn);
Assignment(x, y);

circuit([x1,x2,,xn])

IntVar[] x = {x1, x2, …, xn};
Circuit(Store, x);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
Circuit(Store, x);

count(value,[x1,x2,,xn],var)

int value = …;
IntVar var = new IntVar(…);
IntVar[] x = {x1, x2, …, xn};
Count(x, var, value);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
Count(x, var, value);

cumulative([t1,t2,,tn],[d1,d2,,dn],[r1,r2,,rn],ResourceLimit)

IntVar[] t ={t1, t2, …, tn};
IntVar[] d ={d1, d2, …, dn};
IntVar[] r = {r1, r2, …, rn};
IntVar Limit = new IntVar(…);
Cumulative(t, d, r, Limit);2
or using ArrayList

diff2([[x1,y1,dx1,dy1],,[xn,yn,dxn,dyn]])

IntVar[][] r = {{x1,y1,dx1,dy1}, …,
{xn,yn,dxn,dyn}};
Diff(r); or Diff2(Store, r);1
or using ArrayList>

or

diff2([x1,,xn],[y1,,yn],[dx1,,dxn],[dy1,,dyn])

IntVar[] x = {x1, …, xn};
IntVar[] y = {y1, …, yn};
IntVar[] dx = {dx1, …, dxn};
IntVar[] dy = {dy1, …, dyn};
Diff(x, y, dx, dy); or Diff2(Store, x, y, dx, dy);1
or using ArrayList

distance(x,y,dist)

IntVar x, y, dist;
Distance(x, y, dist);

element(Index,[n1,n2,,nn],V alue)

IntVar Index, Value;
int[] i = {n1, n2, …, nn };
Element(Index, i, Value);

element(Index,[x1,x2,,xn],V alue)

IntVar Index, Value;
IntVar[] x = {x1, x2, …, xn };
Element(Index, x, Value);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
Element(Index, x, Value);

extensionalSupport([x1,x2,,xn],{{1,2,,n},{},,{}})
extensionalConflict([x1,x2,,xn],{{1,2,,n},{},,{}})

IntVar[] x = {x1, x2, …, xn};
int[][] intTuple = {{…}, …});
ExtensinalSupportVA(x,intTuple);
or
ExtensinalConflictVA(x,intTuple);
or
ExtensinalSupportSTR(x,intTuple);
or
ExtensinalSupportMDD(x,intTuple);

gcc([x1,x2,,xn],[y1,y2,,ym])

IntVar[] x = {x1, x2, …, xn};
IntVar[] y = {y1, y2, …, ym};
GCC(x, y);

min([x1,x2,,xn],Xmin)

IntVar[] x = {x1, x2, …, xn};
Min(x, Xmin);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
Min(x, Xmin);

max([x1,x2,,xn],Xmax)

IntVar[] x = {x1, x2, …, xn};
Max(x, Xmax);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
Max(x, Xmax);

arg_min([x1,x2,,xn],indexMin)

IntVar[] x = {x1, x2, …, xn};
ArgMin(x, indexMin);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
ArgMin(x, indexMin);

arg_max([x1,x2,,xn],indexMax)

IntVar[] x = {x1, x2, …, xn};
Max(x, indexMax);
or
ArrayList x = new ArrayList();
x.add(x1); x.add(x2); …x.add(xn);
Max(x, indexMax);

knapsack(profits,weights,quantity,knapsackCapacity,knapsackProfit)

int[] profits = {p1, p2, …, pn};
int[] weights = {w1, w2, …, wn};
IntVar[] quantity = {q1, q2, …, qn};
IntVar knapsackCapacity = new IntVar(…);
IntVar knapsackProfit = new IntVar(…);
Knapsack(profits, weights, quantity, knapsackCapacity, knapsackProfit);

geost(objects,constraints,shapes)

IntVar xOrigin = new IntVar(store, "x1", 0, 20);
IntVar yOrigin = new IntVar(store, "y1", 0, 5);
IntVar shapeNo = new IntVar(store, "s1", 1, 1);
IntVar startGeost = new IntVar(store, "start"+1, 0, 0);
IntVar durationGeost = new IntVar(store, "duration"+1, 1, 1);
IntVar endGeost = new IntVar(store, "end"+1, 1, 1);
IntVar[] coords = {xOrigin, yOrigin};
int objectId = 1;
GeostObject o = new GeostObject(objectId, coords, shapeNo, startGeost, durationGeost, endGeost);
ArrayList objects = new ArrayList();
objects.add(o);
int[] origin = {0, 0};
int[] length = {10, 2};
Shape shape = new Shape(j, new DBox(origin, length));
ArrayList shapes = new ArrayList();
shapes.add(shape);
int[] dimensions = {0, 1};
NonOverlapping constraint = new NonOverlapping(objects, dimensions);
ArrayList constraints = new ArrayList();
constraints.add(constraint);
store.impose(new Geost(objects, constraints, shapes));

regular(fsm,[x1,x2,,xn])

FSM fsm = new FSM();
IntVar[] x = {x1, x2, …, xn};
Regular(fsm, x);

sequence([x1,x2,,xn],set,q,min,max)

IntVar[] x = {x0, x1 …xn};
IntervalDomain set = new IntervalDomain(…);
int q, main, max;
Sequence(x, set, q, min, max);

stretch(values,min,max,[x1,x2,,xn])

int[] values, main, max;
IntVar[] x = {x0, x1 …, xn};
Stretch(values, min, max, x);

values([x1,x2,,xn],count)

IntVar[] x = {x0, x1 …, xn};
IntVar count = new IntVar(…);
Values(x, count);

lex([[x11,x12,,x1n],,[xk1,xk2,,xkm]])

IntVar[][] x = {{x0, x1 …, xn}, …};
Lex(x);
or
Lex(x, true);

soft-alldifferent([x1,x2,,xn],cost,violation_measure)

IntVar[] x = {x0, x1 …, xn};
IntVar count = new IntVar(…);
SoftAlldifferent(x, cost, ViolationMeasure.DECOMPOSITION_BASED);
or
SoftAlldifferent(x, cost, ViolationMeasure.VARIABLE_BASED);

soft-GCC([x1,x2,,xn],hardCounters,countedV alues,softCounters,cost,violation_measure)

IntVar[] x = {x0, x1 …, xn};
IntVar[] hardCounters = {h1, h2, …, hn};
int[] countedValues = {v1, v2, …, vn};
IntVar[] softCounters = {s1, s2, …, sn};
SoftGCC(x, hardCounters, countedValues, softCounters, cost, ViolationMeasure.VALUE_BASED); or
other constructors (see API specification).