Global Constraints (continued) Nicolas Beldiceanu SICS - - PowerPoint PPT Presentation

global constraints continued
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Global Constraints (continued)

Nicolas Beldiceanu SICS

Lägerhyddsvägen 5 SE-75237 Uppsala, Sweden (nicolas@sics.se)

slide-2
SLIDE 2

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.

Describe other global constraints

slide-3
SLIDE 3

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 })

Principle of description

slide-4
SLIDE 4

Arc generators

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(=)

slide-5
SLIDE 5

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 })

More details

Derived collections Set variables More than one graph Constraints on subsets of vertices

slide-6
SLIDE 6

Motivations for Set Variables (finite set of integers)

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

slide-7
SLIDE 7

Inserting Set Variables Has to introduce: 1) A new basic data type: finite set of integers 2) Set variables 3) Elementary constraints over set variables

slide-8
SLIDE 8

Typical Arc Constraint

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

slide-9
SLIDE 9

Typical Arc Constraint

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

slide-10
SLIDE 10

Example of Global Constraint with Set Variables Given a directed graph select a subset of vertices so that the corresponding sub-graph does not contain any circuit. (F.Fages)

slide-11
SLIDE 11

Example of Global Constraint with Set Variables

Symbolic Constraints in Integeger Linear Programming

[E.Althaus,A.Bockmayr,M.Elf,M.Jünger,T.Kasper,K.Mehlhorn]

http://www.mpi-sb.mpg.de/SCIL/

StronglyConnected

”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.”

slide-12
SLIDE 12

Constraints Over Several Final Graphs

PROBLEM

Want to check graph properties on several final graphs

EXAMPLES

  • global cardinality [RÉGIN]: impose restriction on number of occurrences
  • f a value (depend on the value).
  • stretch[PESANT]: impose minimum and maximum time that a value can
  • ccur in a consecutive way (depend on the value)

SOLUTION Introduce an iterator over the items of a collection for

specifying in a generic way a set of:

  • elementary constraints which are pairwise incompatible (before CTR & ¬CTR)
  • graph properties.
slide-13
SLIDE 13

Constraints Over Set of Vertices

CONTEXT

Want to express constraints on set of variables which are not yet defined.

EXAMPLES

  • impose a constraint on all the objects which are assigned to the same bin.
  • impose a constraint on each set of 3 consecutives locations which are

visited by a vehicle.

SOLUTION Allows to impose constraints on set of vertices of the

final graph:

  • provide generators for set of vertices,
  • restrictions: − polynomial number of sets (pred, succ, ...),

− computing each set can be done in polynomial time.

slide-14
SLIDE 14

: 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

  • ARGUMENT
  • RESTRICTION(S)
  • VERTEX INPUT
  • VERTEX GENERATOR
  • EDGE INPUT
  • EDGE GENERATOR
  • EDGE ARITY
  • EDGE CONSTRAINT
  • GRAPH PROPERTIE
  • SETS
  • DYNAMIC CONSTRAINT

Avoid Clique(MAX) as a set generator

Generates all maximum cliques on the final graph: in general can’t be computed in polynomial time !!!

slide-15
SLIDE 15

Example of Use of Clique(MAX)

cumulative({

1 2 3 4 5 6 7 8 9 101112

≤ ≤ ≤ ≤ 8 1 2 3 4 5

  • rigin-1 duration-3 end-4 high-1,
  • rigin-2 duration-9 end-11 high-2,
  • rigin-3 duration-10 end-13 high-1,
  • rigin-6 duration-6 end-12 high-1,
  • rigin-7 duration-2 end-9 high-3

}, 8)

slide-16
SLIDE 16

Constraints Mentioning Clique(MAX)

  • assign_and_count
  • assign_and_nvalue
  • interval_and_sum
  • interval_and_count
  • track
  • bin_packing
  • cumulative
  • cumulatives
  • cumulative_product
  • coloured_cumulative
  • cyclic_cumulative
  • coloured_cumulatives
  • cumulative_2d

OBSERVATION: all final graphs

associated to these constraints are interval graphs, so we use

  • ne other model which avoids

Clique(MAX).

slide-17
SLIDE 17

Intuition of the New Model

  • ARC INPUT
  • ARC GENERATOR
  • ARC ARITY
  • ARC CONSTRAINT
  • SETS

: 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}

slide-18
SLIDE 18

Which Time Points ?

The task origins and ends:

1 2 3 4 5 6 7 8 9 10 11 12

  • But the time points are not explicitly mentioned in the constraint?
slide-19
SLIDE 19

Generates a collection containing one single item

Derived Collections

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

slide-20
SLIDE 20

Generates a collection by applying an item generator to each item of the TASKS collection

Derived Collection for cumulatives

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

slide-21
SLIDE 21
  • DATA CONSTRAINTS
  • VALUE CONSTRAINTS (one set of variables)
  • VALUE CONSTRAINTS (two sets of variables)
  • ORDERING CONSTRAINTS
  • CHANNELING CONSTRAINTS
  • GRAPH CONSTRAINTS
  • RELAXATION AND PROXIMITY CONSTRAINTS

Categories of Global Constraints

slide-22
SLIDE 22
slide-23
SLIDE 23

ARGUMENTS :

ctr_arguments(element, [INDEX-dvar, TABLE-collection(value-dvar), VALUE-dvar]).

PURPOSE :

VALUE is equal to the INDEX-th item of TABLE.

Element

ORIGIN : [VanHentenryckCarillon88] EXAMPLE :

element(3, [[value-6],[value-9],[value-2],[value-9]], 2)

slide-24
SLIDE 24

Element

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

slide-25
SLIDE 25

Element

PRODUCT ITEM TABLE INITIAL GRAPH

NARC=1

FINAL GRAPH element(3, [[value-6],[value-9],[value-2],[value-9]], 2)

slide-26
SLIDE 26
slide-27
SLIDE 27

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]])

Symmetric_alldifferent

slide-28
SLIDE 28

Symmetric_alldifferent

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

slide-29
SLIDE 29

Symmetric_alldifferent

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]])

slide-30
SLIDE 30

ARGUMENTS :

ctr_arguments(balance, [BALANCE-dvar , VARIABLES-collection(var-dvar)]).

PURPOSE :

BALANCE is equal to the difference between the number of

  • ccurrence of the value that occurs the most and the value that
  • ccurs the least within the collection of variables VARIABLES.

Balance

ORIGIN : [Beldiceanu00] EXAMPLE :

balance(2,[[var-3],[var-1],[var-7],[var-1],[var-1]])

slide-31
SLIDE 31

Balance: description

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

=

slide-32
SLIDE 32

Balance: from initial to final graph

FINAL GRAPH

RANGE_NSCC=3-1=2

CLIQUE VARIABLES

=

INITIAL GRAPH balance(2,[[var-3],[var-1],[var-7],[var-1],[var-1]])

slide-33
SLIDE 33
slide-34
SLIDE 34

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]])

Disjoint

slide-35
SLIDE 35

Disjoint

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)

slide-36
SLIDE 36

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]])

Common

slide-37
SLIDE 37

Common

INITIAL GRAPH FINAL GRAPH

slide-38
SLIDE 38

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]])

Used_by

slide-39
SLIDE 39

Used_by

For all CC: NSOURCE >= NSINK NSINK = size(VARIABLES2)

INITIAL GRAPH FINAL GRAPH

slide-40
SLIDE 40

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]])

Same

slide-41
SLIDE 41

Same

INITIAL GRAPH FINAL GRAPH

slide-42
SLIDE 42

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]])

Sort

slide-43
SLIDE 43

Sort

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)]).

slide-44
SLIDE 44

Sort

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

slide-45
SLIDE 45

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

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]])

slide-46
SLIDE 46

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

  • f collection TO according to the permutation PERMUTATION.

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]])

Sort_permutation

slide-47
SLIDE 47

Sort_permutation

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

  • f the collection TO (like sort)
slide-48
SLIDE 48

FINAL GRAPH

Sort_permutation

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]])

slide-49
SLIDE 49

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

  • n the number of occurrences of each value.

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]])

Symmetric_gcc

slide-50
SLIDE 50

Symmetric_gcc

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

slide-51
SLIDE 51

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]])

Symmetric_gcc

3 12 3 3 2 1

slide-52
SLIDE 52
slide-53
SLIDE 53

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]])

Minimum

slide-54
SLIDE 54

Minimum

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

slide-55
SLIDE 55

Minimum

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

slide-56
SLIDE 56

ARGUMENTS :

ctr_arguments(lex_lesseq, [VECTOR1-collection(var-dvar), VECTOR2-collection(var-dvar)]).

PURPOSE :

VECTOR1 is lexicographically less than or equal to VECTOR2.

Lex_lesseq

ORIGIN : CHIP EXAMPLE :

lex_lesseq([[var-5], [var-2], [var-3], [var-1]], [[var-5], [var-2], [var-6], [var-2]])

slide-57
SLIDE 57

Lex_lesseq

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

=

slide-58
SLIDE 58

Lex_lesseq

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

5=5 2=2 3<6 1≤ ≤ ≤ ≤2

slide-59
SLIDE 59
slide-60
SLIDE 60

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.

Domain_constraint

ORIGIN : [Refalo00] EXAMPLE :

domain_constraint(5,[[var01-0, value-9], [var01-1, value-5], [var01-0, value-2], [var01-0, value-7]])

slide-61
SLIDE 61

Domain_constraint

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

slide-62
SLIDE 62

Domain_constraint

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]])

slide-63
SLIDE 63

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]])

Link_set_to_booleans

slide-64
SLIDE 64

Link_set_to_booleans

FINAL GRAPH INITIAL GRAPH

slide-65
SLIDE 65
slide-66
SLIDE 66

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.

Cutset

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]])

slide-67
SLIDE 67

Cutset: description

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

slide-68
SLIDE 68

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

Cutset: from initial to final graph

MAX_NSCC=1, NVERTEX=3

INITIAL GRAPH

NODES CLIQUE

slide-69
SLIDE 69

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.

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}]])

slide-70
SLIDE 70

Clique

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

slide-71
SLIDE 71

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

slide-72
SLIDE 72

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).

K_cut

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}]])

slide-73
SLIDE 73

K_cut

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

slide-74
SLIDE 74

K_cut

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}]])

slide-75
SLIDE 75

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}]])

Path_from_to

slide-76
SLIDE 76

Path_from_to

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

slide-77
SLIDE 77

Path_from_to

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}]])

slide-78
SLIDE 78

! !"#

slide-79
SLIDE 79

ARGUMENTS :

ctr_arguments(soft_alldifferent_ctr, [C-dvar, VARIABLES-collection(var-dvar)]).

PURPOSE :

Consider the disequality constraints involving two distinct variables of the collection

  • VARIABLES. Among the previous set of constraints,

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]])

Soft_alldifferent_ctr

slide-80
SLIDE 80

Soft_alldifferent_ctr

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

slide-81
SLIDE 81

Soft_alldifferent_ctr

CLIQUE(<) VARIABLES

INITIAL GRAPH FINAL GRAPH

NARC=4

soft_alldifferent_ctr(4,[[var-5],[var-1],[var-9],[var-1],[var-5],[var-5]])

slide-82
SLIDE 82

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

  • f VARIABLES take a distinct value.

ORIGIN : [PetitRéginBessière01] EXAMPLE :

soft_alldifferent_var(3,[[var-5],[var-1],[var-9],[var-1],[var-5],[var-5]])

Soft_alldifferent_var

slide-83
SLIDE 83

Soft_alldifferent_var

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

slide-84
SLIDE 84

Soft_alldifferent_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]])

slide-85
SLIDE 85

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]],<)

Distance_between

slide-86
SLIDE 86

Distance_between

slide-87
SLIDE 87

Exercise: modelling the non-overlapping constraint between rectangles

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):

  • ox: coordinate of its origin on x,
  • oy: coordinate of its origin on y,
  • sx: size on x,
  • sy: size on y,
  • ex: end (ox+sx) on x,
  • ey: end (oy+sy) on y.

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(≠))