Presentation is loading. Please wait.

Presentation is loading. Please wait.

Specialised (user defined) constraints in JChoco 2 examples: max and subtour elimination.

Similar presentations


Presentation on theme: "Specialised (user defined) constraints in JChoco 2 examples: max and subtour elimination."— Presentation transcript:

1 Specialised (user defined) constraints in JChoco 2 examples: max and subtour elimination

2 Consider the following contraint This can be implemented in JChoco using primitives as follows

3 Due to Chris Unsworth

4

5

6

7 Could I define my own constraint to do this? Why would I want to do that? Possibly: more compact faster more propagation

8 Define a constraint called Max that extends AbstractLargeIntConstraint V[0] = max(v[1],v[2],…,v[n-1])

9

10

11

12

13

14

15 Methods to be implemented inf: lower bound sup: upper bound instantiate initiation removal of value V[0] = max(v[1],v[2],…,v[n-1])

16 A demo V[0] = max(v[1],v[2],…,v[n-1]) Cart before the horse?

17 Note: output always has a 4 or a 5 in it V[0] = max(v[1],v[2],…,v[n-1])

18

19

20

21 Backtrackable Variables (Stored*) We haven’t used them yet, but ….

22

23

24

25

26 Small TSP’s

27

28 The single successor model An array of n variables But this aint enough “single successor” model of a graph Limits what kind of graph can be modelled out-degree of 1

29 The single successor model 12305674 01 7 23 456 NOT A TOUR! We need subtour elimination

30

31 Associate with each variable next[i] the following reversible variables When making an instantiation next[i] = 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 next[e[j]] != s[i] i.e. we cannot close that loop! Yikes! Show me a picture!

32 0 3 2 1 5 4 7 next[1] = 5 s[1] = 0 e[0] = 1 e[5] = 7 s[7] = 5 8 6 e[8] = 6 s[6] = 8

33 0 3 2 1 5 4 7 e[0] = 7 s[7] = 0 8 6 e[8] = 6 s[6] = 8

34 0 3 2 1 5 4 7 e[0] = 7 s[7] = 0 8 6 e[8] = 6 s[6] = 8 next[7] ≠ 0 Otherwise we have a subtour/loop This is the “propagation”. Note: this is a constraint that may be used in a richer problem

35

36

37 Example application: knight’s tour

38

39

40

41

42 Wot! Show me a picture!

43

44

45

46

47

48 Is there a dvo heuristic for this?

49

50

51

52

53 Warnsdorff's rule

54 Is there an alternative model for this?

55 A knights-graph with a degree sequence 2* that is connected i.e. adjacency matrix model of the graph

56 So? 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

58


Download ppt "Specialised (user defined) constraints in JChoco 2 examples: max and subtour elimination."

Similar presentations


Ads by Google