Download presentation

Presentation is loading. Please wait.

Published byZane Frankson Modified over 2 years ago

1
Global Constraints Toby Walsh NICTA and University of New South Wales www.cse.unsw.edu.au/~tw

2
Quick advert ZUNSW is in Sydney ZRegularly voted in top 10 cities in World ZUNSW is one of top universities in Australia ZIn top 100 universities in world ZTalk to me about our PhD programme! ZAlso happy to have PhDs/PostDocs visit for weeks/months/years … ZAttend CP/KR/ICAPS in Sept

3
Value precedence ZGlobal constraint used to deal with value symmetry ZGood example of “global” constraint where we can use an efficient encoding ZEncoding gives us GAC ZAsymptotically optimal, achieve GAC in O(nd) time ZGood incremental/decremental complexity

4
Value symmetry ZDecision variables: ZCol[Italy], Col[France], Col[Austria]... ZDomain of values: Zred, yellow, green,... ZConstraints Col[Italy]=/=Col[France] Col[Italy]=/=Col[Austria] …

5
Value symmetry ZSolution: ZCol[Italy]=green Col[France]=red Col[Spain]=green … ZValues (colours) are interchangeable: ZSwap red with green everywhere will still give us a solution

6
Value precedence ZOld idea ZUsed in bin-packing and graph colouring algorithms ZOnly open the next new bin ZOnly use one new colour ZApplied now to constraint satisfaction

7
Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1

8
Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1 ZFor X2, we need only consider two choices ZX2=1 or X2=2

9
Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1 ZFor X2, we need only consider two choices ZSuppose we try X2=2

10
Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1 ZFor X2, we need only consider two choices ZSuppose we try X2=2 ZFor X3, we need only consider three choices ZX3=1, X3=2, X3=3

11
Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1 ZFor X2, we need only consider two choices ZSuppose we try X2=2 ZFor X3, we need only consider three choices ZSuppose we try X3=2

12
Value precedence ZSuppose all values from 1 to m are interchangeable ZMight as well let X1=1 ZFor X2, we need only consider two choices ZSuppose we try X2=2 ZFor X3, we need only consider three choices ZSuppose we try X3=2 ZFor X4, we need only consider three choices ZX4=1, X4=2, X4=3

13
Value precedence ZGlobal constraint ZPrecedence([X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) for all j

14
Value precedence ZGlobal constraint ZPrecedence([X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) ZE.g ZPrecedence([1,1,2,1,3,2,4,2,3]) ZBut not Precedence([1,1,2,1,4])

15
Value precedence ZGlobal constraint ZPrecedence([X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) ZPropagator proposed by [Law and Lee 2004] ZPointer based propagator (alpha, beta, gamma) but only for two interchangeable values at a time

16
Value precedence ZPrecedence([j,k],[X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) ZOf course ZPrecedence([X1,..Xn]) iff Precedence([i,j],[X1,..Xn]) for all i

17
Value precedence ZPrecedence([j,k],[X1,..Xn]) iff min({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) ZOf course ZPrecedence([X1,..Xn]) iff Precedence([i,j],[X1,..Xn]) for all i

18
Puget’s method ZIntroduce Zj to record first time we use j ZAdd constraints ZXi=j implies Zj <= i ZZj=i implies Xi=j ZZi < Zi+1

19
Puget’s method ZIntroduce Zj to record first time we use j ZAdd constraints ZXi=j implies Zj < i ZZj=i implies Xi=j ZZi < Zi+1 ZBinary constraints Zeasy to implement

20
Puget’s method ZIntroduce Zj to record first time we use j ZAdd constraints ZXi=j implies Zj < I ZZj=i implies Xi=j ZZi < Zi+1 ZUnfortunately hinders propagation ZAC on encoding may not give GAC on Precedence([X1,..Xn]) ZConsider X1=1, X2 in {1,2}, X3 in {1,3}, X4 in {3,4}, X5=2, X6=3, X7=4

21
Propagating Precedence ZSimple ternary encoding ZIntroduce sequence of variables, Yi ZRecord largest value used so far ZY1=0

22
Propagating Precedence ZSimple ternary encoding ZPost sequence of constraints C(Xi,Yi,Yi+1) for each 1<=i<=n These hold iff Xi<=1+Yi and Yi+1=max(Yi,Xi)

23
Propagating Precedence ZSimple ternary encoding ZPost sequence of constraints ZEasily implemented within most solvers ZImplication and other logical primitives ZGAC-Schema (alias “table” constraint) Z…

24
Propagating Precedence ZSimple ternary encoding ZPost sequence of constraints ZC(Xi,Yi,Yi+1) for each 1<=i<=n ZThis decomposition is Berge-acyclic ZConstraints overlap on one variable and form a tree

25
Propagating Precedence ZSimple ternary encoding ZPost sequence of constraints ZC(Xi,Yi,Yi+1) for each 1<=i<=n ZThis decomposition is Berge-acyclic ZConstraints overlap on one variable and form a tree ZHence enforcing GAC on the decomposition achieves GAC on Precedence([X1,..Xn]) ZTakes O(n) time ZAlso gives excellent incremental behaviour

26
Propagating Precedence ZSimple ternary encoding ZPost sequence of constraints ZC(Xi,Yi,Yi+1) for each 1<=i<=n ZThese hold iff Xi<=1+Yi and Yi+1=max(Yi,Xi) ZConsider Y1=0, X1 in {1,2,3}, X2 in {1,2,3} and X3=3

27
Precedence and matrix symmetry ZAlternatively, could map into 2d matrix ZXij=1 iff Xi=j ZValue precedence now becomes column symmetry ZCan lex order columns to break all such symmetry ZAlternatively view value precedence as ordering the columns of a matrix model

28
Precedence and matrix symmetry ZAlternatively, could map into 2d matrix ZXij=1 iff Xi=j ZValue precedence now becomes column symmetry ZHowever, we get less pruning this way ZAdditional constraint that rows have sum of 1 ZConsider, X1=1, X2 in {1,2,3} and X3=1

29
Partial value precedence ZValues may partition into equivalence classes ZValues within each equivalence class are interchangeable ZE.g. Shift1=nursePaul, Shift2=nursePeter, Shift3=nurseJane, Shift4=nursePaul..

30
Partial value precedence ZShift1=nursePaul, Shift2=nursePeter, Shift3=nurseJane, Shift4=nursePaul.. ZIf Paul and Jane have the same skills, we can swap them (but not with Peter who is less qualified) ZShift1=nurseJane, Shift2=nursePeter, Shift3=nursePaul, Shift4=nurseJane …

31
Partial value precedence ZValues may partition into equivalence classes ZValue precedence easily generalized to cover this case ZWithin each equivalence class, vi occurs before vj for all i

32
Partial value precedence ZValues may partition into equivalence classes ZValue precedence easily generalized to cover this case ZWithin each equivalence class, vi occurs before vj for all i

33
Partial value precedence ZValues may partition into equivalence classes ZValue precedence easily generalized to cover this case ZWithin each equivalence class, vi occurs before vj for all i

34
Partial value precedence ZValues may partition into equivalence classes ZValue precedence easily generalized to cover this case ZWithin each equivalence class, vi occurs before vj for all i

35
Variable and value precedence ZValue precedence compatible with other symmetry breaking methods ZInterchangeable values and lex ordering of rows and columns in a matrix model

36
Conclusions ZSymmetry of interchangeable values can be broken with value precedence constraints ZValue precedence can be decomposed into ternary constraints ZEfficient and effective method to propagate ZCan be generalized in many directions ZPartial interchangeability, …

37
Global constraints ZHardcore algorithms ZData structures ZGraph theory ZFlow theory ZCombinatorics Z… ZComputational complexity ZGlobal constraints are often balanced on the limits of tractability!

38
Computational complexity 101 ZSome problems are essentially easy ZMultiplication, O(n 1.58 ) ZSorting, O(n logn) ZRegular language membership, O(n) ZContext free language membership, O(n 3 ).. ZP (for “polynomial”) ZClass of decision problems recognized by deterministic Turing Machine in polynomial number of steps ZDecision problem ZQuestion with yes/no answer? E.g. is this string in the regular language? Is this list sorted? …

39
NP ZNP ZClass of decision problems recognized by non-deterministic Turing Machine in polynomial number of steps ZGuess solution, check in polynomial time ZE.g. is propositional formula satisfiable? (SAT) ZGuess model (truth assignment) ZCheck if it satisfies formulae in polynomial time

40
NP ZProblems in NP ZMultiplication ZSorting Z.. ZSAT Z3-SAT ZNumber partitioning ZK-Colouring ZConstraint satisfaction Z…

41
NP-completeness ZSome problems are computationally as hard as any problem in NP ZIf we had a fast (polynomial) method to solve one of these, we could solve any problem in NP in polynomial time ZThese are the NP-complete problems ZSAT (Cook’s theorem: non-deterministic TM => SAT) Z3-SAT Z….

42
NP-completeness ZTo demonstrate a problem is NP- complete, there are two proof obligations: Zin NP ZNP-hard (it’s as hard as anything else in NP)

43
NP-completeness ZTo demonstrate a problem is NP- complete, there are two proof obligations: Zin NP ZPolynomial witness for a solution ZE.g. SAT, 3-SAT, number partitioning, k- Colouring, … ZNP-hard (it’s as hard as anything else in NP)

44
NP-completeness ZTo demonstrate a problem is NP- complete, there are two proof obligations: ZNP-hard (it’s as hard as anything else in NP) ZReduce some other NP-complete to it ZThat is, show how we can use our problem to solve some other NP-complete problem ZAt most, a polynomial change in size of problem

45
Global constraints are NP- hard ZCan solve 3SAT using a single global constraint! ZGiven 3SAT problem in N vars and M clauses Z3SAT([X1,…Xn]) where n=N+3M+2 ZConstraint holds iff X1=N, X2=M, ZX_2+i is 0/1 representing value assigned to xi ZX_2+N+3j, X_2+N+3j+1 and X_2+N+3j+2 represents jth clause

46
Our hammer ZUse tools of computational complexity to study global constraints

47
Questions to ask? ZGACSupport? is NP-complete ZDoes this value have support? ZBasic question asked within many propagators ZMaxGAC? is DP-complete ZAre these domains the maximal generalized arc-consistent domains? ZTermination test for a propagator ZDP = NP u coNP ZPropagation “harder” than solving the problem!

48
Questions to ask? ZIsItGAC? is NP-complete ZAre the domains GAC? ZWakeup test for a propagator ZNoGACWipeOut? is NP-complete ZIf we enforce GAC, do we not get a wipeout? ZUsed in many reductions ZGACDomain? is NP-hard ZReturn the maximal GAC domains ZWhat a propagator actually does!

49
Relationships between questions ZNoGACWipeOut = GACSupport = GACDomain ZNoGACWipeOut in P GACDomain in P ZNoGACWipeOut in NP GACDomain in NP ZGACDomain in P => MaxGAC in P => IsItGAC in P ZIsItGAC in NP => MaxGAC in NP => GACDomain in NP ZOpen if arrows cannot be reversed!

50
Constraints in practice ZSome constraints proposed in the past are intractable ZNValues(N,X1,..Xn) ZCardPath(N,[X1,..,Xn],C) Z…

51
NValues ZNValues(N,X1,..,Xm) ZN values used in X1,…,Xm ZUseful for resource allocation

52
NValues ZNValues(Y,X1,..,Xn) ZReduction of 3SAT to NValues Z3SAT problem in N vars, M clauses Xi in {i,-i} for 1 ≤ i ≤ N XN+s in {i,-j,k} if s-th clause is: (i or -j or k) Z Y= N ZHence 3SAT has a solution => NoGACWipeOut answers “yes”

53
NValues ZNValues(N,X1,..,Xm) ZReduction of 3SAT to NValues Z3SAT problem in n vars, l clauses Xi in {i,-i} for 1 ≤ i ≤ n Xn+s in {i,-j,k} if s-th clause is: (i or -j or k) ZN = n ZHence 3SAT has a solution NoGACWipeOut answers “yes” ZEnforce lesser level of local consistency (e.g. BC)

54
Generalizing constraints ZTake a tractable constraint ZGCC([X1,..,Xn],[l1,..,lm],[u1,..,um]) ZValue j occurs between lj and uj times in X1,..,Xn ZGeneralize some constants to variables ZE.g. GCC([X1,..,Xn],[O1,..,Om]) ZNP-hard to enforce GAC!

55
Generalizing constraints ZGCC([X1,..,Xn],[O1,..,Om]) ZReduction from 1in3SAT on positive clauses ZIf jth clause is (x or y or z) then Xj in {x,y,z} ZIf x occurs k times in all clauses then Ox in {0,k} ZHence 1in3SAT has a solution iff NoGACWipeOut answers “yes” ZThus enforcing GAC is NP-hard

56
Meta-constraints ZGlobal constraint used in sequencing problems ZCardPath(C,[X1,..Xn],N) iff C(Xi,..Xi+k) holds N times ZE.g. number of changes is CardPath(=/=,[X1,..Xn],N) ZFixed parameter tractable Zk fixed, GAC takes O(nd^k) time Zk = O(n), GAC is NP-hard even when C is polynomial to test

57
Meta-constraints ZCardPath(C,[X1,..Xn],N) iff C(Xi,..Xi+k) holds N times ZReduce 3SAT in N variables and M clauses to CardPath where k=N+2 ZNM vars Xi to represent repeated truth assignment ZM vars Yj to represent jth clause ZC(X1,..,XN,Yj,X1’) iff Yj=k and Xk=1 and X1=X1’ or Yj=-k and Xk=0 and X1=X1’ ZC(X2,..,XM.Yj,X1’,X2’) iff X2=X2’ Z..

58
Conclusions ZComputational complexity is a useful hammer to study global constraints ZUncovers fundamental limits of reasoning with global constraints ZLesser consistency needs to be enforced ZGeneralization intractable Z..

59
Global grammar constraints ZOften easy to specify a global constraint ZALLDIFFERENT([X1,..Xn]) iff Xi=/=Xj for i

60
Global grammar constraints ZPromising direction initiated is to specify constraints via automata/grammar ZSequence of variables = string in some formal language ZSatisfying assignment = string accepted by the grammar/automata Global constraints meets formal language theory

61
REGULAR constraint ZREGULAR(A,[X1,..Xn]) holds iff ZX1.. Xn is a string accepted by the deterministic finite automaton A ZProposed by Pesant at CP 2004 ZGAC algorithm using dynamic programming ZHowever, DP is not needed since simple ternary encoding is just as efficient and effective

62
REGULAR constraint ZDeterministic finite automaton (DFA) Z ZQ is finite set of states ZSigma is alphabet (from which strings formed) ZT is transition function: Q x Sigma -> Q Zq0 is starting state ZF subseteq Q are accepting states ZDFAs accept precisely regular languages ZRegular language can be specified by rules of the form: NonTerminal -> Terminal | Terminal NonTerminal

63
REGULAR constraint ZDFAs accept precisely regular languages ZRegular language can be specified by rules of the form: NonTerminal -> Terminal NonTerminal -> Terminal NonTerminal | NonTerminal Terminal -Alternatively given by regular expressions -More limited than BNF which can express context- free grammars

64
REGULAR constraint ZRegular language ZS -> 0 | 0A| AB | AC | 1B | 1 ZA -> 0 | 0A ZB -> 1 | 1B ZC -> 1 | 1C | 0 | 0A ZDFA ZQ={q0,q1,q2} ZSigma={0.1} ZT(q0,0)=q0. T(q0,1)=q1 ZT(q1,0)=q2, T(q1,1)=q1 ZT(q2,0)=q2 ZF={q0,q1,q2}

65
REGULAR constraint ZRegular language ZS -> 0 | 0A| AB | AC | 1B | 1 ZA -> 0 | 0A ZB -> 1 | 1B ZC -> 1 | 1C | 0 | 0A ZDFA ZQ={q0,q1,q2} ZSigma={0.1} ZT(q0,0)=q0. T(q0,1)=q1 ZT(q1,0)=q2, T(q1,1)=q1 ZT(q2,0)=q2 ZF={q0,q1,q2} CONTIGUITY constraint

66
REGULAR constraint ZMany global constraints are instances of REGULAR ZAMONG, CONTIGUITY, LEX, PRECEDENCE, STRETCH,.. ZDomain consistency can be enforced in O(ndQ) time using dynamic programming ZContiguity example: {0,1}, {0}, {1}, {0,1}, {1}

67
REGULAR constraint ZREGULAR constraint can be encoded into ternary constraints ZIntroduce Qi+1 Zstate of the DFA after the ith transition ZThen post sequence of constraints ZC(Xi,Qi,Qi+1) iff DFA goes from state Qi to Qi+1 on symbol Xi

68
REGULAR constraint ZREGULAR constraint can be encoded into ternary constraints ZConstraint graph is Berge-acyclic ZConstraints only overlap on one variable ZEnforcing GAC on ternary constraints achieves GAC on REGULAR in O(ndQ) time

69
REGULAR constraint ZPRECEDENCE([X1,..Xn]) iff Zmin({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) for all j

70
REGULAR constraint ZPRECEDENCE([X1,..Xn]) iff Zmin({i | Xi=j or i=n+1}) < min({i | Xi=k or i=n+2}) for all j

71
REGULAR constraint ZSTRETCH([X1,..Xn]) holds iff ZAny stretch of consecutive values is between shortest(v) and longest(v) length ZAny change (v1,v2) is in some permitted set, P ZFor example, you can only have 3 consecutive night shifts and a night shift must be followed by a day off

72
REGULAR constraint ZSTRETCH([X1,..Xn]) holds iff ZAny stretch of consecutive values is between shortest(v) and longest(v) length ZAny change (v1,v2) is in some permitted set, P ZDFA ZQi is ZQ0= ZT(,a)= if q+1<=longest(a) ZT(,b)= if (a,b) in P and q>=shortest(a) ZAll states are accepting

73
Other generalizations of REGULAR ZREGULAR FIX(A,[X1,..Xn],[B1,..Bm]) iff ZREGULAR(A,[X1,..Xn]) and Bi=1 iff exists j. Xj=I ZCertain values must occur within the sequence ZFor example, there must be a maintenance shift ZUnfortunately NP-hard to enforce GAC on this

74
Other generalizations of REGULAR ZREGULAR FIX(A,[X1,..Xn],[B1,..Bm]) ZSimple reduction from Hamiltonian path ZAutomaton A accepts any walk on a graph Zn=m and Bi=1 for all i

75
Chomsky hierarchy ZRegular languages ZContext-free languages ZContext-sensitive languages Z..

76
Chomsky hierarchy ZRegular languages ZGAC propagator in O(ndQ) time ZConext-free languages ZGAC propagator in O(n^3) time and O(n^2) space ZAsymptotically the same as parsing! ZConext-sensitive languages ZChecking if a string is in the language PSPACE-complete ZUndecidable to know if empty string in grammar and thus to detect domain wipeout and enforce GAC!

77
Context-free grammars ZApplications ZHierarchy configuration ZBioinformatics ZNatual language parsing ZRostering Z… ZCFG(G,[X1,…Xn]) holds iff ZX1.. Xn is a string accepted by the context free grammar G

78
CFG propagator ZAdapt CYK parser ZWorks on Chomsky normal form ZNon-terminal -> Terminal ZNon-terminal -> Non-terminal Non- terminal ZUsing dynamic programming ZComputes V[i,j], set of possible parsings for the ith to the jth symbols

79
Conclusions ZGlobal grammar constraints ZSpecify wide range of global constraints ZProvide efficient and effective propagators automatically ZNice marriage of formal language theory and constraint programming!

Similar presentations

OK

(1) MAX X1+3X2+2X3+4X4 X1=AM PHONE, X2=AM RIDE, X3=AFT PHONE, X4=AFT RIDE CONSTRAINTS AM: X1+20X2 < 12(60)=720 AFT: 2X3+30X4 < 14(60) = 840 GAS: X2+X4.

(1) MAX X1+3X2+2X3+4X4 X1=AM PHONE, X2=AM RIDE, X3=AFT PHONE, X4=AFT RIDE CONSTRAINTS AM: X1+20X2 < 12(60)=720 AFT: 2X3+30X4 < 14(60) = 840 GAS: X2+X4.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on recycling of waste material in india Ppt on religious tourism in india Ppt on hydroelectric power generation Ppt on model view controller pattern Ppt on transcription and translation Ppt on polynomials in maths what is the range Ppt on automobile related topics for peace Ppt on needle stick injury ppt Ppt on animal farm themes Ppt on road accidents in pakistan