5.167. global_cardinality_with_costs

DESCRIPTIONLINKSGRAPH
Origin

[Regin99a]

Constraint

πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜(πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚,πš…π™°π™»πš„π™΄πš‚,π™Όπ™°πšƒπšπ™Έπš‡,π™²π™Ύπš‚πšƒ)

Synonyms

𝚐𝚌𝚌𝚌, 𝚌𝚘𝚜𝚝_𝚐𝚌𝚌.

Arguments
πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πšŸπšŠπš›-πšπšŸπšŠπš›)
πš…π™°π™»πš„π™΄πš‚πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πšŸπšŠπš•-πš’πš—πš,πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ-πšπšŸπšŠπš›)
π™Όπ™°πšƒπšπ™Έπš‡πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš’-πš’πš—πš,πš“-πš’πš—πš,𝚌-πš’πš—πš)
π™²π™Ύπš‚πšƒπšπšŸπšŠπš›
Restrictions
πš›πšŽπššπšžπš’πš›πšŽπš(πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚,πšŸπšŠπš›)
|πš…π™°π™»πš„π™΄πš‚|>0
πš›πšŽπššπšžπš’πš›πšŽπš(πš…π™°π™»πš„π™΄πš‚,[πšŸπšŠπš•,πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ])
πšπš’πšœπšπš’πš—πšŒπš(πš…π™°π™»πš„π™΄πš‚,πšŸπšŠπš•)
πš…π™°π™»πš„π™΄πš‚.πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽβ‰₯0
πš…π™°π™»πš„π™΄πš‚.πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽβ‰€|πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚|
πš›πšŽπššπšžπš’πš›πšŽπš(π™Όπ™°πšƒπšπ™Έπš‡,[πš’,πš“,𝚌])
πš’πš—πšŒπš›πšŽπšŠπšœπš’πš—πš_𝚜𝚎𝚚(π™Όπ™°πšƒπšπ™Έπš‡,[πš’,πš“])
π™Όπ™°πšƒπšπ™Έπš‡.πš’β‰₯1
π™Όπ™°πšƒπšπ™Έπš‡.πš’β‰€|πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚|
π™Όπ™°πšƒπšπ™Έπš‡.πš“β‰₯1
π™Όπ™°πšƒπšπ™Έπš‡.πš“β‰€|πš…π™°π™»πš„π™΄πš‚|
|π™Όπ™°πšƒπšπ™Έπš‡|=|πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚|*|πš…π™°π™»πš„π™΄πš‚|
Purpose

Each value πš…π™°π™»πš„π™΄πš‚[i].πšŸπšŠπš• should be taken by exactly πš…π™°π™»πš„π™΄πš‚[i].πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ variables of the πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ collection. In addition the π™²π™Ύπš‚πšƒ of an assignment is equal to the sum of the elementary costs associated with the fact that we assign variable i of the πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ collection to the j th value of the πš…π™°π™»πš„π™΄πš‚ collection. These elementary costs are given by the π™Όπ™°πšƒπšπ™Έπš‡ collection.

Example
3,3,3,6,πšŸπšŠπš•-3πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ-3,πšŸπšŠπš•-5πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ-0,πšŸπšŠπš•-6πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ-1,πš’-1πš“-1𝚌-4,πš’-1πš“-2𝚌-1,πš’-1πš“-3𝚌-7,πš’-2πš“-1𝚌-1,πš’-2πš“-2𝚌-0,πš’-2πš“-3𝚌-8,πš’-3πš“-1𝚌-3,πš’-3πš“-2𝚌-2,πš’-3πš“-3𝚌-1,πš’-4πš“-1𝚌-0,πš’-4πš“-2𝚌-0,πš’-4πš“-3𝚌-6,14

The πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜 constraint holds since:

  • Values 3, 5 and 6 respectively occur 3, 0 and 1 times within the collection 〈3,3,3,6βŒͺ.

  • The π™²π™Ύπš‚πšƒ argument corresponds to the sum of the costs respectively associated with the first, second, third and fourth items of 〈3,3,3,6βŒͺ, namely 4, 1, 3 and 6.

All solutions

FigureΒ 5.167.1 gives all solutions to the following non ground instance of the πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜 constraint:

    V 1 ∈[3,4], V 2 ∈[2,3], V 3 ∈[1,2], V 4 ∈[2,4], V 5 ∈[2,3], V 6 ∈[1,2],

O 1 ∈[1,1], O 2 ∈[2,3], O 3 ∈[0,1], O 4 ∈[2,3],

C∈[0,16],

Β Β Β Β πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜(〈V 1 ,V 2 ,V 3 ,V 4 ,V 5 ,V 6 βŒͺ,

                                     〈1 O 1 , 2 O 2 , 3 O 3 , 4 O 4 βŒͺ,

                                     〈1 1 5, 1 2 0, 1 3 1, 1 4 1, 

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β 2 1 2, 2 2 7, 2 3 0, 2 4 2,Β 

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β 3 1 3, 3 2 3, 3 3 6, 3 4 6,Β 

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β 4 1 4, 4 2 3, 4 3 0, 4 4 0,Β 

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β 5 1 2, 5 2 0, 5 3 6, 5 4 3,Β 

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β 6 1 5, 6 2 4, 6 3 5, 6 4 4βŒͺ,C).

Figure 5.167.1. All solutions corresponding to the non ground example of the πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜 constraint of the All solutions slot
ctrs/global_cardinality_with_costs-1-tikz
Typical
|πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚|>1
πš›πšŠπš—πšπšŽ(πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚.πšŸπšŠπš›)>1
|πš…π™°π™»πš„π™΄πš‚|>1
πš›πšŠπš—πšπšŽ(πš…π™°π™»πš„π™΄πš‚.πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ)>1
πš›πšŠπš—πšπšŽ(π™Όπ™°πšƒπšπ™Έπš‡.𝚌)>1
|πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚|>|πš…π™°π™»πš„π™΄πš‚|
Arg. properties
  • Functional dependency: πš…π™°π™»πš„π™΄πš‚.πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ determined by πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚.

  • Functional dependency: π™²π™Ύπš‚πšƒ determined by πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚, πš…π™°π™»πš„π™΄πš‚ and π™Όπ™°πšƒπšπ™Έπš‡.

Usage

A classical utilisation of the πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜 constraint corresponds to the following assignment problem. We have a set of persons 𝒫 as well as a set of jobs π’₯ to perform. Each job requires a number of persons restricted to a specified interval. In addition each person p has to be assigned to one specific job taken from a subset π’₯ p of π’₯. There is a cost C pj associated with the fact that person p is assigned to job j. The previous problem is modelled with a single πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜 constraint where the persons and the jobs respectively correspond to the items of the πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ and πš…π™°π™»πš„π™΄πš‚ collection.

The πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜 constraint can also be used for modelling a conjunction πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš(πš‡ 1 ,πš‡ 2 ,β‹―,πš‡ πš— ) and Ξ± 1 Β·πš‡ 1 +Ξ± 2 Β·πš‡ 2 +β‹―+Ξ± n Β·πš‡ πš— =π™²π™Ύπš‚πšƒ. For this purpose we set the domain of the πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ variables to {0,1} and the cost attribute 𝚌 of a variable πš‡ πš’ and one of its potential value πš“ to Ξ± i Β·πš“. In practice this can be used for the magic squares and the magic hexagon problems where all the Ξ± i are set to 1.

Algorithm

A filtering algorithm achieving arc-consistency independently on each side (i.e., the greater than or equal to side and the less than or equal to side) of the πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜 constraint is described inΒ [Regin99a], [Regin02]. This algorithm assumes for each value a fixed minimum and maximum number of occurrences. If we rather have occurrence variables, the Reformulation slot explains how to also obtain some propagation from the cost variable back to the occurrence variables.

Reformulation

Let n and m respectively denote the number of items of the πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ and of the πš…π™°π™»πš„π™΄πš‚ collections. Let v 1 ,v 2 ,β‹―,v m denote the values πš…π™°π™»πš„π™΄πš‚[1].πšŸπšŠπš•,πš…π™°π™»πš„π™΄πš‚[2].πšŸπšŠπš•,β‹―,πš…π™°π™»πš„π™΄πš‚[m].πšŸπšŠπš•. In addition let 𝐿𝐼𝑁𝐸 i (with i∈[1,n]) denote the values βŒ©π™Όπ™°πšƒπšπ™Έπš‡[mΒ·(i-1)+1].𝚌,π™Όπ™°πšƒπšπ™Έπš‡[mΒ·(i-1)+2].𝚌,β‹―,π™Όπ™°πšƒπšπ™Έπš‡[mΒ·i].𝚌βŒͺ, i.e., line i of the matrix π™Όπ™°πšƒπšπ™Έπš‡.

By introducing 2Β·n auxiliary variables U 1 ,U 2 ,β‹―,U n and C 1 ,C 2 ,β‹―,C n , the πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜(πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚,πš…π™°π™»πš„π™΄πš‚,π™Όπ™°πšƒπšπ™Έπš‡,π™²π™Ύπš‚πšƒ) constraint can be expressed in term of the conjunction of one πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’(πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚,πš…π™°π™»πš„π™΄πš‚) constraint, 2Β·n πšŽπš•πšŽπš–πšŽπš—πš constraints and one arithmetic constraint πšœπšžπš–_πšŒπšπš›.

For each variable V i (with i∈[1,|πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚|]) of the πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ collection a first πšŽπš•πšŽπš–πšŽπš—πš(U i ,〈v 1 ,v 2 ,β‹―,v m βŒͺ,V i ) constraint provides the correspondence between the variable V i and the index of the value U i to which it is assigned. A second πšŽπš•πšŽπš–πšŽπš—πš(U i ,𝐿𝐼𝑁𝐸 i ,C i ) links the previous index U i to the cost C i variable associated with variable V i . Finally the total cost π™²π™Ύπš‚πšƒ is equal to the sum C 1 +C 2 +β‹―+C n .

In the context of the Example slot we get the following conjunction of constraints:

Β Β Β πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’(〈3,3,3,6βŒͺ,

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β βŒ©πšŸπšŠπš•-3 πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ-3,

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β πšŸπšŠπš•-5 πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ-0,

Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β πšŸπšŠπš•-6 πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ-1βŒͺ),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(1,〈3,5,6βŒͺ,3),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(1,〈3,5,6βŒͺ,3),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(1,〈3,5,6βŒͺ,3),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(3,〈3,5,6βŒͺ,6),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(1,〈4,1,7βŒͺ,4),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(1,〈1,0,8βŒͺ,1),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(1,〈3,2,1βŒͺ,3),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(3,〈0,0,6βŒͺ,6),

Β Β Β 14=4+1+3+6.

We now show how to add implied constraints that can also propagate from the cost variable back to the occurrence variables. Let O 1 ,O 2 ,β‹―,O m respectively denote the variables πš…π™°π™»πš„π™΄πš‚[1].πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ,πš…π™°π™»πš„π™΄πš‚[2].πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ,β‹―,πš…π™°π™»πš„π™΄πš‚[m].πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ. The idea is to get for each value v i (with i∈[1,m]) an idea of its minimum and maximum contribution in the total cost π™²π™Ύπš‚πšƒ that is linked to the number of times it is assigned to a variables of πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚. E.g.,Β if value v i (with i∈[1,m]) is used twice, then the corresponding minimum (respectively maximum) contribution in the total cost π™²π™Ύπš‚πšƒ will be at least equal to the sum of the two smallest (respectively largest) costs attached to row i. Let D i (with i∈[1,m]) denotes the contribution that stems from the variables of πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ that are assigned value v i . For each value v i (with i∈[1,m]) we create one πšŽπš•πšŽπš–πšŽπš—πš constraint for linking O i +1 to the corresponding minimum contribution πΏπ‘‚π‘Š i . The table of that πšŽπš•πšŽπš–πšŽπš—πš constraint has n+1 entries, where entry j (with j∈[0,n]) corresponds to the sum of the j π‘‘β„Ž smallest entries of row i of the cost matrix π™Όπ™°πšƒπšπ™Έπš‡. Similarly we create for each value v i (with i∈[1,m]) one πšŽπš•πšŽπš–πšŽπš—πš constraint for linking O i +1 to the corresponding maximum contribution π‘ˆπ‘ƒ i . The table of that πšŽπš•πšŽπš–πšŽπš—πš constraint also has n+1 entries, where entry j (with j∈[0,n]) corresponds to the sum of the j π‘‘β„Ž largest entries of row i of the cost matrix π™Όπ™°πšƒπšπ™Έπš‡.

In the context of the cost matrix of the Example slot we get the following conjunction of implied constraints:

Β Β Β π™²π™Ύπš‚πšƒ=D 1 +D 2 +D 3 ,

Β Β Β n=O 1 +O 2 +O 3 ,

Β Β Β P 1 =O 1 +1,

Β Β Β P 2 =O 2 +1,

Β Β Β P 3 =O 3 +1,

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(P 1 ,〈0,0,1,4,8βŒͺ,πΏπ‘‚π‘Š 1 ),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(P 2 ,〈0,0,0,1,3βŒͺ,πΏπ‘‚π‘Š 2 ),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(P 3 ,〈0,1,7,14,22βŒͺ,πΏπ‘‚π‘Š 3 ),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(P 1 ,〈0,4,7,8,8βŒͺ,π‘ˆπ‘ƒ 1 ),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(P 2 ,〈0,2,3,3,3βŒͺ,π‘ˆπ‘ƒ 2 ),

Β Β Β πšŽπš•πšŽπš–πšŽπš—πš(P 3 ,〈0,8,15,21,22βŒͺ,π‘ˆπ‘ƒ 3 ),

Β Β Β πΏπ‘‚π‘Š 1 ≀D 1 , D 1 β‰€π‘ˆπ‘ƒ 1 ,

Β Β Β πΏπ‘‚π‘Š 2 ≀D 2 , D 2 β‰€π‘ˆπ‘ƒ 2 ,

Β Β Β πΏπ‘‚π‘Š 3 ≀D 3 , D 3 β‰€π‘ˆπ‘ƒ 3 .

Systems

global_cardinality in SICStus.

See also

attached to cost variant: πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’Β (𝚌𝚘𝚜𝚝 associated with each πšŸπšŠπš›πš’πšŠπš‹πš•πšŽ,πšŸπšŠπš•πšžπšŽ pair removed).

common keyword: πš–πš’πš—πš’πš–πšžπš–_πš πšŽπš’πšπš‘πš_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πšΒ (cost filtering constraint,weighted assignment), πšœπšžπš–_𝚘𝚏_πš πšŽπš’πšπš‘πšπšœ_𝚘𝚏_πšπš’πšœπšπš’πš—πšŒπš_πšŸπšŠπš•πšžπšŽπšœ, πš πšŽπš’πšπš‘πšπšŽπš_πš™πšŠπš›πšπš’πšŠπš•_πšŠπš•πš•πšπš’πšπšΒ (weighted assignment).

implies: πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’.

Keywords

application area: assignment.

constraint arguments: pure functional dependency.

filtering: cost filtering constraint.

heuristics: regret based heuristics, regret based heuristics in matrix problems.

modelling: cost matrix, scalar product, functional dependency.

problems: weighted assignment.

puzzles: magic square, magic hexagon.

For all items of πš…π™°π™»πš„π™΄πš‚:

Arc input(s)

πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚

Arc generator
π‘†πΈπΏπΉβ†¦πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πšŸπšŠπš›πš’πšŠπš‹πš•πšŽπšœ)

Arc arity
Arc constraint(s)
πšŸπšŠπš›πš’πšŠπš‹πš•πšŽπšœ.πšŸπšŠπš›=πš…π™°π™»πš„π™΄πš‚.πšŸπšŠπš•
Graph property(ies)
𝐍𝐕𝐄𝐑𝐓𝐄𝐗=πš…π™°π™»πš„π™΄πš‚.πš—πš˜πšŒπšŒπšžπš›πš›πšŽπš—πšŒπšŽ

Arc input(s)

πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ πš…π™°π™»πš„π™΄πš‚

Arc generator
π‘ƒπ‘…π‘‚π·π‘ˆπΆπ‘‡β†¦πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πšŸπšŠπš›πš’πšŠπš‹πš•πšŽπšœ,πšŸπšŠπš•πšžπšŽπšœ)

Arc arity
Arc constraint(s)
πšŸπšŠπš›πš’πšŠπš‹πš•πšŽπšœ.πšŸπšŠπš›=πšŸπšŠπš•πšžπšŽπšœ.πšŸπšŠπš•
Graph property(ies)
π’π”πŒ_π–π„πˆπ†π‡π“_π€π‘π‚π™Όπ™°πšƒπšπ™Έπš‡βˆ‘(πšŸπšŠπš›πš’πšŠπš‹πš•πšŽπšœ.πš”πšŽπš’-1)*|πš…π™°π™»πš„π™΄πš‚|,πšŸπšŠπš•πšžπšŽπšœ.πš”πšŽπš’.𝚌=π™²π™Ύπš‚πšƒ

Graph model

The first graph constraint forces each value of the πš…π™°π™»πš„π™΄πš‚ collection to be taken by a specific number of variables of the πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ collection. It is identical to the graph constraint used in the πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’ constraint. The second graph constraint expresses that the π™²π™Ύπš‚πšƒ variable is equal to the sum of the elementary costs associated with each variable-value assignment. All these elementary costs are recorded in the π™Όπ™°πšƒπšπ™Έπš‡ collection. More precisely, the cost c ij is recorded in the attribute 𝚌 of the ((i-1)Β·|πš…π™°π™»πš„π™΄πš‚)|+j) th entry of the π™Όπ™°πšƒπšπ™Έπš‡ collection. This is ensured by the πš’πš—πšŒπš›πšŽπšŠπšœπš’πš—πš restriction that enforces the fact that the items of the π™Όπ™°πšƒπšπ™Έπš‡ collection are sorted in lexicographically increasing order according to attributes πš’ and πš“.

PartsΒ (A) andΒ (B) of FigureΒ 5.167.2 respectively show the initial and final graph associated with the second graph constraint of the Example slot.

Figure 5.167.2. Initial and final graph of the πšπš•πš˜πš‹πšŠπš•_πšŒπšŠπš›πšπš’πš—πšŠπš•πš’πšπš’_πš πš’πšπš‘_𝚌𝚘𝚜𝚝𝚜 constraint
ctrs/global_cardinality_with_costsActrs/global_cardinality_with_costsB
(a) (b)