Title: Case study 5: all interval series
1Case study 5 all interval series
- Results due to Simonis, Puget Regin
2All interval series
- Prob007 at www.csplib.org
- Comes from musical composition
- Traced back to Alban Berg
- Extensively used by Ernst Krenek
- Op.170 Quaestio temporis
3All interval series
- Take the 12 standard pitch classes
- c, c, d, ..
- Represent them by numbers 0, .., 11
- Find a sequence so each occurs once
- Each difference occurs once
4All interval series
- Can generalize to any n (not just 12)
- Find Sn, a permutation of 0,n)
- such that Sn1-Sn are all distinct
- Finding one solution is easy
5All interval series
- Can generalize to any n (not just 12)
- Find Sn, a permutation of 0,n) such that
Sn1-Sn are all distinct - Finding one solution is easy
- n,1,n-1,2,n-2,.., floor(n/2)2,floor(n/2)-1,flo
or(n/2)1,floor(n/2) - Giving the differences n-1,n-2,..,2,1
- Challenge is to find all solutions!
6Basic methodology
- Devise basic CSP model
- What are the variables? What are the constraints?
- Introduce auxiliary variables if needed
- Consider dual or combined models
- Break symmetry
- Introduce implied constraints
7Basic CSP model
8Basic CSP model
- What are the variables?
- Si j if the ith note is j
- What are the constraints?
9Basic CSP model
- What are the variables?
- Si j if the ith note is j
- What are the constraints?
- Si in 0,n)
- All-different(S1,S2, Sn)
- Forall ilti Si1 - Si / Si1 - Si
- Will this model be any good? If so, why?
- If not, why not?
10Basic methodology
- Devise basic CSP model
- What are the variables? What are the constraints?
- Introduce auxiliary variables if needed
- Consider dual or combined models
- Break symmetry
- Introduce implied constraints
11Improving basic CSP model
- Is it worth introducing any auxiliary variables?
- Are there any loose or messy constraints we could
better (more compactly?) express via some
auxiliary variables?
12Improving basic CSP model
- Is it worth introducing any auxiliary variables?
- Yes, variables for the pairwise differences
- Di Si1 - Si
- Now post single large all-different constraint
- Di in 1,n-1
- All-different(D1,D2,Dn-1)
13Basic methodology
- Devise basic CSP model
- What are the variables? What are the constraints?
- Introduce auxiliary variables if needed
- Consider dual or combined models
- Break symmetry
- Introduce implied constraints
14Dual or combined model?
- Would a dual model be useful?
15Dual or combined model?
- Would a dual model be useful?
- We already have GAC on permutations so not there!
- Would an 0/1 model be useful?
16Dual or combined model?
- Would a dual model be useful?
- We already have GAC on permutations so not there!
- Would an 0/1 model be useful?
- No obvious benefits here?
17Basic methodology
- Devise basic CSP model
- What are the variables? What are the constraints?
- Introduce auxiliary variables if needed
- Consider dual or combined models
- Break symmetry
- Introduce implied constraints
18Break symmetry
- Does the problem have any symmetry?
19Break symmetry
- Does the problem have any symmetry?
- Yes, we can reverse any sequence
- S1, S2, Sn is an all-inverse series
- Sn, , S2, S1 is also
- How do we eliminate this symmetry?
20Break symmetry
- Does the problem have any symmetry?
- Yes, we can reverse any sequence
- S1, S2, , Sn is an all-inverse series
- Sn, , S2, S1 is also
- How do we eliminate this symmetry?
- As with Golomb ruler!
- D1 lt Dn-1
21Break symmetry
- Does the problem have any other symmetry?
22Break symmetry
- Does the problem have any other symmetry?
- Yes, we can invert the numbers in any sequence
- 0, n-1, 1, n-2, map x onto n-1-x
- n-1, 0, n-2, 1,
- How do we eliminate this symmetry?
23Break symmetry
- Does the problem have any other symmetry?
- Yes, we can invert the numbers in any sequence
- 0, n-1, 1, n-2, map x onto n-1-x
- n-1, 0, n-2, 1,
- How do we eliminate this symmetry?
- S1 lt S2
24Basic methodology
- Devise basic CSP model
- What are the variables? What are the constraints?
- Introduce auxiliary variables if needed
- Consider dual or combined models
- Break symmetry
- Introduce implied constraints
25Implied constraints
- Are there useful implied constraints to add?
26Implied constraints
- Are there useful implied constraints to add?
- Hmm, unlike Golomb ruler, we only have
neighbouring differences - So, no need to consider transitive closure
27Implied constraints
- Are there useful implied constraints to add?
- Hmm, unlike Golomb ruler, we are not optimizing
- So, no need to improve propagation for
optimization variable
28Performance
- Basic model is poor
- Refined model able to compute all solutions up to
n14 or so - GAC on all-different constraints very beneficial
- As is enforcing GAC on Di Si1-Si
- This becomes too expensive for large n
- So use just bounds consistency (BC) for larger n
29Case study 6 progressive party problem
- Model due to Barabra Smith
30Progressive party problem
- Progressive does not mean hippy!
- But people progress round the party
- Yacht club party
- Small number of host boats
- Crews of other boats circulate round the hosts
31Progressive party problem
- There are h hosts, and g guests
- Each host boat has a maximum capacity of people
- Each guest boat has a crew size
- In each of t time periods
- Each guest boat visits one of the h hosts
- Subject to capacity constraints on hosts
- In addition, no two guests should meet twice and
no guest visit the same host twice
32Basic methodology
- Devise basic CSP model
- What are the variables? What are the constraints?
- Introduce auxiliary variables if needed
- Consider dual or combined models
- Break symmetry
- Introduce implied constraints
33Basic CSP model
34Basic CSP model
- What are the variables?
- Hit j if guest boat i visits host j at time t
- Why not the dual model of which guest visits
host j at time t?
35Basic CSP model
- What are the variables?
- Hit j if guest boat i visits host j at time t
- Why not the dual model of which guest visits
host j at time t? - But several guests visit each host so would need
to deal with set of guests for each host?
36Basic CSP model
- What are the constraints?
- No guest boat visits a host boat twice
- For all i . All-different(Hi1,Hi2,..,Hit)
37Basic CSP model
- What are the constraints?
- No guest boat visits a host boat twice
- For all i . All-different(Hi1,Hi2,..,Hit)
- Host boat capacity is not exceeded
38Basic CSP model
- What are the constraints?
- No guest boat visits a host boat twice
- For all i . all-different(Hi1,Hi2,..,Hit)
- Host boat capacity is not exceeded
- Hmm, hosts are values to Hit variables so would
need to look at all Hit variables simultaneously!
39Basic methodology
- Devise basic CSP model
- What are the variables? What are the constraints?
- Introduce auxiliary variables if needed
- Consider dual or combined models
- Break symmetry
- Introduce implied constraints
40Improving basic CSP model
- Is it worth introducing any auxiliary variables?
- Could we express capacity constraints via some
auxiliary variables?
41Improving basic CSP model
- Is it worth introducing any auxiliary variables?
- Could we express capacity constraints via some
auxiliary variables? - Of course, I wouldnt be asking the question
otherwise
42Improving basic CSP model
- Introduce auxiliary 0/1 variables that can be
summed - Vijt 1 iff Hitj
43Improving basic CSP model
- Introduce auxiliary 0/1 variables that can be
summed - Vijt 1 iff Hitj
- Capacity constraint now easy to specify
- Sum_i Vijt crew_i lt capacity_j
- where crew_i is crew size of boat j and
capacity_j is capacity of host boat j
44What about other constraints?
- Still have to specify that no two guest boats
meet twice
45What about other constraints?
- Still have to specify that no two guest boats
meet twice - Quantify over all pairs of guest, all host boats
and all time periods - O(g2 h t) constraints
46Basic methodology
- Devise basic CSP model
- What are the variables? What are the constraints?
- Introduce auxiliary variables if needed
- Consider dual or combined models
- Break symmetry
- Introduce implied constraints
47Improving basic CSP model
- Is it worth introducing any auxiliary variables?
- Could we express dont meet twice constraints
more compactly/efficiently via some auxiliary
variables?
48Improving basic CSP model
- Is it worth introducing any auxiliary variables?
- Could we express dont meet twice constraints
more compactly/efficiently via some auxiliary
variables? - Yes, of course. I wouldnt be asking otherwise!
49Improving CSP model
- Introduce auxiliary 0/1 variables to represent
meetings - Mklt 1 iff HktHlt
- I.e. if guest k meets guest l at time t
50Improving CSP model
- Introduce auxiliary 0/1 variables to represent
meetings - Mklt 1 iff HktHlt
- I.e. if guest k meets guest l at time t
- Meeting constraints easily specified
- Sum_t Mklt lt 1
51Basic methodology
- Devise basic CSP model
- What are the variables? What are the constraints?
- Introduce auxiliary variables if needed
- Consider dual or combined models
- Break symmetry
- Introduce implied constraints
52Break symmetry
- Does the problem have any symmetry?
53Break symmetry
- Does the problem have any symmetry?
- Yes, of course. The world is full of symmetry!
54Break symmetry
- Host boats of the same capacity are symmetric
- Guest boats of the same crew size are symmetric
- Guest boat symmetry is more important than host
boat. Why?
55Break symmetry
- Does the problem have any other symmetry?
56Break symmetry
- Does the problem have any other symmetry?
- Yes, of course. Time periods are symmetric
57Break symmetry
- How do we deal with symmetry of time periods?
58Break symmetry
- How do we deal with symmetry of time periods?
- Largest guest boat visits host boats in order
- Similar trick to assigning first row of
orthogonal Latin square - Why largest?
59Break symmetry
- Guest boats with the same crew size are symmetric
- How do we break this symmetry?
60Break symmetry
- Guest boats with the same crew size are symmetric
- If jltk have same crew size then
- Hj1 lt Hk1
61Break symmetry
- Guest boats with the same crew size are symmetric
- If jltk have same crew size then
- Hj1 lt Hk1
- They might still meet at t1!
- We cannot rule this out
- If they do, we still have this symmetry
62Break symmetry
- Guest boats with the same crew size are symmetric
- If jltk have same crew size then
- Hj1 lt Hk1
- They might still meet at t1!
- Hj1ltHk1 or Hj2ltHk2
- They cannot meet at t1 and t2
63Break symmetry
- Host boats with the same capacity are symmetric
- How do we break this symmetry?
64Break symmetry
- Host boats with the same capacity are symmetric
- Partial solution
- If jltk have identical capacity, then guest boat 1
visits k implies it also visits j
65Break symmetry
- Host boats with the same capacity are symmetric
- Partial solution
- If jltk have identical capacity, then guest boat 1
visits k implies it also visits j - Can you improve on this?
66Solving choices
- Which variables to branch on?
- Hit, Vijt or Mijt ?
67Solving choices
- Which variables to branch on?
- Hit and let others follow
- What variable ordering heuristic
68Solving choices
- Which variables to branch on?
- Hit and let others follow
- What variable ordering heuristic
- Fail first
- What value ordering?
69Solving choices
- Which variables to branch on?
- Hit and let others follow
- What variable ordering heuristic
- Fail first
- What value ordering?
- Host boats by their spare capacity
- Alias succeed first
70Performance
- Party held before problem solved!
- 13 hosts, 29 guests, 6 time periods
- Heuristic tweaked to assign each period in turn
- Solution found for 7 period problem
- They could have partied longer
- 12 host problem easy to show insoluble
- Simple capacity argument
71Conclusions
- Constraint programming can improve your social
life! - Modelling is an art but there are patterns
- Develop basic model
- Use auxiliary variables to represent constraints
compactly/efficiently - Consider dual, combined and 0/1 models
- Break symmetry
- Add implied constraints