chapter 5 outline
DESCRIPTION
Chapter 5 Outline. Formal definition of CSP CSP Examples Backtracking search for CSPs Problem structure and problem decomposition Local search for CSPs. Constraint Satisfaction Problems. World state : well defined set of variables V i with domain D i - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/1.jpg)
Chapter 5 Outline
•Formal definition of CSP
•CSP Examples
•Backtracking search for CSPs
•Problem structure and problem decomposition
•Local search for CSPs
![Page 2: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/2.jpg)
Constraint Satisfaction Problems• World state: well defined set of variables Vi with domain Di
• Goal test: satisfy a set of constraints that specify allowable combinations of values for subsets of variables
• Depth first search appropriate – path doesn’t matter, only goal state, maximum depth fixed at n, the number of variables, select 1 variable to branch on at each level of the tree
• Backtracking: once a constraint is violated there is no point looking further
• Forward checking: reduce branching factor by “shrinking” domains of un-set variables to reflect constraints imposed by already set variables. Backtrack if any un-set variables domain is empty
![Page 3: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/3.jpg)
Formal Definition: CSP• Constraint Satisfaction Problem (CSP)
– Set of Variables: X1, X2, X3, … Xn
– Each Xi has a non-empty domain Di of possible values, vi.
– Set of Constraints: C1, C2, … Cn
– Each Ci has a subset of variables specifying the combination of vi’s.
![Page 4: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/4.jpg)
Constraint Satisfaction Problems– A problem state or assignment is represented by:
• {Xi = vi, Xj = vi, ...}
– An assignment is consistent if no constraints are violated.
– Constraint Graph• Nodes represent variables
• Arcs represent constraints
![Page 5: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/5.jpg)
Simple CSPs• CSPs with discrete variables and finite domains.
– Map-coloring (graph coloring)– SAT (3SAT) (NP-Complete)– N-Queens
![Page 6: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/6.jpg)
Any CSP can be reformulated into the standard notation (Set of Variables: X1, X2, X3, … Xn, Set of Constraints: C1, C2, … Cn, Bla bla)
Why would we do that?
Question
![Page 7: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/7.jpg)
CSP Example• Graph coloring is a good example of a CSP.
– Graphs are also good for representing constraints!– Assume we can use the colors {red, blue, yellow}– Can we color the graph such that a each adjacent node has a
different color?
X1 X2
X3
X4
X5
Let’s choose blue for X1?
What color can we choose for X2?
Now what can wechoose for X3?
Does it matter what color we choose forX4?
What about X5?
What if we connectX5 to X2?
![Page 8: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/8.jpg)
CSP Example
• What happens if we only have two colors {red, blue}?
X1 X2
X3
X4
X5
Does adding the link betweenX2 and X5 change the problem?
![Page 9: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/9.jpg)
Types of Constraints
• Unary Constraint– Constrains the value of a single variable.
• Binary Constraint– Relates two variables.
• N-ary Constraint– Relates multiple variables.
• Preference Constraint– Indicate preferred solutions.
![Page 10: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/10.jpg)
More complex CSPs• Discrete variables with infinite domains.
– For example, a set of integers.– Characteristic of such problems
• Cannot enumerate all variable combinations.
– Requires a constraint language.
• Continuous Domains– Example, linear progamming.
![Page 11: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/11.jpg)
CSP Search Approach: Backtracking• A depth-first search that chooses values for one
variable at a time and backtracks when a variable has no legal values left to assign is a backtracking search.
![Page 12: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/12.jpg)
Questions to address1. Which variable should we choose for
assignment?
2. What order should we assign values?
3. What are the implications of the current variable assignments on the other unassigned variables?
4. When a path fails, how do we avoid repeating the failure on subsequent paths?
![Page 13: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/13.jpg)
Which variable to assign?• Which variable to assign?
– Standard backtracking uses some arbitrary/fixed ordering and simply assigns the next available variable.
• It is rare that this is efficient.
– Is there a way to chose the variable with the fewest “legal” values?
![Page 14: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/14.jpg)
Which variable to assign?• Minimum remaining values (MRV)
– Simply select the variable with the fewest “legal” values.
– If a variable has no legal values, then MRV selects the variable and the failure is immediately detected.
– Can be implemented by changing the selection criteria of backtracking search.
![Page 15: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/15.jpg)
Which variable to assign?• MRV is useful if you have already started the
search.
• But how is the first variable chosen?– Degree Heuristic
• Choose the variable involved with the largest number of constraints with other unassigned variables.
• Can also be used as a tie-breaker in all other situations.
![Page 16: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/16.jpg)
Which variable to assign?
• Degree HeuristicX1 X2
X3
X4
X5
Which Variable has the largest number of constraints?
![Page 17: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/17.jpg)
Choosing a value to assign• Chose the value that rules out the fewest choices
for the neighboring variables in the constraint graph. (Least-Constraining-Value)– Attempts to provide maximum flexibility for remaining
variable assignments
![Page 18: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/18.jpg)
What are the implications of an assignment?
• Can we reduce the search space by looking at constraints earlier in the search process?
•Forward Checking•Constraint Propagation
![Page 19: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/19.jpg)
Forward Checking• When variable X is assigned, check each
unassigned variable Y connected to X by a constraint.
• Delete from Y’s domain any value that is inconsistent with the value assigned to X.
![Page 20: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/20.jpg)
Constraint Propagation• Propagate the implications of a constraint on one
variable onto other variables.– Must be able to do this quickly. – Why?
![Page 21: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/21.jpg)
Arc Consistency• Requires a directed arc in the consistency graph.
• Provides early detection of inconsistencies.– Must be applied repeatedly to detect ALL constraints.
![Page 22: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/22.jpg)
![Page 23: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/23.jpg)
![Page 24: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/24.jpg)
![Page 25: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/25.jpg)
K-Consistency• A CSP is k-consistent if for any set of k – 1
variables and for any constraint assignment to those variables, a consistent value can always be assigned to any kth value.
![Page 26: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/26.jpg)
K-Consistency– Node Consistency (1-Consistency)
• Each individual variable is consistent.
– 2-Consistency = arc consistency
– Path Consistency (3-Consistency)• Any pair of adjacent variables can always be extended
to a third neighboring variable.
– Stronger consistency checks require more processing time but reduce the branching factor and detection of inconsistencies.
![Page 27: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/27.jpg)
Special Constraints• AllDiff – All variables must have distinct values.
– To satisfy this constraint for m variables and n values, n >= m. Why?
• Resource (atmost) constraint– Define an atmost constraint value and then add the
minimum values of the current domains. – The sum must be less than or equal to the constraint
value.
![Page 28: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/28.jpg)
How is repeating failures avoided?
• Chronological backtracking– Backs up to the most recent decision point and tries a
different value for it.
![Page 29: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/29.jpg)
Chronological BacktrackingX1 X2
X3
X4
X5
Simple backtracking takesus to X5. What happens?
• Back up to the conflict set– The variables that caused the problem.– Typically the set for X is the set of previously
assigned variables connected to X by constraints.
![Page 30: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/30.jpg)
Backjumping• Backtracks to the most recent variable in the
conflict set.– Every branch pruned by backjumping is also pruned
by forward checking.
![Page 31: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/31.jpg)
Conflict-directed backjumping
• Modify backjumping to use conflict sets that include not only the variables with a direct conflict but also any subsequent variables with no consistent solution. – Look backwards and expand the conflict set.
![Page 32: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/32.jpg)
Conflict-Directed Backjumping– Let Xj be the current variable, and let conf(Xj) be its
conflict set. If every possible value for Xj fails, backjump to the most recent variable Xi in conf (Xj), and set conf (Xi) conf(Xi) conf(Xj) – {Xi}.
• Does this stop us from making the same mistake in another branch of the same tree?
![Page 33: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/33.jpg)
Local Search• Section 4.3 discussed local search algorithms.
– Can be quite effective for CSP.• Fairly efficient
• Can be used on-line when a problem changes.
![Page 34: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/34.jpg)
![Page 35: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/35.jpg)
![Page 36: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/36.jpg)
![Page 37: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/37.jpg)
![Page 38: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/38.jpg)
![Page 39: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/39.jpg)
![Page 40: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/40.jpg)
![Page 41: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/41.jpg)
![Page 42: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/42.jpg)
![Page 43: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/43.jpg)
![Page 44: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/44.jpg)
![Page 45: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/45.jpg)
![Page 46: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/46.jpg)
![Page 47: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/47.jpg)
![Page 48: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/48.jpg)
![Page 49: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/49.jpg)
![Page 50: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/50.jpg)
![Page 51: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/51.jpg)
![Page 52: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/52.jpg)
![Page 53: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/53.jpg)
![Page 54: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/54.jpg)
![Page 55: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/55.jpg)
![Page 56: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/56.jpg)
![Page 57: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/57.jpg)
![Page 58: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/58.jpg)
![Page 59: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/59.jpg)
![Page 60: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/60.jpg)
![Page 61: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/61.jpg)
![Page 62: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/62.jpg)
![Page 63: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/63.jpg)
![Page 64: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/64.jpg)
![Page 65: Chapter 5 Outline](https://reader035.vdocuments.net/reader035/viewer/2022062408/56812fc6550346895d9546d3/html5/thumbnails/65.jpg)