5.334. same
DESCRIPTION | LINKS | GRAPH | AUTOMATON |
- Origin
N.Β Beldiceanu
- Constraint
- Arguments
- Restrictions
- Purpose
The variables of the collection correspond to the variables of the collection according to a permutation.
- Example
-
The constraint holds since values 1, 2, 5 and 9 have the same number of occurrences within both collections and . FigureΒ 5.334.1 illustrates this correspondence.
Figure 5.334.1. Illustration of the correspondence between the items of the and of the collections of the Example slot
- All solutions
FigureΒ 5.334.2 gives all solutions to the following non ground instance of the constraint: , , , , , , .
Figure 5.334.2. All solutions corresponding to the non ground example of the constraint of the All solutions slot where identical values are coloured in the same way in both collections
- Typical
- Symmetries
Arguments are permutable w.r.t. permutation .
Items of are permutable.
Items of are permutable.
All occurrences of two distinct values in or can be swapped; all occurrences of a value in or can be renamed to any unused value.
- Arg. properties
Aggregate: , .
- Usage
The constraint can be used in the following contexts:
Pairing problems taken fromΒ [BeldiceanuKatrielThiel04b]. The organisation Doctors Without Borders has a list of doctors and a list of nurses, each of whom volunteered to go on one mission in the next year. Each volunteer specifies a list of possible dates and each mission involves one doctor and one nurse. The task is to produce a list of pairs such that each pair includes a doctor and a nurse who are available at the same date and each volunteer appears in exactly one pair. The problem is modelled by a constraint where each doctor is represented by a domain variable in and each nurse by a domain variable in . For a given doctor or nurse the corresponding domain variable gives the dates when the person is available. When the number of nurses is different from the number of doctors we replace the constraint by a constraint.
Timetabling problems where we wish to produce fair schedules for different persons is a second use of the constraint. Assume we need to generate a plan over a period of consecutive days for persons. For each day and each person we need to decide whether person works in the morning shift, in the afternoon shift, in the night shift or does not work at all on day . In a fair schedule, the number of morning shifts should be the same for all the persons. The same condition holds for the afternoon and the night shifts as well as for the days off. We create for each person the sequence of variables . is equal to one of and 3, depending on whether person does not work, works in the morning, in the afternoon or during the night on day . We can use constraints to express the fact that should be a permutation of for each .
The constraint can also be used as a channelling constraint for modelling the following recurring pattern: given the number of 1s in each line and each column of a 0-1 matrix with rows and columns, reconstruct the matrix. This pattern usually occurs with additional constraints about compatible positions of the 1s, or about the overall shape reconstructed from all the 1's (e.g.,Β convexity, connectivity). If we restrict ourselves to the basic pattern there is an algorithm for reconstructing a matrix from its horizontal and vertical directionsΒ [Gale57]. We show how to model this pattern with the constraint. Let and denote respectively, the required number of 1s in the row and the column of . We number the entries of the matrix as shown in the left-hand side ofΒ 5.334.3. For row we create domain variables where . Similarly, for each column we create domain variables where . The domain of each variable contains the set of entries that belong to the row or column that the variable corresponds to. Thus, each domain variable represents a 1 that appears in the designated row or column. Let be the set of variables corresponding to rows and be the set of variables corresponding to columns. To make sure that each 1 is placed in a different entry, we impose the constraint . In addition, the constraint enforces that the 1s exactly coincide on the rows and the columns. A solution is shown on the right-hand side ofΒ 5.334.3. Note that the constraint allows to model the matrix reconstruction problem without the additional constraint.
Figure 5.334.3. Modelling the 0-1 matrix reconstruction problem with the constraint (variable corresponds to the position of value 1 in the first row, variables , , correspond to the position of value 1 in the second row, and variables , , , respectively to the positions of value 1 in the first, second, third and fourth columns)
- Remark
The constraint is a relaxed version of the constraint introduced inΒ [OlderSwinkelsEmden95]. We do not enforce the second collection of variables to be sorted in increasing order.
If we interpret the collections and as two multisets variablesΒ [KiziltanWalsh02], the constraint can be considered as an equality constraint between two multisets variables.
The constraint can be modelled by two constraints. For instance, the constraint
where the union of the domains of the different variables is corresponds to the conjunction of the following two constraints:
As shown by the next example, the consistency for all variables of the two constraints does not implies consistency for the corresponding constraint. This is for instance the case when the domains of , , and is respectively equal to , , and . The conjunction of the two constraints does not remove values 3 and 4 from .
In his PhD thesis, W.-J.Β vanΒ Hoeve introduces a soft version of the constraint where the cost is the minimum number of variables to assign differently in order to get back to a solutionΒ [vanHoeve05]. In the context of the constraint this violation cost corresponds to the difference between the number of variables in and the number of values that both occur in and in (provided that one value of matches at most one value of ).
- Algorithm
InΒ [BeldiceanuKatrielThiel04a], [BeldiceanuKatrielThiel04b], [BeldiceanuKatrielThiel05], [Katriel05], it is shown how to model this constraint by a flow network that enables to compute arc-consistency and bound-consistency. The rightmost part of FigureΒ 3.7.30 illustrates this flow model. Unlike the networks used for and , the network now has three sets of nodes, so the algorithms are more complex, in particular the efficient bound-consistency algorithm.
More recentlyΒ [Cymer12], [CymerPhD13] presents a second filtering algorithm also achieving arc-consistency based on a mapping of the solutions to the constraint to perfect matchings in a bipartite intersection graph derived from the domain of the variables of the constraint in the following way. To each variable of the and collection corresponds a vertex of the intersection graph. There is an edge between a vertex associated with a variable of the collection and a vertex associated with a variable of the collection if and only if the corresponding variables have at least one value in common in their domains.
- Reformulation
- Used in
- See also
generalisation: Β ( parameter added), Β ( replaced by ), Β ( replaced by ), Β ( replaced by ).
implied by: , , , .
implies: , .
related to a common problem: Β (matrix reconstruction problem).
- Keywords
characteristic of a constraint: sort based reformulation, automaton, automaton with array of counters.
combinatorial object: permutation, multiset.
constraint arguments: constraint between two collections of variables.
filtering: bipartite matching, flow, arc-consistency, bound-consistency, DFS-bottleneck.
modelling: channelling constraint, equality between multisets.
- Arc input(s)
- Arc generator
-
- Arc arity
- Arc constraint(s)
- Graph property(ies)
-
- Graph model
PartsΒ (A) andΒ (B) of FigureΒ 5.334.4 respectively show the initial and final graph associated with the Example slot. Since we use the and graph properties, the source and sink vertices of the final graph are stressed with a double circle. Since there is a constraint on each connected component of the final graph we also show the different connected components. Each of them corresponds to an equivalence class according to the arc constraint. The constraint holds since:
Each connected component of the final graph has the same number of sources and of sinks.
The number of sources of the final graph is equal to .
The number of sinks of the final graph is equal to .
Figure 5.334.4. Initial and final graph of the constraint
(a) (b) - Signature
Since the initial graph contains only sources and sinks, and since isolated vertices are eliminated from the final graph, we make the following observations:
Sources of the initial graph cannot become sinks of the final graph,
Sinks of the initial graph cannot become sources of the final graph.
From the previous observations and since we use the arc generator on the collections and , we have that the maximum number of sources and sinks of the final graph is respectively equal to and . Therefore we can rewrite to and simplify to . In a similar way, we can rewrite to and simplify to .
- Automaton
To each item of the collection corresponds a signature variable that is equal to 0. To each item of the collection corresponds a signature variable that is equal to 1.
Figure 5.334.5. Automaton of the constraint