5.103. cycle

DESCRIPTIONLINKSGRAPH
Origin

[BeldiceanuContejean94]

Constraint

πšŒπš’πšŒπš•πšŽ(π™½π™²πšˆπ™²π™»π™΄,π™½π™Ύπ™³π™΄πš‚)

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

Consider a digraph G described by the π™½π™Ύπ™³π™΄πš‚ collection. π™½π™²πšˆπ™²π™»π™΄ is equal to the number of circuits for covering G in such a way that each vertex of G belongs to a single circuit. π™½π™²πšˆπ™²π™»π™΄ can also be interpreted as the number of cycles of the permutation associated with the successor variables of the π™½π™Ύπ™³π™΄πš‚ collection.

Example
2,πš’πš—πšπšŽπš‘-1𝚜𝚞𝚌𝚌-2,πš’πš—πšπšŽπš‘-2𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-3𝚜𝚞𝚌𝚌-5,πš’πš—πšπšŽπš‘-4𝚜𝚞𝚌𝚌-3,πš’πš—πšπšŽπš‘-5𝚜𝚞𝚌𝚌-4
1,πš’πš—πšπšŽπš‘-1𝚜𝚞𝚌𝚌-2,πš’πš—πšπšŽπš‘-2𝚜𝚞𝚌𝚌-5,πš’πš—πšπšŽπš‘-3𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-4𝚜𝚞𝚌𝚌-3,πš’πš—πšπšŽπš‘-5𝚜𝚞𝚌𝚌-4
5,πš’πš—πšπšŽπš‘-1𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-2𝚜𝚞𝚌𝚌-2,πš’πš—πšπšŽπš‘-3𝚜𝚞𝚌𝚌-3,πš’πš—πšπšŽπš‘-4𝚜𝚞𝚌𝚌-4,πš’πš—πšπšŽπš‘-5𝚜𝚞𝚌𝚌-5
  • In the first example we have the following 2 (π™½π™²πšˆπ™²π™»π™΄=2) cycles: 1↦2↦1 and 3↦5↦4↦3. Consequently, the corresponding πšŒπš’πšŒπš•πšŽ constraint holds.

ctrs/cycle-1-tikz

  • In the second example we have 1 (π™½π™²πšˆπ™²π™»π™΄=1) cycle: 1↦2↦5↦4↦3↦1.

  • In the third example we have the following 5 (π™½π™²πšˆπ™²π™»π™΄=5) cycles: 1↦1, 2↦2, 3↦3, 4↦4 and 5↦5.

ctrs/cycle-2-tikz

All solutions

FigureΒ 5.103.1 gives all solutions to the following non ground instance of the πšŒπš’πšŒπš•πšŽ constraint: N∈[1,2], V 1 ∈[2,4], V 2 ∈[2,3], V 3 ∈[1,6], V 4 ∈[2,5], V 5 ∈[2,3], V 6 ∈[1,6], πšŒπš’πšŒπš•πšŽ(N,〈1 V 1 , 2 V 2 , 3 V 3 , 4 V 4 , 5 V 5 , 6 V 6 βŒͺ).

Figure 5.103.1. All solutions corresponding to the non ground example of the πšŒπš’πšŒπš•πšŽ constraint of the All solutions slot
ctrs/cycle-3-tikz
Typical
π™½π™²πšˆπ™²π™»π™΄<|π™½π™Ύπ™³π™΄πš‚|
|π™½π™Ύπ™³π™΄πš‚|>2
Symmetries
  • Items of π™½π™Ύπ™³π™΄πš‚ are permutable.

  • Attributes of π™½π™Ύπ™³π™΄πš‚ are permutable w.r.t. permutation (πš’πš—πšπšŽπš‘,𝚜𝚞𝚌𝚌) (permutation applied to all items).

Arg. properties

Functional dependency: π™½π™²πšˆπ™²π™»π™΄ determined by π™½π™Ύπ™³π™΄πš‚.

Usage

The PhD thesis of Γ‰ricΒ BourreauΒ [Bourreau99] mentions the following applications of extensions of the πšŒπš’πšŒπš•πšŽ constraint:

  • The balanced Euler knight problem where one tries to cover a rectangular chessboard of size NΒ·M by C knights that all have to visit between 2·⌊⌊(NΒ·M)/CβŒ‹/2βŒ‹ and 2·⌈⌈(NΒ·M)/CβŒ‰/2βŒ‰ distinct locations. For some values of N, M and C there does not exist any solution to the previous problem. This is for instance the case when N=M=C=6. FigureΒ 5.103.2 depicts the graph associated with the 6Γ—6 chessboard as well as examples of balanced solutions with respectively 1, 2, 3, 4 and 5 knights.

  • Some pick-up delivery problems where a fleet of vehicles has to transport a set of orders. Each order is characterised by its initial location, its final destination and its weight. In addition one also has to take into account the capacity of the different vehicles.

Figure 5.103.2. Graph of potential moves of a 6Γ—6 chessboard, corresponding balanced knight's tours with 1 up to 5 knights, and collection of nodes passed to the πšŒπš’πšŒπš•πšŽ constraint corresponding to the solution with 5 knights; note that their is no balanced knight's tour on a 6Γ—6 chessboard where each knight exactly performs 6 moves.
ctrs/cycle-4-tikz
Remark

In the original πšŒπš’πšŒπš•πšŽ constraint of CHIP the πš’πš—πšπšŽπš‘ attribute was not explicitly present. It was implicitly defined as the position of a variable in a list.

In an early version of the CHIP there was a constraint named πšŒπš’πš›πšŒπšžπš’πš that, from a declarative point of view, was equivalent to πšŒπš’πšŒπš•πšŽ(1,π™½π™Ύπ™³π™΄πš‚). In ALICE [Lauriere78] the πšŒπš’πš›πšŒπšžπš’πš constraint was also present.

Given a complete digraph of n vertices as well as an unrestricted number of circuits π™½π™²πšˆπ™²π™»π™΄, the total number of solutions to the corresponding πšŒπš’πšŒπš•πšŽ constraint corresponds to the sequence A000142 of the On-Line Encyclopaedia of Integer SequencesΒ [Sloane10]. Given a complete digraph of n vertices as well as a fixed number of circuits π™½π™²πšˆπ™²π™»π™΄ between 1 and n, the total number of solutions to the corresponding πšŒπš’πšŒπš•πšŽ constraint corresponds to the so called Stirling number of first kind.

Algorithm

Since all 𝚜𝚞𝚌𝚌 variables have to take distinct values one can reuse the algorithms associated with the πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš constraint. A second necessary condition is to have no more than π™½π™²πšˆπ™²π™»π™΄ Β― strongly connected components. Pruning for enforcing this condition, as soon as we have π™½π™²πšˆπ™²π™»π™΄ Β― strongly connected components, can be done by forcing all strong bridges to belong to the final solution, since otherwise we would have more than π™½π™²πšˆπ™²π™»π™΄ Β― strongly connected components. Since all the vertices of a circuit belong to the same strongly connected component an arc going from one strongly connected component to another strongly connected component has to be removed.

Reformulation

Let n and s 1 ,s 2 ,β‹―,s n respectively denotes the number of vertices (i.e., |π™½π™Ύπ™³π™΄πš‚|) and the successor variables associated with vertices 1,2,β‹―,n. The πšŒπš’πšŒπš•πšŽ constraint can be reformulated as a conjunction of one πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš constraint, nΒ·(n-1) πšŽπš•πšŽπš–πšŽπš—πš constraints, n πš–πš’πš—πš’πš–πšžπš– constraints, and one πš—πšŸπšŠπš•πšžπšŽ constraint.

ctrs/cycle-5-tikz

Counting
Length (n)2345678910
Solutions26241207205040403203628803628800

Number of solutions for πšŒπš’πšŒπš•πšŽ: domains 0..n

ctrs/cycle-6-tikz

ctrs/cycle-7-tikz

Length (n)2345678910
Total26241207205040403203628803628800
Parameter
value

112624120720504040320362880
21311502741764130681095841026576
3-16352251624131321181241172700
4--11085735676967284723680
5---115175196022449269325
6----121322453663273
7-----1285469450
8------136870
9-------145
10--------1

Solution count for πšŒπš’πšŒπš•πšŽ: domains 0..n

ctrs/cycle-8-tikz

ctrs/cycle-9-tikz

See also

common keyword: πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πšΒ (permutation),

πšŒπš’πš›πšŒπšžπš’πš_πšŒπš•πšžπšœπšπšŽπš›Β (graph constraint, one_succ),

πšŒπš’πšŒπš•πšŽ_πšŒπšŠπš›πš_πš˜πš—_πš™πšŠπšπš‘Β (permutation,graph partitioning constraint),

πšŒπš’πšŒπš•πšŽ_πš˜πš›_πšŠπšŒπšŒπšŽπšœπšœπš’πš‹πš’πš•πš’πšπš’Β (graph constraint),

πšŒπš’πšŒπš•πšŽ_πš›πšŽπšœπš˜πšžπš›πšŒπšŽΒ (graph partitioning constraint),

πšπšŽπš›πšŠπš—πšπšŽπš–πšŽπš—πšΒ (permutation),

πšπš›πšŠπš™πš‘_πšŒπš›πš˜πšœπšœπš’πš—πšΒ (graph constraint,graph partitioning constraint),

πš’πš—πšŸπšŽπš›πšœπšŽΒ (permutation),

πš–πšŠπš™Β (graph partitioning constraint),

πšœπš’πš–πš–πšŽπšπš›πš’πšŒ_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πšΒ (permutation),

πšπš˜πšžπš›Β (graph constraint),

πšπš›πšŽπšŽΒ (graph partitioning constraint).

implies: πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš.

implies (items to collection): πšŠπšπš•πšŽπšŠπšœπš_πš—πšŸπšŽπšŒπšπš˜πš›.

related: πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšŒπš’πšŒπš•πšŽΒ (counting number of cycles versus controlling how balanced the cycles are).

specialisation: πšŒπš’πš›πšŒπšžπš’πšΒ (π™½π™²πšˆπ™²π™»π™΄ set to 1).

used in reformulation: πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš, πšŽπš•πšŽπš–πšŽπš—πš, πš–πš’πš—πš’πš–πšžπš–, πš—πšŸπšŠπš•πšžπšŽ.

Keywords

characteristic of a constraint: core.

combinatorial object: permutation.

constraint arguments: business rules.

constraint type: graph constraint, graph partitioning constraint.

filtering: strong bridge, DFS-bottleneck.

final graph structure: circuit, connected component, strongly connected component, one_succ.

modelling: cycle, functional dependency.

problems: pick-up delivery.

puzzles: Euler knight.

Cond. implications

β€’ πšŒπš’πšŒπš•πšŽ(π™½π™²πšˆπ™²π™»π™΄,π™½π™Ύπ™³π™΄πš‚)

Β Β Β  withΒ  π™½π™²πšˆπ™²π™»π™΄=1

Β Β implies πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšŒπš’πšŒπš•πšŽ(𝙱𝙰𝙻𝙰𝙽𝙲𝙴,π™½π™Ύπ™³π™΄πš‚)

Β Β Β  whenΒ  𝙱𝙰𝙻𝙰𝙽𝙲𝙴=0.

β€’ πšŒπš’πšŒπš•πšŽ(π™½π™²πšˆπ™²π™»π™΄,π™½π™Ύπ™³π™΄πš‚)

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

Arc input(s)

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

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

Arc arity
Arc constraint(s)
πš—πš˜πšπšŽπšœ1.𝚜𝚞𝚌𝚌=πš—πš˜πšπšŽπšœ2.πš’πš—πšπšŽπš‘
Graph property(ies)
β€’ 𝐍𝐓𝐑𝐄𝐄=0
β€’ 𝐍𝐂𝐂=π™½π™²πšˆπ™²π™»π™΄

Graph class
𝙾𝙽𝙴_πš‚πš„π™²π™²

Graph model

From the restrictions and from the arc constraint, we deduce that we have a bijection from the successor variables to the values of interval [1,|π™½π™Ύπ™³π™΄πš‚|]. With no explicit restrictions it would have been impossible to derive this property.

In order to express the binary constraint that links two vertices one has to make explicit the identifier of the vertices. This is why the πšŒπš’πšŒπš•πšŽ constraint considers objects that have two attributes:

  • One fixed attribute πš’πš—πšπšŽπš‘ that is the identifier of the vertex,

  • One variable attribute 𝚜𝚞𝚌𝚌 that is the successor of the vertex.

The graph property 𝐍𝐓𝐑𝐄𝐄 = 0 is used in order to avoid having vertices that both do not belong to a circuit and have at least one successor located on a circuit. This concretely means that all vertices of the final graph should belong to a circuit.

PartsΒ (A) andΒ (B) of FigureΒ 5.103.3 respectively show the initial and final graph associated with the first example of the Example slot. Since we use the 𝐍𝐂𝐂 graph property, we show the two connected components of the final graph. The constraint holds since all the vertices belong to a circuit (i.e., 𝐍𝐓𝐑𝐄𝐄 = 0) and since π™½π™²πšˆπ™²π™»π™΄ = 𝐍𝐂𝐂 = 2.

Figure 5.103.3. Initial and final graph of the πšŒπš’πšŒπš•πšŽ constraint
ctrs/cycleActrs/cycleB
(a) (b)
Quiz

Β Β 

πšŒπš’πšŒπš•πšŽ: checking whether a ground instance holds or not ctrs/cycle-10-tikz Β 

πšŒπš’πšŒπš•πšŽ: finding all solutions ctrs/cycle-11-tikz Β 

πšŒπš’πšŒπš•πšŽ: identifying infeasible values ctrs/cycle-12-tikz Β 

πšŒπš’πšŒπš•πšŽ: variable-based degree of violation ctrs/cycle-13-tikz Β 

πšŒπš’πšŒπš•πšŽ: DeΒ Bruijn sequence ctrs/cycle-14-tikz Β 

ctrs/cycle-15-tikz Β 

ctrs/cycle-16-tikz Β 

ctrs/cycle-17-tikz Β 

ctrs/cycle-18-tikz Β 

ctrs/cycle-19-tikz