1Constraint satisfaction basically boils down to graph coloring.2Graph coloring is NP complete, so any solution is *worst case* exponential time.This is a valid 4-coloring…we’re just not using the 4thcolor!3Note map coloring can be defined as graph coloring. Each state in map is represented as a node in the graph, with edges between nodes if the states are adjacentAll map coloring can be represented as graph coloring, but not all graph coloring can be represented as map coloring. This is because maps are planar graphs.4Complete: every state is colored. Consistent: it’s a valid soln.5Binary CSP can usually be expressed as a graph, because each edge has 2 endpoints, so each edge can be one constraint.6Example ([(V2,V3),{(R,B),…}]): the possible values the tuple (V2,V3) can take7The second example is an easier way to write the first.Higher order example: allDif(X,Y,Z)allDif(X,Y,Z) means X,Y, and Z all must be different.8Note you can convert any CSP to binary. Ex: diff(X,Y,Z) diff(X,Y), diff(Y,Z), 9diff(Z,X)When you convert to binary, # of constraints can blow upi: column10Qi: row1112131415In addition to what we said before, need to wait for Oi1to finish before Oi2can start, 1612etc.Sij: start time for operation j of job i17jTij: duration of operation j of job i18How to use DFS? For example, you’d have a tree with root as start state, children 19as V1=red, V1=blue, V1=green, and then branch out on V2, etc.How many possible successors? Number of colors.20You’ll get to the bottom of the tree and have to backtrack because you made a dumb assignment.You can check if V1 and V2 don’t violate.How do you pick which node to explore next? Choose the most constrained node. But we’re not going to get that smart yet.212223This can be really slow.2425This works slightly better than DFS.26Place X’s in places that can’t be red anymore. If V1 is red, then V2V4and V5can’t 271 245be assigned red.282930The X’s mean there are whole branches of the search tree that we don’t look at. 31We still need to backtrack, but this is much more efficient. This is an example of pruning a search tree (chopping off branches)32This is even better.33343536Uh oh, V5 can only be one color. Take it. This is a key difference37Now that you set V5, V4can now only be one color!383940Fail-first is good, because you don’t waste your time looking at branches of the 41search tree that can’t possibly work.Pick green for V3as it adds no new constraints (We already know that V4can’t be
View Full Document