Constraint Satisfaction Problems Problems Artificial Intelligence - - PDF document

constraint satisfaction problems problems
SMART_READER_LITE
LIVE PREVIEW

Constraint Satisfaction Problems Problems Artificial Intelligence - - PDF document

Constraint Satisfaction Problems Problems Artificial Intelligence AIMA 2 nd edition, chapter 5 Section 1 3 Hadi Moradi 1 Outline Constraint Satisfaction Problems (CSP) Backtracking search for CSPs B kt ki h f CSP Local


slide-1
SLIDE 1

1

Constraint Satisfaction Problems Problems

Artificial Intelligence AIMA 2nd edition, chapter 5 Section 1 – 3 Hadi Moradi

1

Outline

Constraint Satisfaction Problems (CSP)

B kt ki h f CSP

Backtracking search for CSPs Local search for CSPs

2

slide-2
SLIDE 2

2

Constraint satisfaction problems (CSPs)

CSP:

  • State
  • goal test
  • 3

Example: Map-Coloring

  • Variables

4

  • Domains
  • Constraints:
slide-3
SLIDE 3

3

Example: Map-Coloring

5

Solutions are complete and consistent assignments,

Constraint graph

Binary CSP: each constraint relates two variables

  • Constraint graph: nodes are variables, arcs are constraints
  • 6
slide-4
SLIDE 4

4

Varieties of CSPs

Discrete variables

finite domains: infinite domains:

7 Continuous variables

  • Varieties of constraints

Unary constraints involve a single variable, Binary constraints involve pairs of variables,

8

Higher-order constraints involve 3 or more

variables,

slide-5
SLIDE 5

5

Real-world CSPs

Assignment problems Timetabling problems Transportation scheduling

9

p g

Factory scheduling

Standard search formulation (incremental)

Let's start with the straightforward approach, then fix it

  • Initial state:

Initial state:

  • Successor function
  • Goal test:

B anching facto

10

1.

Branching factor:

slide-6
SLIDE 6

6

Backtracking search

  • Variable assignments are commutative}, i.e.,

[ WA = red then NT = green ] same as [ NT = green then WA = red ]

  • Depth-first search for CSPs with single-variable assignments is called

backtracking search

11

  • Can solve n-queens for n ≈ 25

Backtracking search

12

slide-7
SLIDE 7

7

Backtracking example

13

Backtracking example

14

slide-8
SLIDE 8

8

Backtracking example

15

Backtracking example

16

slide-9
SLIDE 9

9

Improving backtracking efficiency

General-purpose methods can give huge

gains in speed: gains in speed:

Which variable should be assigned next? In what order should its values be tried?

17

Can we detect inevitable failure early?

Minimum Remaining Variable

18

slide-10
SLIDE 10

10

Degree Heuristic

Choose the Most constraining variable:

19

Least constraining value

Given a variable, choose the least

constraining value: constraining value:

  • 20
slide-11
SLIDE 11

11

Forward checking

Idea:

Keep track of remaining legal values for unassigned variables

p g g g

Terminate search when any variable has no legal values

21

Forward checking

22

slide-12
SLIDE 12

12

Forward checking

23

Forward checking

24

slide-13
SLIDE 13

13

Constraint propagation

Forward checking doesn't provide early detection for all

failures: failures:

  • 25

Arc consistency

Simplest form of propagation makes each arc consistent

X Y i i t t iff

X Y is consistent iff

  • for every value x of X there is some allowed y

26

slide-14
SLIDE 14

14

Arc consistency

Simplest form of propagation makes each arc consistent

X Y i i t t iff

X Y is consistent iff

  • for every value x of X there is some allowed y

27

Arc consistency

If X loses a value, neighbors of X need to be rechecked

  • 28
slide-15
SLIDE 15

15

Arc consistency

  • 29

Arc consistency algorithm AC-3

30

slide-16
SLIDE 16

16

Local search for CSPs

Hill-climbing, simulated annealing typically work with

"complete" states, i.e., all variables assigned

To apply to CSPs: 31

Example: 4-Queens

States: 4 queens in 4 columns (44 = 256 states)

  • Actions: move queen in column
  • Goal test: no attacks
  • Evaluation: h(n) = number of attacks
  • 32
slide-17
SLIDE 17

17

Summary

  • CSPs are a special kind of problem:
  • states defined by values of a fixed set of variables
  • goal test defined by constraints on variable values
  • goal test defined by constraints on variable values
  • Backtracking = depth-first search with one variable assigned per node
  • Variable ordering and value selection heuristics help significantly
  • Forward checking prevents assignments that guarantee later failure
  • Constraint propagation (e.g., arc consistency) does additional work to

constrain values and detect inconsistencies

33

constrain values and detect inconsistencies

  • Iterative min-conflicts is usually effective in practice