+ All Categories
Home > Documents > Constraint Satisfaction Problems

Constraint Satisfaction Problems

Date post: 05-Jan-2016
Category:
Upload: dacia
View: 26 times
Download: 1 times
Share this document with a friend
Description:
Constraint Satisfaction Problems. Constraint Satisfaction Problem (CSP) Set of Variables: X 1 , X 2 , X 3 , … X n Set of Constraints: C 1 , C 2 , … C n Each X i has a non-empty domain D i of possible values, v i . Each C i has a subset of variables specifying the combination of v i ’s. - PowerPoint PPT Presentation
Popular Tags:
29
Constraint Satisfaction Problems • Constraint Satisfaction Problem (CSP) Set of Variables: X 1 , X 2 , X 3 , … X n Set of Constraints: C 1 , C 2 , … C n Each X i has a non-empty domain D i of possible values, v i . Each C i has a subset of variables specifying the combination of v i ’s.
Transcript
Page 1: Constraint Satisfaction Problems

Constraint Satisfaction Problems

• Constraint Satisfaction Problem (CSP)– Set of Variables: X1, X2, X3, … Xn

– Set of Constraints: C1, C2, … Cn

– Each Xi has a non-empty domain Di of possible values, vi.

– Each Ci has a subset of variables specifying the combination of vi’s.

Page 2: Constraint Satisfaction Problems

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 3: Constraint Satisfaction Problems

CSP Example

• Graph coloring is a good example of a CSP.– 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 4: Constraint Satisfaction Problems

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 5: Constraint Satisfaction Problems

Characteristics of CSP

• Every problem must be a complete assignment. – Assume n variables, then search tree only goes

to depth n.– Depth first search typically applied.

• General CSP algorithms solve problems significantly larger than those that can be solved with general search algorithms.

Page 6: Constraint Satisfaction Problems

Simplest CSPs

• CSPs with discrete variables and finite domains. – Map-coloring– 8-Queens– Boolean CSPs – 3SAT (NP-Complete)

Page 7: Constraint Satisfaction Problems

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 8: Constraint Satisfaction Problems

Types of Constraints

• Unary Constraint– Constrains the value of a single variable.

• Binary Constraint– Relates two variables.

• Preference Constraint– Indicate preferred solutions.

Page 9: Constraint Satisfaction Problems

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.– What have we learned about backtracking in the

past?

Page 10: Constraint Satisfaction Problems

Questions to address

1. What variable to assign next and what order are the values to be tested?

2. What are the implications of the current variable assignments on the other unassigned variables?

3. When a path fails, how do we avoid repeating the failure on subsequent paths?

Page 11: Constraint Satisfaction Problems

Which variable to assign?

• Which variable to assign?– Standard backtracking 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 12: Constraint Satisfaction Problems

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 13: Constraint Satisfaction Problems

Which variable to assign?

• MRV is useful if have already started the search.

• 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 14: Constraint Satisfaction Problems

Which variable to assign?

• Degree Heuristic

X1 X2

X3

X4

X5

Which Variable has the largest number of constraints?

How does the algorithm know the order in which to examine values?

Page 15: Constraint Satisfaction Problems

Least-Constraining-Value

• Chose the value that rules out the fewest choices for the neighboring variables in the constraint graph.– Attempts to provide maximum flexibility for

remaining variable assignments

Page 16: Constraint Satisfaction Problems

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 17: Constraint Satisfaction Problems

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.– Problem: Does not catch all inconsistencies.

• Why?

Page 18: Constraint Satisfaction Problems

Constraint Propagation

• Propagate the implications of a constraint on one variable onto other variables.– Must be able to do this quickly. – Why?

Page 19: Constraint Satisfaction Problems

Arc Consistency

• Requires a directed arc in the consistency graph.

• Provides early detection of inconsistencies.– Must be applied repeatedly to detect ALL

constraints.

Page 20: Constraint Satisfaction Problems

Arc Consistency

X1 X2

X3

X4

X5

{R, Y, B} {R, Y, B}{Y, B}

{Y, B}{B}

{R, Y}

{R, Y, B}

{R, Y}

Still may not find all inconsistencies.

Page 21: Constraint Satisfaction Problems

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 22: Constraint Satisfaction Problems

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 23: Constraint Satisfaction Problems

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 24: Constraint Satisfaction Problems

How is repeating failures avoided?

• Chronological backtracking– Backs up to the most recent decision point and

tries a different value for it.

Page 25: Constraint Satisfaction Problems

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 26: Constraint Satisfaction Problems

Backjumping

• Backtracks to the most recent variable in the conflict set.– Every branch pruned by backjumping is also

pruned by forward checking.

Page 27: Constraint Satisfaction Problems

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 28: Constraint Satisfaction Problems

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 29: Constraint Satisfaction Problems

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.

• Min-conflicts heuristic– Choose the variable with the fewest conflicts with

other variables.


Recommended