UI CS 4420 - Constraint Satisfaction

Unformatted text preview:

11Constraint SatisfactionConstraint SatisfactionReading: Russell & Norvig Chapter 5,Kumar, “Algorithms for constraint satisfaction problems: A survey”2Overview• Constraint Processing offers a powerful problem-solving paradigm– View a problem as a set of variables to which we have to assign values that satisfy a number of problem-specific constraints.– Constraint programming, CSPs, constraint logic programming…• Algorithms for CSPs– Backtracking (systematic search)– Constraint propagation (k-consistency)– Variable ordering heuristics– Backjumping and dependency-directed backtracking3Informal Definition of CSP• CSP = Constraint Satisfaction Problem•Given(1) a finite set of variables(2) each with a domain of possible values (often finite)(3) a set of constraints that limit the values the variables can take on•A solution is an assignment of a value to each variable such that the constraints are all satisfied.• Tasks might be to decide if a solution exists, to find a solution, to find all solutions, or to find the “best solution” according to some metric.24SEND + MORE = MONEYAssign distinct digits to the lettersS, E, N, D, M, O, R, Ysuch that S E N D+ M O R E= M O N E Yholds.5SEND + MORE = MONEYAssign distinct digits to the lettersS, E, N, D, M, O, R, Ysuch that S E N D+ M O R E= M O N E Yholds.Solution9 5 6 7+ 1 0 8 5= 1 0 6 5 26ModelingFormalize the problem as a constraint problem:• number of variables: n• constraints: c1,…,cm ⊆Ζn• problem: Find a = (v1,…,vn)∈Ζnsuch that a ∈ ci, for all 1 ≤ i ≤ m37A Model for MONEY• number of variables: 8• constraints:c1= {(S,E,N,D,M,O,R,Y)∈Ζ8 | 0 ≤ S,…,Y ≤ 9 }c2= {(S,E,N,D,M,O,R,Y)∈Ζ8 |1000*S + 100*E + 10*N + D+ 1000*M + 100*O + 10*R + E= 10000*M + 1000*O + 100*N + 10*E + Y}8A Model for MONEY (continued)• more constraints c3= {(S,E,N,D,M,O,R,Y)∈Ζ8 | S ≠ 0 }c4= {(S,E,N,D,M,O,R,Y)∈Ζ8 | M ≠ 0 }c5= {(S,E,N,D,M,O,R,Y)∈Ζ8 | S…Y all different}9Solution for MONEYc1= {(S,E,N,D,M,O,R,Y)∈Ζ8 | 0≤S,…,Y≤9 }c2= {(S,E,N,D,M,O,R,Y)∈Ζ8 |1000*S + 100*E + 10*N + D+ 1000*M + 100*O + 10*R + E= 10000*M + 1000*O + 100*N + 10*E + Y}c3= {(S,E,N,D,M,O,R,Y)∈Ζ8 | S ≠ 0 }c4= {(S,E,N,D,M,O,R,Y)∈Ζ8 | M ≠ 0 }c5= {(S,E,N,D,M,O,R,Y)∈Ζ8 | S…Y all different}Solution: (9,5,6,7,1,0,8,2)∈Ζ8410Informal Example: Map Coloring• Color the following map using three colors (red, green, blue) such that no two adjacent regions have the same color.ED ACB11Example: Map Coloring• Variables: A, B, C, D, E all of domain RGB• Domains: RGB = {red, green, blue}• Constraints: A≠B, A≠C,A ≠ E, A ≠ D, B ≠ C, C ≠ D, D ≠ E• One solution: A=red, B=green, C=blue, D=green, E=blueED ACBED ACB=>12Example: SATisfiability• Given a set of propositions containing variables, find an assignment of the variables to {false,true} that satisfies them.• Example, the clauses:– A or B or ~C, ~A or D– (equivalent to C -> A or B, D -> A)• Are satisfied byA = falseB = trueC = falseD = false513Real-world problems• Scheduling• Temporal reasoning• Building design• Planning• Optimization/satisfaction• Vision• Graph layout• Network management• Natural language processing• Molecular biology / genomics• VLSI design14Formal definition of a constraint network (CN)A constraint network (CN) consists of• a set of variables X = {x1, x2, … xn} – each with an associated domain of values {d1, d2, … dn}. – The domains are typically finite• a set of constraints {c1, c2… cm} where– each constraint defines a predicate which is a relation over a particular subset of X. – E.g., Ciinvolves variables {Xi1, Xi2, … Xik} and defines the relation Ri⊆ Di1x Di2x … Dik• Unary constraint: only involves one variable• Binary constraint: only involves two variables15Formal definition of a CN (cont.)• Instantiations–An instantiation of a subset of variables S is an assignment of a legal domain value to each variable in in S–An instantiation is legal iff it does not violate any (relevant) constraints.•A solution is an instantiation of all of the variables in the network.616Typical Tasks for CSP• Solutions:–Does a solution exist?–Find one solution–Find all solutions–Given a partial instantiation, do any of the above• Transform the CN into an equivalent CN that is easier to solve.17Binary CSP•A binary CSP is a CSP in which all of the constraints are binary or unary.• Any non-binary CSP can be converted into a binary CSP by introducing additional variables.• A binary CSP can be represented as a constraint graph, which has a node for each variable and an arc between two nodes if and only there is a constraint involving the two variables.– Unary constraint appears as self-referential arc18Solving Constraint Problems• Systematic search–Generate and test–Backtracking• Constraint propagation (consistency)• Variable ordering heuristics• Backjumping and dependency-directed backtracking719Generate and test• Try each possible combination until you find one that works:–Hoses –hike –run –hike –no–Hoses –hike –run –hike –be–Hoses –hike –run –hike –us• Doesn’t check constraints until all variables have been instantiated• Very inefficient way to explore the space of possibilities20Systematic search: Backtracking(a.k.a. depth-first search)• Consider the variables in some order• Pick an unassigned variable and give it a provisional value such that it is consistent with all of the constraints• If no such assignment can be made, we’ve reached a dead end and need to backtrack to the previous variable• Continue this process until a solution is found or we backtrack to the initial variable and have exhausted all possible values21Example: Crossword Puzzle12 345822Running Example: XWORD Puzzle• Variables and their domains– X1 is 1 across D1 is 5-letter words– X2 is 2 down D2 is 4-letter words– X3 is 3 down D3 is 3-letter words– X4 is 4 across D4 is 4-letter words– X5 is 5 across D5 is 2-letter words• Constraints (implicit/intensional)– C12 is “the 3rd letter of X1 must equal the 1st letter of X2”– C13 is “the 5th letter of X1 must equal the 1st letter of X3”.– C24 is …– C25 is …– C34 is ...23Backtracking: XWORD12345∅X1=hoses X1=laserX2=aronX2=sameX2=hikeX2=hike………X3=runX3=sun X3=letX4=hikeX4=same…ho se suname24Elements of


View Full Document
Download Constraint Satisfaction
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Constraint Satisfaction and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Constraint Satisfaction 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?