Transcription of 5 CONSTRAINT SATISFACTION PROBLEMS
1 5 CONSTRAINTSATISFACTIONPROBLEMSI nwhich weseehowtreatingstatesasmore thanjustlittleblack boxesleadsto theinventionofa range ofpowerfulnew search methodsanda deeperunderstandingofproblemstructure and4 exploredtheideathatproblemscanbesolvedby searchinginaspaceofstates. Thesestatescanbeevaluatedbydomain-specif icheuristicsandtestedtoseewhetherthey ,however,eachstateis is representedbyanarbi-BLACKBOX trarydatastructurethatcanbeaccessedonlyb ytheproblem-specificroutines thesuccessorfunction,heuristicfunction, , whosestatesandgoaltestconformtoa standard,structured,andverysimplereprese ntation( ).
2 Searchal-REPRESENTATION gorithmscanbedefinedthattake advantageofthestructureofstatesandusegen eral-purposeratherthanproblem-specifiche uristicsto enablethesolutionoflargeproblems( ).Perhapsmostimportantly, thestandardrepresentationofthegoaltestre vealsthestruc-tureoftheproblemitself( ).Thisleadstomethodsforproblemdecomposit ionandtoanunderstandingoftheintimateconn ectionbetweenthestructureofa ,aconstraintsatisfactionproblem(orCSP)is definedbya setofvari-CONSTRAINTSATISFACTIONPROBLEM ables,X1; X2; : : : ; Xn, anda setofconstraints,C1; C2; : : : ; Cm.
3 EachvariableXihasaVARIABLESCONSTRAINTS nonemptydomainDiofpossiblevalues. definedbyanassignmentofvaluesto someorallofthevariables,fXi=vi; Xj=ASSIGNMENTvj; : : :g. Anassignmentthatdoesnotviolateany constraintsis oneinwhicheveryvariableis mentioned,andaso-lutiontoa CSPis a solutionthatmaximizesanobjective ,havingtiredofRomania,wearelookingata mapofAustraliashowingeachofitsstatesandt erritories, (a),andthatwearegiventhetaskofcoloringea chregioneitherred,green,orblueinsucha waythatnoneighboringregionshave thesamecolor. To formulatethisasa CSP, wedefinethevariablestobetheregions:WA,NT ,Q,NSW,V,SA, andT.
4 Thedomainofeachvariableis thesetfred;green;blueg. Theconstraintsrequireneighboringregionst ohave distinctcolors;forexample,theallowableco mbinationsforWAandNTarethepairsf(red;gre en);(red;blue);(green;red);(green;blue); (blue;red);(blue;green)g:(Theconstraintc analsoberepresentedmoresuccinctlyasthein equalityWA6=NT, pro-videdtheconstraintsatisfactionalgori thmhassomewayto evaluatesuchexpressions.)Therearemany possiblesolutions,suchasfWA=red;NT=green ; Q=red;NSW=green; V=red;SA=blue; T=redg:It is helpfultovisualizea CSPasaconstraintgraph, (b). problemasa a CSPconformsto astandardpattern thatis,a setofvariableswithassignedvalues thesuccessorfunctionandgoaltestcanwritte nina ,wecandevelopeffective,genericheuristics thatrequirenoadditional, , thestructureoftheconstraintgraphcanbeuse dtosim-plifythesolutionprocess,insomecas esgivinganexponentialreductionincomplexi ty.
5 TheCSPrepresentationis thefirst,andsimplest,ina South WalesVictoriaTasmaniaWANTSAQNSWVT(a)(b)F igure (a) toassigncolorstoeachregionsothatnoneighb oringregionshave thesamecolor. (b)Themap-coloringproblemrepresentedasa is fairlyeasyto seethata CSPcanbegivenanincrementalformulationasa standardsearchproblemasfollows:}Initials tate: theemptyassignmentfg, inwhichallvariablesareunassigned.}Succes sorfunction: a valuecanbeassignedtoany unassignedvariable,providedthatit doesnotconflictwithpreviouslyassignedvar iables.}Goaltest: thecurrentassignmentis complete.
6 }Pathcost: a constantcost( ,1) completeassignmentandthereforeappearsatd epthnif ,thesearchtreeextendsonlytodepthn. Forthesereasons,depth-firstsearchalgorit hmsarepopularforCSPs.( )It is alsothecasethatthepathbywhich a solutionis reachedis ,wecanalsouseacomplete-stateformulation, inwhicheverystateis a ( ) canalsobeviewedasa finite-domainCSP, wherethevariablesQ1; : : : ; Q8arethepositionsofeachqueenincolumns1; : : : ;8andeachvariablehasthedomainf1;2;3;4;5; 6;7;8g. If themaximumdomainsizeofany variableina CSPisd, thenthenumberofpossiblecompleteassignmen tsisO(dn) thatis, , whosevariablescanbeeithertrueorfalse.
7 BooleanCSPsincludeBOOLEANCSPS asspecialcasessomeNP-completeproblems,su chas3 SAT. (SeeChapter7.)Intheworstcase,therefore,w ecannotexpecttosolve ,however, general-purposeCSPalgorithmscansolve problemsorders ofmagnitudelargerthanthosesolvableviathe general-purposesearchalgorithmsthatwesaw forexample, ,whenschedulingconstructionjobsontoa calendar, eachjob sstartdateis a ,it is , ,ifJob1, whichtakesfive days,mustprecedeJob3, thenwewouldneeda constraintlanguageofalgebraicinequalitie ssuchasStartJob1+ 5 StartJob3. It is alsonolongerpossibletosolve suchconstraintsbyenumeratingallpossiblea ssignments,becausethereareinfinitelymany (whichwewillnotdiscusshere)existforlinea rconstraintsonintegervariables thatis, constraints ,suchastheonejustgiven , , ,ina schedulingproblem.
8 Thestartandfinishofeachobservationandman euverarecontinuous-valuedvariablesthatmu stobey a varietyofastronomical,precedence, thatoflinearprogrammingproblems, timepolynomialin functionshave alsobeenstudied quadraticprogramming,second-orderconicpr ogramming, ,it is usefultolookat theunaryconstraint, whichrestrictstheUNARY CONSTRAINT valueofa ,it couldbethecasethatSouthAustraliansactive lydislike thecolorgreen. Everyunaryconstraintcanbeeliminatedsimpl ybypreprocessingthedomainofthecorrespond ingvariabletoremove any ,SA6=NSWis a CONSTRAINT binaryCSPis onewithonlybinaryconstraints;it canberepresentedasa constraintgraph, (b).
9 Higher-orderconstraintsinvolve ( (a).)It is usualtoinsistthateachletterinCRYPTARITHM ETICa cryptarithmeticpuzzlerepresenta (a)),thiswouldberepresentedasthesix-vari ableconstraintAlldi (F; T; U; W; R; O). Alternatively, it canberepresentedbya collectionofbinaryconstraintssuchasF6=T. Theadditionconstraintsonthefourcolumnsof thepuzzlealsoinvolve severalvariablesandcanbewrittenasO+O=R+ 10 X1X1+W+W=U+ 10 X2X2+T+T=O+ 10 X3X3=FwhereX1,X2, andX3areauxiliaryvariablesrepresentingth edigit(0or1)carriedover , (b).Thesharp-eyedreaderwillhave noticedthattheAlldi constraintcanbebrokendownintobinaryconst raints F6=T,F6=U, , , everyhigher-order, finite-domainconstraintcanbereducedto a setofbinaryconstraintsif , describedsofarhave allbeenabsoluteconstraints,violationofwh ichrulesouta ,ina universitytimetablingproblem, teachingat 2 solution( ), forexample, pointsagainsttheoverallobjective function, , (a)OWTFUR(b)+FTTOWWUOORX3X1X2 Figure (a)A distinctdigit.
10 Theaimistofinda substitutionofdigitsforletterssuchthatth eresultingsumis arithmeticallycorrect,withtheaddedrestri ctionthatnoleadingzeroesareallowed.(b)Th econstrainthypergraphforthecryptarithmet icproblem,showingtheAlldi a squareboxconnectedtothevariablesit , donotdiscusssuchCSPsfurtherinthischapter , a ,any ofthesearchalgorithmsfromChapters3 and4 cansolve quicklynoticesomethingterrible:thebranch ingfactorat thetoplevel isnd, becauseanyofdvaluescanbeassignedtoany ,thebranchingfactoris(n 1)d, generatea treewithn! dnleaves,eventhoughthereareonlydnpossibl ecompleteassignments!