# Constraint-based problem solving - PowerPoint PPT Presentation

Constraint-based problem solving

1 / 6
Constraint-based problem solving

## Constraint-based problem solving

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

1. Constraint-based problem solving • Model problem • specify in terms of constraints on acceptable solutions • define variables (denotations) and domains • define constraints in some language • Solve model • define search space / choose algorithm • incremental assignment / backtracking search • complete assignments / stochastic search • design/choose heuristics • Verify and analyze solution

2. Example: n-queens • Place n-queens on an n  n board so that no pair of queens attacks each other • CSP formulation: • variable for each row: x1, …, xn • domains are possible column positions: {1, …, n} • binary constraints between each pair of variables not same column and not same diagonal

3. Example: 4-queens 1 2 3 4 x1 Constraints: xi  xjand | xi - xj | | i- j| x2 x3 x4

4. Example: 4-queens One solution: x1  2 x2  4 x3  1 x4  3 1 2 3 4 x1 Q x2 Q x3 Q x4 Q

5. Search graph for 4-queens (1,1,1,2) (1,1,4,2) 4 (1,1,1,1) 1 6 (1,1,1,3) 3 (3,1,4,2) 0 (1,1,1,4) 4 (1,4,1,3) 1 (4,1,4,2) 1 (2,4,1,3) 0

6. Pick queen in conflict x1 Q x2 2 1 Q 1 x3 Q x4 Q Move to min. conflicts Pick queen in conflict x1 x1 Q Q x2 Q x2 Q x3 Q x3 0 2 2 Q x4 Q x4 Q Stochastic search Initial assignment x1 Q x2 Q x3 Q x4 Q