Download presentation
Presentation is loading. Please wait.
Published byKameron Hinch Modified over 10 years ago
1
Global Constraints Toby Walsh National ICT Australia and University of New South Wales www.cse.unsw.edu.au/~tw
2
Course outline ● Introduction ● All Different ● Lex ordering ● Value precedence ● Complexity ● GAC-Schema ● Soft Global Constraints ● Global Grammar Constraints ● Roots Constraint ● Range Constraint ● Slide Constraint ● Global Constraints on Sets
3
Constraint programming ● “Constraint programming represents one of the closest approaches computer science has yet made to the Holy Grail of programming: the user states the problem, the computer solves it”. – Gene Freuder, Constraints, April 1997
4
My Da Vinci code Sol= [ S,E,N,D, M,O,R,E, M,O,N.E.Y], Sol :: [0..9], S<>0, M<>0. alldifferent(Sol), 1000*S+100*E+10*N+D+ 1000*M+100*O+10*R+E= 10000*M+1000*O+100*N+10*E+Y, label(Sol).
5
My Da Vinci code Sol= [ S,E,N,D, M,O,R,E, M,O,N.E.Y], Sol :: [0..9], S<>0, M<>0. alldifferent(Sol), 1000*S+100*E+10*N+D+ 1000*M+100*O+10*R+E= 10000*M+1000*O+100*N+10*E+Y, label(Sol). ? Sol = [9,5,8,7,1,0,8,2]
6
Suduko Puzzle = [X11,X12,X13, …X19, X21,X22, ………X29,.. X91,X92, ……….X99] Puzzle :: 1..9 alldifferent([X11,..X19]) alldifferent([X21,..X29]).. alldifferent([X11,..X91]).. alldifferent([X11,..X33])..
7
Application areas ● Scheduling ● Timetabling ● Assignment – personnel – stand allocation ● Network configuration ● Configuration ● Bioinformatics ●...
8
Constraint satisfaction ● Decision variables: – X1, X2, X3... ● Domain of values: – red, yellow, green,... ● Constraints – binary relations like X1=/= X2 – non-binary relations like NValues([X1,..Xn],3)
9
Constraint optimization ● Many problems are in fact optimization – Maximize profit – Minimize costs –... ● Optimization = sequence of decision problems – Feasibility constraints – Optimization constraint: Sum(i,ai.Xi) <= Cost ● Branch and bound
10
Solving constraint satisfaction problems ● Systematic methods – Extend partial solutions – Search (branching) and – Inference (enforcing a local consistency) ● Local search methods – Complete solution – Repair based
11
Solving constraint satisfaction problems ● Systematic methods – Pick a variable and a value to assign it ● Branching heuristic – Enforce a local consistency property ● This prunes values of future uninstantiated variables – If a domain is wiped out, backtrack – Else repeat
12
Tree search
13
Branching heuristics ● Variable ordering – most constrained variable, fail first – e.g. smallest domain, domain/degree ● Value ordering – most promising value – succeed first
14
Arc consistency ● X=a has support iff it occurs in an assignment that satisfies the constraint ● A constraint is arc consistent iff each value in the domain of each variable has support ● Enforce arc consistency by deleting values without support – Exists maximal arc consistent domains ● For non-binary constraints, arc consistency called generalized arc consistency (GAC) or hyper arc consistency
15
Enforcing arc consistency ● X1, X2 in {red,blue} ● X3 in {red,blue,green} ● X1=/=X2, X1=/=X3, X2=/=X3 ● All three binary inequalities are arc consistent – e.g X3=red has support X1=blue in X1=/=X3
16
Enforcing arc consistency ● X1, X2 in {red,blue} ● X3 in {red,blue,green} ● AllDifferent(X1,X2,X3) ● Now enforcing GAC on AllDifferent constraint prunes – X3=red and X3=blue – These values have no support! – X3=green has two supports: – X1=red, X2=blue and X1=blue, X2=red
17
Bound consistency ● Max and min values have supports which lie between max and min values in each domain ● Also used with set variables – Set variable typically represented by – Upper bound = elements that can be in set – Lower bound = elements that must be in set – Equivalently 0/1 vector representing characteristic function ● Bound consistency on characteristic function rep – Upper bound = Union of possible supported values – Lower bound = Intersection of possible supported values
18
Global constraints Richer modelling Richer solving....
19
Comparison with Operations Research ● CP – rich modelling language – many different global constraints – variable indexing – fast local inference on these global constraints – good for finding feasible and tightly constrained solutions ● (I)LP – everything has to be a linear inequality – limited range of solution methods (simplex,...) – good at proving optimality
20
Variable indexing ● OR people jealously look at our ability to index with a variable – Array like “look up” – E.g. sports scheduling ● forall(i in Teams, k i Weeks) Plays[Plays[i,k]]=i – Not possible in ILP – Simple global “element” constraint ● element(X,[a_1,..,a_m],Y) iff a_X = Y
21
Global constraints ● Any non-binary constraint – AllDifferent – Nvalues – Element – Lex ordering – Stretch constraint – Sequencing constraint – Cummulative constraint –... – Beldiceanu's large catalog ● Each comes with an efficient propagator...
22
To be or not to be a global constraint? ● [Bessiere and Van Hentenryck CP 03] ● Semantically global – no constraint decomposition ● Operationally global – no constraint decomposition on which we do the same pruning (e.g. GAC on All Different) ● Algorithmically global – complexity disadvantage to use decomposition (e.g. FC on All Different)
23
Why global constraints? ● Richer modelling – simple models (e.g. variable indexing) – easy to prototype and maintain ● Richer solving – propagators provide “global” view otherwise missing in CP – can making solving competitive with OR methods
24
Conclusions ● Constraint programming is a powerful paradigm for solving many combinatorial optimization problems ● Global constraints are integral to this success ● As we shall see, there are many different types of global constraints – However, a few are central like AllDifferent, Roots, Range, Slide,...
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.