Title: Specialised user defined constraints in JChoco
1Specialised (user defined) constraints in JChoco
2 examples max and subtour elimination
2Consider the following contraint
This can be implemented in JChoco using
primitives as follows
3Due to Chris Unsworth
4(No Transcript)
5(No Transcript)
6(No Transcript)
7Could I define my own constraint to do
this? Why would I want to do that?
- Possibly
- more compact
- faster
- more propagation
8V0 max(v1,v2,,vn-1)
Define a constraint called Max that extends
AbstractLargeIntConstraint
9(No Transcript)
10(No Transcript)
11(No Transcript)
12(No Transcript)
13(No Transcript)
14(No Transcript)
15Methods to be implemented
V0 max(v1,v2,,vn-1)
initiation
inf lower bound sup upper bound
removal of value
instantiate
16V0 max(v1,v2,,vn-1)
A demo
Cart before the horse?
17V0 max(v1,v2,,vn-1)
Note output always has a 4 or a 5 in it
18(No Transcript)
19(No Transcript)
20(No Transcript)
21We havent used them yet, but .
Backtrackable Variables (Stored)
22(No Transcript)
23(No Transcript)
24(No Transcript)
25(No Transcript)
26Small TSPs
27(No Transcript)
28The single successor model
An array of n variables
- single successor model of a graph
- Limits what kind of graph can be modelled
- out-degree of 1
But this aint enough
29The single successor model
NOT A TOUR!
1
2
3
0
5
6
7
4
7
4
5
6
0
1
2
3
We need subtour elimination
30(No Transcript)
31Associate with each variable nexti the
following reversible variables
- When making an instantiation
- nexti j
- We now join the path that ends in i to path that
starts with j - If the path involves less that n vertices/cities
- nextej ! si
- i.e. we cannot close that loop!
326
s6 8
8
e8 6
s7 5
7
4
5
next1 5
e5 7
1
s1 0
2
3
0
e0 1
336
s6 8
8
e8 6
s7 0
7
4
5
1
2
3
0
e0 7
346
s6 8
8
e8 6
s7 0
7
4
5
next7 ? 0 Otherwise we have a
subtour/loop This is the propagation .
1
2
3
0
e0 7
Note this is a constraint that may be used in a
richer problem
35(No Transcript)
36(No Transcript)
37Example application knights tour
38(No Transcript)
39(No Transcript)
40(No Transcript)
41(No Transcript)
42Wot! Show me a picture!
43(No Transcript)
44(No Transcript)
45(No Transcript)
46(No Transcript)
47(No Transcript)
48Is there a dvo heuristic for this?
49(No Transcript)
50(No Transcript)
51(No Transcript)
52(No Transcript)
53Warnsdorff's rule
54Is there an alternative model for this?
55A knights-graph with a degree sequence 2 that is
connected i.e. adjacency matrix model of the
graph
56So?
- Jean-Francois Puget called this the glass box
- Note how this fits with AC5
- Note that we need to consider state and
backtracking - Why bother?
57(No Transcript)
58(No Transcript)