Global Constraints (continued)
Nicolas Beldiceanu SICS
Lägerhyddsvägen 5 SE-75237 Uppsala, Sweden (nicolas@sics.se)
Global Constraints (continued) Nicolas Beldiceanu SICS - - PowerPoint PPT Presentation
Global Constraints (continued) Nicolas Beldiceanu SICS Lgerhyddsvgen 5 SE-75237 Uppsala, Sweden (nicolas@sics.se) Describe other global constraints Except resource scheduling, routing, geometric, regulation and optimisation constraints
Lägerhyddsvägen 5 SE-75237 Uppsala, Sweden (nicolas@sics.se)
Except resource scheduling, routing, geometric, regulation and optimisation constraints (see in next courses). But first, go into more detail on how to describe global constraints.
V1 V2 V3 V4 V5 Edge constraint:
=
V1 V2 V3 V4 V5 = = = = = = = = = = = = = = =
3 1 7 1 6
= = = = = = Graph property:
NSCC=NVAL
nvalue(4, { var-3,var-1,var-7,var-1,var-6 })
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 3 2 4 1 3 2 4 1 3 2 4 1 3 2 4
SELF LOOP PATH PATH PATH_1 PATH_N CIRCUIT CHAIN CYCLE CLIQUE CLIQUE(≠ ≠ ≠ ≠) CLIQUE(<) PRODUCT PRODUCT(=) SYMMETRIC_PRODUCT SYMMETRIC_PRODUCT(=)
V1 V2 V3 V4 V5 Edge constraint:
=
V1 V2 V3 V4 V5 = = = = = = = = = = = = = = =
3 1 7 1 6
= = = = = = Graph property:
NSCC=NVAL
nvalue(4, { var-3,var-1,var-7,var-1,var-6 })
Derived collections Set variables More than one graph Constraints on subsets of vertices
1) Exists since a long time (both in academy and in industrial solvers) 2) Has a discrete nature (as standard domain variables) 3) Expressive (avoid models with artificial variables) 4) Recently some suggestions of global constraints with set variables 5) Within linear programming and constraint programming a typical constraint is: for a given graph selects a subset of arcs so that a given graph property holds
index1: int var1 : svar index2∈var1 index2: int var2 : svar index1: 1 var1: {2,3,5} 3∈var1 index3: 3 var3 : {} index2: 2 var2 : {} index4: 4 var4 : {} 2∈var1 4∈var1
index1: int var1 : svar index2∈var1 index2: int var2 : svar index1: 1 var1: {2,3,5} 3∈var1 index3: 3 var3 : {} index2: 2 var2 : {} index4: 4 var4 : {} 2∈var1 4∈var1
http://www.mpi-sb.mpg.de/SCIL/
”This symbolic constraints takes as arguments a directed graph G and a var_map<edge> X. X has to map every edge of the graph to a binary variable. The feasible assignments of the symbolic constraint are those where the vector of the variables associated with the edges of the graph is an incidence vector of a strongly connected subgraph of G.”
PROBLEM
Want to check graph properties on several final graphs
EXAMPLES
SOLUTION Introduce an iterator over the items of a collection for
specifying in a generic way a set of:
CONTEXT
Want to express constraints on set of variables which are not yet defined.
EXAMPLES
visited by a vehicle.
SOLUTION Allows to impose constraints on set of vertices of the
final graph:
− computing each set can be done in polynomial time.
: TASKS: collection(origin-dvar,duration-dvar end-dvar, high-dvar) LIMIT: int : at least 2 out of [TASKS.origin,TASKS.duration,TASKS.end] required(TASKS.high) TASKS.duration ≥ 0 TASKS.high ≥ 0 LIMIT ≥ 0 : TASKS : IDENTITY : TASKS : CLIQUE : 2 : TASKS.origin[1]+TASKS.duration[1]=TASKS.end[1] ∧ TASKS.origin[2]+TASKS.duration[2]=TASKS.end[2] ∧ TASKS.origin[1]<TASKS.end[2] ∧ TASKS.origin[2]<TASKS.end[1] : NVERTEX = |TASKS| : CLIQUE(MAX) : Sum(TASKS.high) ≤ LIMIT
Generates all maximum cliques on the final graph: in general can’t be computed in polynomial time !!!
cumulative({
1 2 3 4 5 6 7 8 9 101112
≤ ≤ ≤ ≤ 8 1 2 3 4 5
}, 8)
OBSERVATION: all final graphs
associated to these constraints are interval graphs, so we use
Clique(MAX).
: Time points, Tasks : product : 2 : overlap : succ Time points Tasks Is overlapped by
p1 p2 p3 p4 p5 p6 t1 t2 t3 {t1, t2} {t2, t3} {t3}
The task origins and ends:
1 2 3 4 5 6 7 8 9 10 11 12
Generates a collection containing one single item
An optional extra field for describing a global constraint. Purpose : generates collections from the parameters of the constraint. Motivation: allows to simplify parameters of a constraint.
FROM element(INDEX,TABLE,VALUE) INDEX : dvar TABLE: collection(index-dvar,value-dvar) VALUE: dvar TO element(ITEM,TABLE) ITEM : collection(index-dvar,value-dvar) TABLE: collection(index-int ,value-int ) DERIVED COLLECTION: SIMPLE ITEM: (index-INDEX, value-VALUE)
FIELD NAME COLLECTION GENERATOR NAME OF GENERATED COLLECTION PARAMETERS FOR THE COLLECTION GENERATOR
Generates a collection by applying an item generator to each item of the TASKS collection
CONSTRAINT: cumulatives(TASKS,MACHINES,CTR) ARGUMENTS: TASKS : collection(machine-dvar,origin-dvar,duration-dvar,end-dvar,height-dvar) MACHINES: collection(id-int,capacity-int) CTR : atom ..........................................................................................
DERIVED COLLECTION: EXPAND(TASKS) TIME_POINTS: (duration-1, origin-origin, end-origin+1) (duration-1, origin-end , end-end+1 )
FIELD NAME COLLECTION GENERATOR NAME OF GENERATED COLLECTION PARAMETERS FOR THE COLLECTION GENERATOR
ARGUMENTS :
ctr_arguments(element, [INDEX-dvar, TABLE-collection(value-dvar), VALUE-dvar]).
PURPOSE :
VALUE is equal to the INDEX-th item of TABLE.
ORIGIN : [VanHentenryckCarillon88] EXAMPLE :
element(3, [[value-6],[value-9],[value-2],[value-9]], 2)
ctr_graph(element, [ITEM,TABLE], 2, [PRODUCT>>collection(item,table)], [item.index = table.key, item.value = table.value], [NARC = 1]).
1:index value 2:key value
item.index = table.key item.value = table.value ARC CONSTRAINT PRODUCT ITEM TABLE INITIAL GRAPH
PRODUCT ITEM TABLE INITIAL GRAPH
NARC=1
FINAL GRAPH element(3, [[value-6],[value-9],[value-2],[value-9]], 2)
ARGUMENTS :
ctr_arguments(symmetric_alldifferent, [NODES-collection(index-int, succ-dvar)]).
PURPOSE :
All variables associated to the succ attribute of the NODES collection should be pairwise distinct. In addition enforce the following condition: If variable NODES[i].succ takes value j then variable NODES[j].succ takes value i.
ORIGIN : [Régin99] EXAMPLE :
symmetric_alldifferent([[index-1, succ-3], [index-2, succ-4], [index-3, succ-1], [index-4, succ-2]])
NODES INITIAL GRAPH CLIQUE(≠ ≠ ≠ ≠) ctr_graph(symmetric_alldifferent, [NODES], 2, [CLIQUE(≠ ≠ ≠ ≠)>>collection(nodes1,nodes2)], [nodes1.succ = nodes2.index, nodes2.succ = nodes1.index], [NARC = size(NODES)]).
1:index succ 2:index succ
nodes1.succ = nodes2.index, nodes2.succ = nodes1.index ARC CONSTRAINT
NODES INITIAL GRAPH CLIQUE(≠ ≠ ≠ ≠) FINAL GRAPH
NARC=4
symmetric_alldifferent([[index-1, succ-3], [index-2, succ-4], [index-3, succ-1], [index-4, succ-2]])
ARGUMENTS :
ctr_arguments(balance, [BALANCE-dvar , VARIABLES-collection(var-dvar)]).
PURPOSE :
BALANCE is equal to the difference between the number of
ORIGIN : [Beldiceanu00] EXAMPLE :
balance(2,[[var-3],[var-1],[var-7],[var-1],[var-1]])
CLIQUE VARIABLES
INITIAL GRAPH ctr_graph(balance, [VARIABLES], 2, [CLIQUE>>collection(variables1,variables2)], [variables1.var = variables2.var], [RANGE_NSCC = BALANCE]).
1:var 2:var
variables1.var = variables2.var ARC CONSTRAINT
FINAL GRAPH
RANGE_NSCC=3-1=2
CLIQUE VARIABLES
INITIAL GRAPH balance(2,[[var-3],[var-1],[var-7],[var-1],[var-1]])
ARGUMENTS :
ctr_arguments(disjoint,[VARIABLES1-collection(var-dvar), VARIABLES2-collection(var-dvar)]).
PURPOSE :
Each variable of the collection VARIABLES1 should be different from all the variables of the collection VARIABLES2.
ORIGIN : N.Beldiceanu EXAMPLE :
disjoint([[var-1],[var-9],[var-1],[var-5]], [[var-2],[var-7],[var-7],[var-0],[var-6],[var-8]])
1:var 2:var
variables1.var = variables2.var ARC CONSTRAINT PRODUCT VARIABLES1 INITIAL GRAPH VARIABLES2 ctr_graph(disjoint, [VARIABLES1, VARIABLES2], 2, [PRODUCT>>collection(variables1, variables2)], [variables1.var = variables2.var], [NARC = 0]). FINAL GRAPH is empty (NARC = 0)
ARGUMENTS :
ctr_arguments(common,[NCOMMON1-dvar, NCOMMON2-dvar, VARIABLES1-collection(var-dvar), VARIABLES2-collection(var-dvar)]).
PURPOSE :
NCOMMON1 is the number of variables of the collection of variables VARIABLES1 taking a value in VARIABLES2. NCOMMON2 is the number of variables of the collection of variables VARIABLES2 taking a value in VARIABLES1.
ORIGIN : N.Beldiceanu EXAMPLE :
common(3,4,[[var-1],[var-9],[var-1],[var-5]], [[var-2],[var-1],[var-9],[var-9],[var-6],[var-9]])
INITIAL GRAPH FINAL GRAPH
ARGUMENTS :
ctr_arguments(used_by,[VARIABLES1-collection(var-dvar), VARIABLES2-collection(var-dvar)]).
PURPOSE :
All the values of the variables of collection VARIABLES2 are used by the variables of collection VARIABLES1.
ORIGIN : N.Beldiceanu EXAMPLE :
used_by([[var-1],[var-9],[var-1],[var-5],[var-2],[var-1]], [[var-1],[var-1],[var-2],[var-5]])
For all CC: NSOURCE >= NSINK NSINK = size(VARIABLES2)
INITIAL GRAPH FINAL GRAPH
ARGUMENTS :
ctr_arguments(same, [VARIABLES1-collection(var-dvar), VARIABLES2-collection(var-dvar)]).
PURPOSE :
The variables of the collection VARIABLES2 correspond to the variables of the collection VARIABLES1 according to a permutation.
ORIGIN : N.Beldiceanu EXAMPLE :
same([[var-1],[var-9],[var-1],[var-5],[var-2],[var-1]], [[var-9],[var-1],[var-1],[var-1],[var-2],[var-5]])
INITIAL GRAPH FINAL GRAPH
ARGUMENTS :
ctr_arguments(sort,[VARIABLES1-collection(var-dvar), VARIABLES2-collection(var-dvar)]).
PURPOSE :
The variables of the collection VARIABLES2 correspond to the variables of VARIABLES1 according to a permutation. The variables of VARIABLES2 are sorted in increasing order.
ORIGIN : [OlderSwinkelsEmden95] EXAMPLE :
sort([[var-1],[var-9],[var-1],[var-5],[var-2],[var-1]], [[var-1],[var-1],[var-1],[var-2],[var-5],[var-9]])
PRODUCT VARIABLES1 INITIAL GRAPH VARIABLES2
1:var 2:var
variables1.var = variables2.var ARC CONSTRAINT ctr_graph(sort, [VARIABLES1, VARIABLES2], 2, [PRODUCT>>collection(variables1, variables2)], [variables1.var = variables2.var], [for_all(CC,NSOURCE = NSINK), NSOURCE = size(VARIABLES1), NSINK = size(VARIABLES2)]).
1:var 2:var
variables1.var ≤ variables2.var ARC CONSTRAINT ctr_graph(sort, [VARIABLES2], 2, [PATH>>collection(variables1, variables2)], [variables1.var ≤ variables2.var], [NARC = size(VARIABLES2)-1]). INITIAL GRAPH VARIABLES2 PATH
PRODUCT
VARIABLES1 INITIAL GRAPH VARIABLES2 FINAL GRAPH
CC#1: NSOURCE=3, NSINK=3 CC#2: NSOURCE=1, NSINK=1 CC#3: NSOURCE=1, NSINK=1 CC#4: NSOURCE=6, NSINK=6 NSOURCE=3, NSINK=3
sort([[var-1],[var-9],[var-1],[var-5],[var-2],[var-1]], [[var-1],[var-1],[var-1],[var-2],[var-5],[var-9]])
ARGUMENTS :
ctr_arguments(sort_permutation, [FROM-collection(var-dvar), PERMUTATION-collection(ind-dvar), TO-collection(var-dvar)]).
PURPOSE :
The variables of collection FROM correspond to the variables
The variables of collection TO are sorted in increasing order.
ORIGIN : [Zhou97] EXAMPLE :
sort_permutation([[var-1],[var-9],[var-1],[var-5],[var-2],[var-1]], [[ind-1],[ind-6],[ind-3],[ind-5],[ind-4],[ind-2]], [[var-1],[var-1],[var-1],[var-2],[var-5],[var-9]])
PRODUCT FROM_PERMUTATION
INITIAL GRAPH
TO
ctr_graph(sort_permutation, [FROM_PERMUTATION,TO], 2, [PRODUCT>>collection( from_permutation,to)], [from_permutation.var = to.var, from_permutation.ind = to.key], [NARC = size(PERMUTATION)]).
1:var ind 2:key ind
from_permutation.var = to.var, from_permutation.ind = to.key ARC CONSTRAINT + a graph for ordering the items
FINAL GRAPH
NARC=6 PRODUCT FROM_PERMUTATION
INITIAL GRAPH
TO
sort_permutation([[var-1],[var-9],[var-1],[var-5],[var-2],[var-1]], [[ind-1],[ind-6],[ind-3],[ind-5],[ind-4],[ind-2]], [[var-1],[var-1],[var-1],[var-2],[var-5],[var-9]])
ARGUMENTS :
ctr_arguments(symmetric_gcc, [VARS-collection(idvar-int, var-svar, nocc-dvar), VALS-collection(idval-int, val-svar, nocc-dvar)]).
PURPOSE :
Put in relation two sets: for each element of one set gives the corresponding elements of the other set to which it is associated. In addition enforce constraints
ORIGIN : Derived from global_cardinality by W.Kocjan. EXAMPLE :
symmetric_gcc([[idvar-1, var-{3} , nocc-1],[idvar-2, var-{1} , nocc-1], [idvar-3, var-{1,2} , nocc-2],[idvar-4, var-{1,3}, nocc-2]], [[idval-1, val-{2,3,4}, nocc-3],[idval-2, val-{3} , nocc-1], [idval-3, val-{1,4} , nocc-2],[idval-4, val-{} , nocc-0]])
PRODUCT VARS INITIAL GRAPH VALS ctr_graph(symmetric_gcc, [VARS,VALS], 2, [PRODUCT>>collection(vars,vals)], [in_set(vars.idvar,vals.val) ⇔ ⇔ ⇔ ⇔ in_set(vals.idval,vars.var), vars.nocc = card_set(vars.var), vals.nocc = card_set(vals.val)], [NARC = size(VARS)*size(VALS)]).
1:idvar var nocc 2:idval val nocc
ARC CONSTRAINT
PRODUCT VARS INITIAL GRAPH VALS FINAL GRAPH
NARC=16
symmetric_gcc([[idvar-1, var-{3} , nocc-1],[idvar-2, var-{1} , nocc-1], [idvar-3, var-{1,2} , nocc-2],[idvar-4, var-{1,3}, nocc-2]], [[idval-1, val-{2,3,4}, nocc-3],[idval-2, val-{3} , nocc-1], [idval-3, val-{1,4} , nocc-2],[idval-4, val-{} , nocc-0]])
3 12 3 3 2 1
ARGUMENTS :
ctr_arguments(minimum,[MIN-dvar, VARIABLES-collection(var-dvar)]).
PURPOSE :
MIN is the minimum value of the collection of domain variables VARIABLES.
ORIGIN : CHIP EXAMPLE :
minimum(2,[[var-3],[var-2],[var-7],[var-2],[var-6]])
CLIQUE VARIABLES INITIAL GRAPH ctr_graph(minimum, [VARIABLES], 2, [CLIQUE>>collection(variables1, variables2)], [variables1 = variables2 \/ variables1.var < variables2.var], [ORDER(0,MAXINT,var) = MIN]).
1:var 2:var
variables1 = variables2 \/ variables1.var < variables2.var ARC CONSTRAINT
FINAL GRAPH
ORDER(0,MAXINT,var)=2
CLIQUE VARIABLES INITIAL GRAPH minimum(2,[[var-3],[var-2],[var-7],[var-2],[var-6]]) 2 2
ARGUMENTS :
ctr_arguments(lex_lesseq, [VECTOR1-collection(var-dvar), VECTOR2-collection(var-dvar)]).
PURPOSE :
VECTOR1 is lexicographically less than or equal to VECTOR2.
ORIGIN : CHIP EXAMPLE :
lex_lesseq([[var-5], [var-2], [var-3], [var-1]], [[var-5], [var-2], [var-6], [var-2]])
PRODUCT(PATH,VOID)
COMPONENTS INITIAL GRAPH DESTINATION
ctr_graph(lex_lesseq, [COMPONENTS,DESTINATION], 2, [PRODUCT(PATH,VOID)>> collection(item1,item2)], [(item2.index>0 /\ item1.x = item1.y) \/ (item1.index < size('VECTOR1') /\ item2.index=0 /\ item1.x < item1.y) \/ (item1.index = size('VECTOR1') /\ item2.index=0 /\ item1.x ≤ item1.y], [PATH_FROM_TO(index,1,0) = 1]).
1:index x y 2:index x y
ARC CONSTRAINT item1.x = item1.y item1.x < item1.y item1.x ≤ item1.y
PRODUCT(PATH,VOID)
COMPONENTS INITIAL GRAPH DESTINATION
FINAL GRAPH
PATH_FROM_TO(index,1,0)
1:0,0,0 1:1,5,5
COMPONENTS DESTINATION
ARGUMENTS :
ctr_arguments(domain_constraint, [VAR-dvar, VALUES-collection(var01-dvar, value-int)]).
PURPOSE :
Used in order to make the link between a formulation using finite domain constraints and a formulation based on linear programming.
ORIGIN : [Refalo00] EXAMPLE :
domain_constraint(5,[[var01-0, value-9], [var01-1, value-5], [var01-0, value-2], [var01-0, value-7]])
ctr_graph(domain_constraint, [VALUE,VALUES], 2, [PRODUCT>>collection(value,values)], [(value.value=values.value /\ values.var01=1) \/ (value.value≠ ≠ ≠ ≠values.value /\ values.var01=0)], [NARC = size(VALUES)]).
1:var01 value 2:var01 value
ARC CONSTRAINT
(value.value=values.value /\ values.var01=1) \/ (value.value≠ ≠ ≠ ≠values.value /\ values.var01=0)
PRODUCT VALUE VALUES INITIAL GRAPH
PRODUCT VALUE VALUES INITIAL GRAPH FINAL GRAPH
NARC=4
domain_constraint(5,[[var01-0, value-9], [var01-1, value-5], [var01-0, value-2], [var01-0, value-7]])
ARGUMENTS :
ctr_arguments(link_set_to_booleans, [SVAR-svar, BOOLEANS-collection(bool-dvar, val-int)]).
PURPOSE :
Make the link between a set variable SVAR and those 0-1 variables that are associated to each potential value belonging to SVAR.
ORIGIN : Inspired by domain_constraint. EXAMPLE :
link_set_to_booleans({1,3,4}, [[bool-0, val-0],[bool-1, val-1],[bool-0, val-2], [bool-1, val-3],[bool-1, val-4],[bool-0, val-5]])
FINAL GRAPH INITIAL GRAPH
ARGUMENTS :
ctr_arguments(cutset, [SIZE_CUTSET-dvar, NODES-collection(index-int, succ-sint, bool-dvar)]).
PURPOSE :
Consider a directed graph G with n vertices. Enforces that the subset of kept vertices of cardinality n-SIZE_CUTSET and their corresponding arcs form a graph without circuit.
ORIGIN : [FagesLal03] EXAMPLE :
cutset(1, [[index-1, succ-{2,3,4}, bool-1], [index-2, succ-{3}, bool-1], [index-3, succ-{4}, bool-1], [index-4, succ-{1}, bool-0]])
NODES
INITIAL GRAPH ctr_graph(cutset, [NODES], 2, [CLIQUE>>collection(nodes1,nodes2)], [nodes2.index∈
∈ ∈ ∈nodes1.succ,
nodes1.bool = 1 , nodes2.bool = 1 ], [MAX_NSCC ≤ 1, NVERTEX = size(NODES) − SIZE_CUTSET]).
1:index
succ bool
nodes2.index∈
∈ ∈ ∈nodes1.succ,
nodes1.bool = 1, nodes2.bool = 1 ARC CONSTRAINT
2:index
succ bool CLIQUE
cutset(1, [[index-1, succ-{2,3,4}, bool-1], [index-2, succ-{3}, bool-1], [index-3, succ-{4}, bool-1], [index-4, succ-{1}, bool-0]])
FINAL GRAPH
MAX_NSCC=1, NVERTEX=3
INITIAL GRAPH
NODES CLIQUE
ARGUMENTS :
ctr_arguments(clique, [SIZE_CLIQUE-dvar, NODES-collection(index-int, succ-svar)]).
PURPOSE :
Consider a directed graph G. Select a subset of the vertices of G which form a clique of size SIZE_CLIQUE.
ORIGIN : [Fahle02] EXAMPLE :
clique(3, [[index-1, succ-{}], [index-2, succ-{3,5}], [index-3, succ-{2,5}], [index-4, succ-{}], [index-5, succ-{2,3}]])
NODES
INITIAL GRAPH ctr_graph(clique, [NODES], 2, [CLIQUE >>collection(nodes1,nodes2)], [nodes1 ≠ nodes2, in_set(nodes2.index,nodes1.succ)], [NARC = SIZE_CLIQUE*SIZE_CLIQUE −SIZE_CLIQUE, NVERTEX = SIZE_CLIQUE]).
1:index
succ
nodes1 ≠ nodes2, in_set(nodes2.index,nodes1.succ) ARC CONSTRAINT
2:index
succ CLIQUE
FINAL GRAPH
NARC=6, NVERTEX=3 NODES
INITIAL GRAPH clique(3, [[index-1, succ-{}], [index-2, succ-{3,5}], [index-3, succ-{2,5}], [index-4, succ-{}], [index-5, succ-{2,3}]])
CLIQUE
ARGUMENTS :
ctr_arguments(k_cut, [K-int, NODES-collection(index-int, succ-svar)]).
PURPOSE :
Select some arcs of a directed graph in order to have at least K connected components (an isolated vertex is counted as one connected component).
ORIGIN : E. Althaus EXAMPLE :
k_cut(3,[[index-1, succ-{}],[index-2, succ-{3,5}],[index-3, succ-{5}], [index-4, succ-{}],[index-5, succ-{2,3}]])
ctr_graph(k_cut, [NODES], 2, [CLIQUE >>collection(nodes1,nodes2)], [nodes1=nodes2 \/ in_set(nodes2.index,nodes1.succ)], [NCC >= K]).
1:index
succ
nodes1=nodes2 \/ in_set(nodes2.index,nodes1.succ) ARC CONSTRAINT
2:index
succ CLIQUE NODES
INITIAL GRAPH
CLIQUE NODES
INITIAL GRAPH FINAL GRAPH
NCC=3
k_cut(3,[[index-1, succ-{}],[index-2, succ-{3,5}],[index-3, succ-{5}], [index-4, succ-{}],[index-5, succ-{2,3}]])
ARGUMENTS :
ctr_arguments(path_from_to,[FROM-int, TO-int, NODES-collection(index-int, succ-svar)]).
PURPOSE :
MIN is the minimum value of the collection of domain variables VARIABLES.
ORIGIN : [AlthausBockmayrElfKasperJungerMehlhorn02] EXAMPLE :
path_from_to(4,3,[[index-1, succ-{} ],[index-2, succ-{}],[index-3, succ-{5}], [index-4, succ-{5}],[index-5, succ-{2,3}]])
CLIQUE NODES
INITIAL GRAPH ctr_graph(path_from_to, [NODES], 2, [CLIQUE >>collection(nodes1,nodes2)], [in_set(nodes2.index,nodes1.succ)], [PATH_FROM_TO(index,FROM,TO) = 1]).
1:index
succ
in_set(nodes2.index,nodes1.succ) ARC CONSTRAINT
2:index
succ
FINAL GRAPH
PATH_FROM_TO(index,4,3)=1 CLIQUE NODES
INITIAL GRAPH path_from_to(4,3,[[index-1, succ-{} ],[index-2, succ-{}],[index-3, succ-{5}], [index-4, succ-{5}],[index-5, succ-{2,3}]])
ARGUMENTS :
ctr_arguments(soft_alldifferent_ctr, [C-dvar, VARIABLES-collection(var-dvar)]).
PURPOSE :
Consider the disequality constraints involving two distinct variables of the collection
C is the number of disequality constraints which do not hold.
ORIGIN : [PetitRéginBessière01] EXAMPLE :
soft_alldifferent_ctr(4,[[var-5],[var-1],[var-9],[var-1],[var-5],[var-5]])
ctr_graph(soft_alddifferent_ctr, [VARIABLES], 2, [CLIQUE(<)>>collection(variables1, variables2)], [variables1.var = variables2.var], [NARC = C]).
1:var
variables1.var = variables2.var ARC CONSTRAINT
2:var
CLIQUE(<) VARIABLES
INITIAL GRAPH
CLIQUE(<) VARIABLES
INITIAL GRAPH FINAL GRAPH
NARC=4
soft_alldifferent_ctr(4,[[var-5],[var-1],[var-9],[var-1],[var-5],[var-5]])
ARGUMENTS :
ctr_arguments(soft_alldifferent_var,[C-dvar, VARIABLES-collection(var-dvar)]).
PURPOSE :
C is the minimum number of variables of the collection VARIABLES for which the value needs to be changed in order that all variables
ORIGIN : [PetitRéginBessière01] EXAMPLE :
soft_alldifferent_var(3,[[var-5],[var-1],[var-9],[var-1],[var-5],[var-5]])
CLIQUE VARIABLES
INITIAL GRAPH ctr_graph(soft_alddifferent_var, [VARIABLES], 2, [CLIQUE >>collection(variables1, variables2)], [variables1.var = variables2.var], [size(VARIABLES) - NSCC = C]).
1:var
variables1.var = variables2.var ARC CONSTRAINT
2:var
CLIQUE VARIABLES
INITIAL GRAPH FINAL GRAPH
NSCC=3
soft_alldifferent_var(3,[[var-5],[var-1],[var-9],[var-1],[var-5],[var-5]])
ARGUMENTS :
ctr_arguments(distance_between, [DIST-dvar, VARIABLES1-collection(var-dvar), VARIABLES2-collection(var-dvar), CTR-[=,=\=,<,>=,>,=<]).
PURPOSE :
Let Ui and Vi be respectively the i-th and j-th variables of VARIABLES1. Let Xi and Yi be respectively the i-th and j-th variables of VARIABLES2. DIST is equal to the number of times one of the following mutually incompatible conditions are true: Ui CTR Vi holds and Xi CTR Yi does not hold, Xi CTR Yi holds and Ui CTR Vi does not hold.
ORIGIN : N.Beldiceanu. EXAMPLE :
distance_between(2,[[var-3],[var-4],[var-6],[var-2],[var-4]], [[var-2],[var-6],[var-9],[var-3],[var-6]],<)
Model the non-overlapping constraint between n rectangles. Each rectangle is described by its origin (lower leftmost point), its sizes and its ends (all domain variables):
Hints: First model the non-overlapping constraint between two rectangles, (use the arc generator SYMMETRIC_PRODUCT(=), take care of the case when size can be equal to 0) Then model the non-overlapping constraint between n rectangles (use CLIQUE(≠))