5.397. symmetric_alldifferent_loop

DESCRIPTIONLINKSGRAPH
Origin

Derived from πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš

Constraint

πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™(π™½π™Ύπ™³π™΄πš‚)

Synonyms

πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπš_πš•πš˜πš˜πš™, πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšœπšπš’πš—πšŒπš_πš•πš˜πš˜πš™, πšœπš’πš–πš–_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™, πšœπš’πš–πš–_πšŠπš•πš•πšπš’πšπš_πš•πš˜πš˜πš™, πšœπš’πš–πš–_πšŠπš•πš•πšπš’πšœπšπš’πš—πšŒπš_πš•πš˜πš˜πš™.

Argument
π™½π™Ύπ™³π™΄πš‚πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš’πš—πšπšŽπš‘-πš’πš—πš,𝚜𝚞𝚌𝚌-πšπšŸπšŠπš›)
Restrictions
πš›πšŽπššπšžπš’πš›πšŽπš(π™½π™Ύπ™³π™΄πš‚,[πš’πš—πšπšŽπš‘,𝚜𝚞𝚌𝚌])
π™½π™Ύπ™³π™΄πš‚.πš’πš—πšπšŽπš‘β‰₯1
π™½π™Ύπ™³π™΄πš‚.πš’πš—πšπšŽπš‘β‰€|π™½π™Ύπ™³π™΄πš‚|
πšπš’πšœπšπš’πš—πšŒπš(π™½π™Ύπ™³π™΄πš‚,πš’πš—πšπšŽπš‘)
π™½π™Ύπ™³π™΄πš‚.𝚜𝚞𝚌𝚌β‰₯1
π™½π™Ύπ™³π™΄πš‚.πšœπšžπšŒπšŒβ‰€|π™½π™Ύπ™³π™΄πš‚|
Purpose

All variables associated with the 𝚜𝚞𝚌𝚌 attribute of the π™½π™Ύπ™³π™΄πš‚ collection should be pairwise distinct. In addition enforce the following condition: if variable π™½π™Ύπ™³π™΄πš‚[i].𝚜𝚞𝚌𝚌 is assigned value j then variable π™½π™Ύπ™³π™΄πš‚[j].𝚜𝚞𝚌𝚌 is assigned value i. Note that i and j are not necessarily distinct. This can be interpreted as a graph-covering problem where one has to cover a digraph G with circuits of length two or one in such a way that each vertex of G belongs to a single circuit.

Example
πš’πš—πšπšŽπš‘-1𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-2𝚜𝚞𝚌𝚌-4,πš’πš—πšπšŽπš‘-3𝚜𝚞𝚌𝚌-3,πš’πš—πšπšŽπš‘-4𝚜𝚞𝚌𝚌-2

The πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™ constraint holds since:

  • We have two loops respectively corresponding to π™½π™Ύπ™³π™΄πš‚[1].𝚜𝚞𝚌𝚌=1 and π™½π™Ύπ™³π™΄πš‚[3].𝚜𝚞𝚌𝚌=3.

  • We have one circuit of length 2 corresponding to π™½π™Ύπ™³π™΄πš‚[2].𝚜𝚞𝚌𝚌=4β‡”π™½π™Ύπ™³π™΄πš‚[4].𝚜𝚞𝚌𝚌=2.

FigureΒ 5.397.1 provides a second example involving a πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™ constraint.

Figure 5.397.1. (A)Β Magic square Duerer where cells that belong to a same cycle are coloured identically by a colour different from grey; each cell has an index in its upper left corner (in red) and a value (in blue). (B)Β Corresponding graph where there is an arc from node i to node j if and only if the value of cell i is equal to the index of cell j. (C)Β Collection of nodes passed to the πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™ constraint: the four self-loops of the graph correspond to the four grey cells of the magic square such that the value of the cell (in blue) is equal to the index of the cell (in red).
ctrs/symmetric_alldifferent_loop-1-tikz
All solutions

FigureΒ 5.397.2 gives all solutions to the following non ground instance of the πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™ constraint: S 1 ∈[2,5], S 2 ∈[1,3], S 3 ∈[1,4], S 4 ∈[2,4], S 5 ∈[1,5], πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™(〈1 S 1 ,2 S 2 ,3 S 3 ,4 S 4 ,5 S 5 βŒͺ).

Figure 5.397.2. All solutions corresponding to the non ground example of the πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™ constraint of the All solutions slot; the πš’πš—πšπšŽπš‘ attribute is displayed as indices of the 𝚜𝚞𝚌𝚌 attribute and self loops are coloured in red.
ctrs/symmetric_alldifferent_loop-2-tikz
Typical
|π™½π™Ύπ™³π™΄πš‚|β‰₯4
Symmetry

Items of π™½π™Ύπ™³π™΄πš‚ are permutable.

Algorithm

An arc-consistency filtering algorithm for the πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™ constraint is described inΒ [Cymer13], [CymerPhD13]. The algorithm is based on the following ideas:

  • First, one can map solutions of the πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™ constraint to perfect (g,f)-matchings in a non-bipartite graph derived from the domain of the variables of the constraint where g(x)=0, f(x)=1 for vertices x which have a self-loop, and g(x)=f(x)=1 for all the remaining vertices. A perfect (g,f)-matching β„³ of a graph is a subset of edges such that every vertex x is incident with the number of edges in β„³ between g(x) and f(x).

  • Second, Gallai-Edmonds decompositionΒ [Gallai63], [Edmonds65] allows to find out all edges that do not belong any perfect (g,f)-matchings, and therefore prune the corresponding variables.

Counting
Length (n)2345678910
Solutions2410267623276426209496

Number of solutions for πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™: domains 0..n

ctrs/symmetric_alldifferent_loop-3-tikz

ctrs/symmetric_alldifferent_loop-4-tikz

See also

implied by: πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš.

implies: πšπš πš’πš—.

implies (items to collection): πš•πšŽπš‘_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš.

Keywords

characteristic of a constraint: all different, disequality.

combinatorial object: permutation, involution, matching.

constraint type: graph constraint, graph partitioning constraint.

final graph structure: circuit.

modelling: cycle.

Cond. implications

πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™(π™½π™Ύπ™³π™΄πš‚)

Β Β implies πš™πšŽπš›πš–πšžπšπšŠπšπš’πš˜πš—(πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚:π™½π™Ύπ™³π™΄πš‚).

Arc input(s)

π™½π™Ύπ™³π™΄πš‚

Arc generator
πΆπΏπΌπ‘„π‘ˆπΈβ†¦πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš—πš˜πšπšŽπšœ1,πš—πš˜πšπšŽπšœ2)

Arc arity
Arc constraint(s)
β€’ πš—πš˜πšπšŽπšœ1.𝚜𝚞𝚌𝚌=πš—πš˜πšπšŽπšœ2.πš’πš—πšπšŽπš‘
β€’ πš—πš˜πšπšŽπšœ2.𝚜𝚞𝚌𝚌=πš—πš˜πšπšŽπšœ1.πš’πš—πšπšŽπš‘
Graph property(ies)
𝐍𝐀𝐑𝐂=|π™½π™Ύπ™³π™΄πš‚|

Graph model

In order to express the binary constraint that links two vertices one has to make explicit the identifier of the vertices.

PartsΒ (A) andΒ (B) of FigureΒ 5.397.3 respectively show the initial and final graph associated with the Example slot. Since we use the 𝐍𝐀𝐑𝐂 graph property, the arcs of the final graph are stressed in bold.

Figure 5.397.3. Initial and final graph of the πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš•πš˜πš˜πš™ constraint
ctrs/symmetric_alldifferent_loopActrs/symmetric_alldifferent_loopB
(a) (b)
Signature

Since all the πš’πš—πšπšŽπš‘ attributes of the π™½π™Ύπ™³π™΄πš‚ collection are distinct, and because of the first condition πš—πš˜πšπšŽπšœ1.𝚜𝚞𝚌𝚌=πš—πš˜πšπšŽπšœ2.πš’πš—πšπšŽπš‘ of the arc constraint, each vertex of the final graph has at most one successor. Therefore the maximum number of arcs of the final graph is equal to the maximum number of vertices |π™½π™Ύπ™³π™΄πš‚| of the final graph. So we can rewrite 𝐍𝐀𝐑𝐂=|π™½π™Ύπ™³π™΄πš‚| to 𝐍𝐀𝐑𝐂β‰₯|π™½π™Ύπ™³π™΄πš‚| and simplify 𝐍𝐀𝐑𝐂 Β― Μ² to 𝐍𝐀𝐑𝐂 Β―.