5.44. balance_cycle

DESCRIPTIONLINKSGRAPH
Origin

derived from πš‹πšŠπš•πšŠπš—πšŒπšŽ and πšŒπš’πšŒπš•πšŽ

Constraint

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

Arguments
π™±π™°π™»π™°π™½π™²π™΄πšπšŸπšŠπš›
π™½π™Ύπ™³π™΄πš‚πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš’πš—πšπšŽπš‘-πš’πš—πš,𝚜𝚞𝚌𝚌-πšπšŸπšŠπš›)
Restrictions
𝙱𝙰𝙻𝙰𝙽𝙲𝙴β‰₯0
π™±π™°π™»π™°π™½π™²π™΄β‰€πš–πšŠπš‘(0,|π™½π™Ύπ™³π™΄πš‚|-2)
πš›πšŽπššπšžπš’πš›πšŽπš(π™½π™Ύπ™³π™΄πš‚,[πš’πš—πšπšŽπš‘,𝚜𝚞𝚌𝚌])
π™½π™Ύπ™³π™΄πš‚.πš’πš—πšπšŽπš‘β‰₯1
π™½π™Ύπ™³π™΄πš‚.πš’πš—πšπšŽπš‘β‰€|π™½π™Ύπ™³π™΄πš‚|
πšπš’πšœπšπš’πš—πšŒπš(π™½π™Ύπ™³π™΄πš‚,πš’πš—πšπšŽπš‘)
π™½π™Ύπ™³π™΄πš‚.𝚜𝚞𝚌𝚌β‰₯1
π™½π™Ύπ™³π™΄πš‚.πšœπšžπšŒπšŒβ‰€|π™½π™Ύπ™³π™΄πš‚|
Purpose

Consider a digraph G described by the π™½π™Ύπ™³π™΄πš‚ collection. Partition G into a set of vertex disjoint circuits in such a way that each vertex of G belongs to a single circuit. 𝙱𝙰𝙻𝙰𝙽𝙲𝙴 is equal to the difference between the number of vertices of the largest circuit and the number of vertices of the smallest circuit.

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

In the first example we have the following two circuits: 1β†’2β†’1 and 3β†’5β†’4β†’3. Since 𝙱𝙰𝙻𝙰𝙽𝙲𝙴=1 is the difference between the number of vertices of the largest circuit (i.e.,Β 3) and the number of vertices of the smallest circuit (i.e.,Β 2) the corresponding πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšŒπš’πšŒπš•πšŽ constraint holds.

All solutions

FigureΒ 5.44.1 gives all solutions to the following non ground instance of the πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšŒπš’πšŒπš•πšŽ constraint: π™±π™°π™»π™°π™½π™²π™΄βˆˆ[0,1], S 1 ∈[1,2], S 2 ∈[1,3], S 3 ∈[3,5], S 4 ∈[3,4], S 5 ∈[2,5], πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšŒπš’πšŒπš•πšŽ(𝙱𝙰𝙻𝙰𝙽𝙲𝙴,〈1 S 1 ,2 S 2 ,3 S 3 ,4 S 4 ,5 S 5 βŒͺ).

Figure 5.44.1. 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 all vertices of a same cycle are coloured by the same colour.
ctrs/balance_cycle-1-tikz
Typical
|π™½π™Ύπ™³π™΄πš‚|>2
Symmetry

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

Arg. properties

Functional dependency: 𝙱𝙰𝙻𝙰𝙽𝙲𝙴 determined by π™½π™Ύπ™³π™΄πš‚.

Counting
Length (n)2345678910
Solutions26241207205040403203628803628800

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

ctrs/balance_cycle-2-tikz

ctrs/balance_cycle-3-tikz

Length (n)2345678910
Total26241207205040403203628803628800
Parameter
value

0231025176721640642561436402
1-36456086117782328384150
2--820250770798038808363680
3---30901344630075348456120
4----144504873645360708048
5-----840336066240378000
6------576025920572400
7-------45360226800
8--------403200

Solution count for πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšŒπš’πšŒπš•πšŽ: domains 0..n

ctrs/balance_cycle-4-tikz

ctrs/balance_cycle-5-tikz

See also

related: πš‹πšŠπš•πšŠπš—πšŒπšŽΒ (equivalence classes correspond to vertices in same cycle rather than variables assigned to the same value), πšŒπš’πšŒπš•πšŽΒ (do not care how many cycles but how balanced the cycles are).

Keywords

combinatorial object: permutation.

constraint type: graph constraint, graph partitioning constraint.

filtering: DFS-bottleneck.

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

modelling: cycle, functional dependency.

Cond. implications

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

Β Β Β  withΒ  𝙱𝙰𝙻𝙰𝙽𝙲𝙴>0

Β Β Β  andΒ Β  𝙱𝙰𝙻𝙰𝙽𝙲𝙴≀2

Β Β implies πšŠπš•πš•_πšπš’πšπšπšŽπš›_πšπš›πš˜πš–_𝚊𝚝_πš•πšŽπšŠπšœπš_πš”_πš™πš˜πšœ(𝙺:𝙱𝙰𝙻𝙰𝙽𝙲𝙴,πš…π™΄π™²πšƒπ™Ύπšπš‚:π™½π™Ύπ™³π™΄πš‚).

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

Β Β 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.44.2 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 connected components of the final graph. The constraint holds since all the vertices belong to a circuit (i.e., 𝐍𝐓𝐑𝐄𝐄 = 0) and since 𝙱𝙰𝙻𝙰𝙽𝙲𝙴 = 𝐑𝐀𝐍𝐆𝐄_𝐍𝐂𝐂 = 1.

Figure 5.44.2. Initial and final graph of the πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšŒπš’πšŒπš•πšŽ constraint
ctrs/balance_cycleActrs/balance_cycleB
(a) (b)