Download presentation

Presentation is loading. Please wait.

Published byDean Chopin Modified over 3 years ago

1
Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Constraint Programming 3: The Party

2
Intelligence Artificial Intelligence Part I :Formulation Part II:Progressive piss up at a yacht club Constraint Programming 3

3
3 Constraint Satisfaction Problems zCSP = Constraint Satisfaction Problems zA CSP consists of: ya set of variables, X yfor each variable x i in X, a domain D i xD i is a finite set of possible values ya set of constraints restricting tuples of values xif only pairs of values, it’s a binary CSP zA solution is an assignment of a value in D i to each variable x i such that every constraint satisfied

4
4 Donald + Gerald = Robert zWe can write one long constraint for the sum: y100000*D + 10000*O + 1000*N + 100*A+ 10*L + D + 100000*G + 10000*E + 1000*R + 100*A+ 10*L + D = 100000*R + 10000*O + 1000*B + 100*E+ 10*R + T zBut what about the difference between variables? yCould write D =/= O, D=/=N, … B =/= T yOr express it as a single constraint on all variables yAllDifferent(D,O,N,A,L,G,E,R,B,T) zThese two constraints yexpress the problem precisely yboth involve all the 10 variables in the problem

5
5 Formulation of CSP’s zAll-different is an example of the importance of formulation yall-different(x,y,z) much better than x y, y z, z x yeven though logically equivalent zIn general, it’s hard to find the best formulation zRemember DONALD + GERALD = ROBERT zThe formulation I gave had just 2 constraints yall-different and a complicated arithmetic constraint zAll-different fine, but neither FC nor MAC can do much with the arithmetic constraint

6
6 Cryptarithmetic Revisited zFC cannot propagate until only one variable left in constraint zAC cannot propagate until only two variables left zWhen coded in ILOG Solver, search backtracks 8018 times zHow can we formulate the problem better? zHint: we’d like to consider the sum in each column separately

7
7 This shouldn’t work ?!? zWe’ve made the problem bigger, so how can it help? zBefore, there were 9 3 10 7 possibilities ynow there are 2 5 = 32 times as many! zThe constraints now involve fewer variables yconstraint propagation can happen sooner yvariables can be set sooner (reduced to one value) ydomain wipe out & backtracking occurs earlier zIn ILOG Solver, this encoding needs only 212 ydown from 8,018 yif that doesn’t impress you, call it minutes (or hours)

8
8 DONALD + GERALD = ROBERT zOne solution is to add more variables to the problem zVariables C1, C2, C3, C4, C5 yCi represents carry from previous column i yD Ci = {0,1} yNow we can express more constraints y D + D = 10*C1 + T yC1 + L + L = 10*C2 + R yC2 + A + A = 10*C3 + E yC3 + N + R = 10*C4 + B yC4 + O + E = 10*C5 + O yC5 + D + G = R

9
9 The importance of heuristics zRemember “minimum remaining value” heuristic ycheck out Constraints lecture 1 if not zVariable ordering heuristic ychoose variable to expand next with m.r.v. xI.e. smallest number of values left in current domain yvery important in practical solution of CSPs zIn DONALD + GERALD using ILOG Solver ycarry variables take 8,018 fails to 212 ym.r.v. reduces it to 14 y(multiply it by 1,000,000 if it doesn’t seem important)

10
10 Exercises from Constraints 3 zSolve DONALD + GERALD = ROBERT y Try to simulate what constraints program would do x use carry variables and m.r.v. heuristic zWhat does the progressive party problem tell us? yConsider issues such as: xrelative success and failure of CP/ILP xnumber of variables necessary xcomplication of formulation/heuristics

11
11 Progressive Piss up at a yacht club z“The Progressive Party Problem: yInteger Linear Programming and Constraint Programming Compared” yBarbara M Smith, Sally Brailsford, Peter Hubbard, Paul Williams z39 boats at a yachting rally yeach boat with a known crew size y& capacity to entertain a certain number of guests ydesignated host crews stay put, other crews circulate yguest crews progress every half hour y3 hours = 6 visits

12
12 What’s a progressive party? zConstraints yno guest crew may visit the same host boat twice yno two guest crews may meet twice ycrews cannot be split up (neither host nor guest) yno boat’s capacity can be exceeded ywant to minimise the number of host boats xand find a way of organising the party with this number zIn the particular problem, we definitely need 13 boats ythe largest 12 boats are too small yInteger L.P. techniques found solution with 14 boats xbut not 13 boats using 189 cpu hours in 1994/5

13
13 Formulation & Heuristics critical zSmith designated the 13 host boats ythose with the largest spare capacity zThis means that failure to find solution not definitive ymight be a solution with different choice of boats ylargest 13 boats might be better irrespective of spare capacity xlarge boat with large crew may be best staying put as host zNow we know h boats 1-13, g boats 1=26, times 1-6 zPrimary variables will be h gt, domain D = { 1 … 13 } yvariable gives location of guest crew g at time t

14
14 Secondary variables zLike carry’s in Donald + Gerald, useful for search ydomains will be {0,1} yalso helpful for formulation zv ght = 1 h gt = h yI.e. v ght = 1 iff guest crew g visits host h at time t zm gft = 1 h gt = h ft yI.e. m gft = 1 iff guest crews g and f meet at time t

15
15 Constraints for a party zAutomatically have that crews do not split ywe have to allocate location of whole crew at once zNeed to link up primary and secondary variables yusing constraints summarised on previous slide xe.g. v ght = 1 h gt = h zOther constraints now expressible zFirst one does not need secondary vars: yCrews do not visit same boat twice xAllDifferent(h g1,h g2, …, h g6 ) one for all g = 1, 2, … 26

16
16 More constraints for a party zUse variables about crews meeting: yTwo guest crews do not meet twice (or more) xm gf1 + m gf2 + … + m gf6 < 2 one for all pairs f, g zUse variables about visits by guest crews yassume that S h is spare capacity of host boat h yand that C g is size of crew of guest boat g xc 1 v 1ht + c 2 v 2ht + … + c 26 v 26ht S h one for all pairs h, t zSome “symmetry” constraints I won’t detail ye.g. to distinguish guest boats with same size crew

17
17 Heuristics zBoth variable and value ordering heuristics used zVariable ordering heuristic had 5 levels … zOnly considered primary variables h gt yConsider time periods in order (e.g. h 71 before h 32 ) xuse minimum remaining value within that so that guest crews with fewest possible hosts allocated first break ties by picking variables in most constraints –if still tied, pick biggest guest crew zValue ordering was much simpler ytry host crews (values) in descending order of spare capacity

18
18 We have ourselves a party zConstraint programming (ILOG Solver) won! zThis managed to schedule the party in 27 mins y1994/5 cpu times zIn general, Constraints not always better than ILP zIn this case, constraints were very tight zWhere constraints looser, often ILP better

19
19 And Finally … zThe real party was scheduled by hand ysince the CP solution was not done until months later zBUT ythe real party used more host boats than it needed to yand ILOG Solver found a solution for a 7 th half hour ySo with constraint programming … xThey could have had a longer party!!

Similar presentations

Presentation is loading. Please wait....

OK

Chapter 5 Constraint Satisfaction Problems

Chapter 5 Constraint Satisfaction Problems

© 2018 SlidePlayer.com Inc.

All rights reserved.

To ensure the functioning of the site, we use **cookies**. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy & Terms.
Your consent to our cookies if you continue to use this website.

Ads by Google

Ppt on business marketing management Ppt on world book day april Ppt on operation research introduction Ppt on community health and environment Ppt on indian food industry Ppt on road accidents videos Ppt on obesity prevention in schools Ppt on swami vivekananda books Ppt on column chromatography steps Ppt on old english literature