5.360. soft_alldifferent_var

DESCRIPTIONLINKSGRAPH
Origin

[PetitReginBessiere01]

Constraint

𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πšŸπšŠπš›(𝙲,πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚)

Synonyms

𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπš_πšŸπšŠπš›, 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšœπšπš’πš—πšŒπš_πšŸπšŠπš›, 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπš_πš–πš’πš—_πšŸπšŠπš›, 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš–πš’πš—_πšŸπšŠπš›, 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšœπšπš’πš—πšŒπš_πš–πš’πš—_πšŸπšŠπš›.

Arguments
π™²πšπšŸπšŠπš›
πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πšŸπšŠπš›-πšπšŸπšŠπš›)
Restrictions
𝙲β‰₯0
πš›πšŽπššπšžπš’πš›πšŽπš(πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚,πšŸπšŠπš›)
Purpose

𝙲 is greater than or equal to the minimum number of variables of the collection πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ for which the value needs to be changed in order that all variables of πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ take a distinct value.

Example
(3,5,1,9,1,5,5)
(1,5,1,9,6,5,3)
(0,8,1,9,6,5,3)

Within the collection 〈5,1,9,1,5,5βŒͺ of the first example, 3 and 2 items are respectively fixed to values 5 and 1. Therefore one must change the values of at least (3-1)+(2-1)=3 items to get back to 6 distinct values. Consequently, the corresponding 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πšŸπšŠπš› constraint holds since its first argument 𝙲 is greater than or equal to 3.

Typical
𝙲>0
2*𝙲≀|πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚|
|πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚|>1
πšœπš˜πš–πšŽ_πšŽπššπšžπšŠπš•(πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚)
Symmetries
  • 𝙲 can be increased.

  • Items of πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚ are permutable.

  • All occurrences of two distinct values of πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚.πšŸπšŠπš› can be swapped; all occurrences of a value of πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚.πšŸπšŠπš› can be renamed to any unused value.

Arg. properties

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

Usage

A soft πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš constraint.

Remark

Since it focus on the soft aspect of the πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš constraint, the original articleΒ [PetitReginBessiere01], which introduce this constraint, describes how to evaluate the minimum value of 𝙲 and how to prune according to the maximum value of 𝙲.

The 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πšŸπšŠπš› constraint is called 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπš_πš–πš’πš—_πšŸπšŠπš› inΒ [HebrardMarxSullivanRazgon09].

Algorithm

A first filtering algorithm presented inΒ [PetitReginBessiere01] achieves arc-consistency. A second filtering algorithm also achieving arc-consistency is described inΒ [Cymer12], [CymerPhD13].

Reformulation

By introducing a variable M that gives the number of distinct values used by variables of the collection πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚, the 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πšŸπšŠπš›(𝙲,πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚) constraint can be expressed as a conjunction of the πš—πšŸπšŠπš•πšžπšŽ(M,πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚) constraint and of the linear constraint 𝙲β‰₯|πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚|-M.

Counting
Length (n)2345678
Solutions2421224703568261460012286024279472266

Number of solutions for 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πšŸπšŠπš›: domains 0..n

ctrs/soft_alldifferent_var-1-tikz

ctrs/soft_alldifferent_var-2-tikz

Length (n)2345678
Total2421224703568261460012286024279472266
Parameter
value

0624120720504040320362880
19604804320428404636805443200
2964620732097440140448021530880
3-646257770116340199248037406880
4--6257776117642209361642550704
5---7776117649209714443037568
6----117649209715243046712
7-----209715243046721
8------43046721

Solution count for 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πšŸπšŠπš›: domains 0..n

ctrs/soft_alldifferent_var-3-tikz

ctrs/soft_alldifferent_var-4-tikz

See also

common keyword: 𝚜𝚘𝚏𝚝_πšŠπš•πš•_πšŽπššπšžπšŠπš•_πš–πšŠπš‘_πšŸπšŠπš›, 𝚜𝚘𝚏𝚝_πšŠπš•πš•_πšŽπššπšžπšŠπš•_πš–πš’πš—_πšŒπšπš›, 𝚜𝚘𝚏𝚝_πšŠπš•πš•_πšŽπššπšžπšŠπš•_πš–πš’πš—_πšŸπšŠπš›, 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πšŒπšπš›, πš πšŽπš’πšπš‘πšπšŽπš_πš™πšŠπš›πšπš’πšŠπš•_πšŠπš•πš•πšπš’πšπšΒ (soft constraint).

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

implied by: πšŠπš•πš•_πš–πš’πš—_πšπš’πšœπš, πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πš–πš˜πšπšžπš•πš˜, 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πšŒπšπš›.

related: πšŠπšπš–πš˜πšœπš_πš—πšŸπšŠπš•πšžπšŽ, πš—πšŸπšŠπš•πšžπšŽ.

Keywords

characteristic of a constraint: all different, disequality.

constraint type: soft constraint, value constraint, relaxation, variable-based violation measure.

filtering: bipartite matching.

final graph structure: strongly connected component, equivalence.

Arc input(s)

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

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

Arc arity
Arc constraint(s)
πšŸπšŠπš›πš’πšŠπš‹πš•πšŽπšœ1.πšŸπšŠπš›=πšŸπšŠπš›πš’πšŠπš‹πš•πšŽπšœ2.πšŸπšŠπš›
Graph property(ies)
𝐍𝐒𝐂𝐂β‰₯|πš…π™°πšπ™Έπ™°π™±π™»π™΄πš‚|-𝙲

Graph model

We generate a clique with binary equalities constraints between each pairs of vertices (this include an arc between a vertex and itself) and we state that 𝙲 is equal to the difference between the total number of variables and the number of strongly connected components.

PartsΒ (A) andΒ (B) of FigureΒ 5.360.1 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 different strongly connected components of the final graph. Each strongly connected component of the final graph includes all variables that take the same value. Since we have 6 variables and 3 strongly connected components the cost variable 𝙲 is greater than or equal to 6-3.

Figure 5.360.1. Initial and final graph of the 𝚜𝚘𝚏𝚝_πšŠπš•πš•πšπš’πšπšπšŽπš›πšŽπš—πš_πšŸπšŠπš› constraint
ctrs/soft_alldifferent_varActrs/soft_alldifferent_varB
(a) (b)