Solving Constraint Satisfaction Problems: Arc Consistency and - - PDF document

solving constraint satisfaction problems arc consistency
SMART_READER_LITE
LIVE PREVIEW

Solving Constraint Satisfaction Problems: Arc Consistency and - - PDF document

Solving Constraint Satisfaction Problems: Arc Consistency and Constraint Propagation Brian Williams 16.410 - 13 September 29 th , 2003 Slides adapted from: 6.034 Tomas Lozano Perez and AIMA Stuart Russell & Peter Norvig 1 1 Outline


slide-1
SLIDE 1

1

Solving Constraint Satisfaction Problems: Arc Consistency and Constraint Propagation

1

Brian Williams 16.410 - 13 September 29th, 2003

Slides adapted from: 6.034 Tomas Lozano Perez and AIMA Stuart Russell & Peter Norvig

2

Outline

  • Recap: constraint satisfaction problems (CSP)
  • Solving CSPs
  • Arc-consistency and propagation
  • Analysis of constraint propagation
  • Search
slide-2
SLIDE 2

3

Solving CSPs

Solving CSPs involves some combination of:

  • 1. Constraint propagation
  • eliminates values that can’t be part of any

solution 2. Search

  • explores valid assignments

4

Arc Consistency

  • Directed arc (Vi, Vj) is arc consistent if
  • For every x in Di, there exists some y in Dj such that

assignment (x,y) is allowed by constraint Cij

  • Or ∀x∈Di ∃y∈Dj such that (x,y) is allowed by constraint Cij

where

  • ∀ denotes “for all”
  • ∃ denotes “there exists”
  • ∈ denotes “in”

Arc consistency eliminates values of each variable domain that can never satisfy a particular constraint (an arc). Vi Vj {1,2,3} {1,2} =

slide-3
SLIDE 3

5

Arc Consistency

  • Directed arc (Vi, Vj) is arc consistent if
  • ∀x∈Di ∃y∈Dj such that (x,y) is allowed by constraint Cij

Arc consistency eliminates values of each variable domain that can never satisfy a particular constraint (an arc). Vi Vj {1,2,3} {1,2} = Example: Given: Variables V1 and V2 with Domain {1,2,3,4} Constraint: {(1, 3) (1, 4) (2, 1)} What is the result of arc consistency?

6

Achieving Arc Consistency via Constraint Propagation

  • Directed arc (Vi, Vj) is arc consistent if

∀x∈Di ∃y∈Dj such that (x,y) is allowed by constraint Cij Arc consistency eliminates values of each variable domain that can never satisfy a particular constraint (an arc). Constraint propagation: To achieve arc consistency:

  • Delete every value from each tail domain Di of each arc

that fails this condition,

  • Repeat until quiescence:
  • If element deleted from Di then
  • check directed arc consistency for each arc with head Di
  • Maintain arcs to be checked on FIFO queue (no duplicates).
slide-4
SLIDE 4

7

Constraint Propagation Example

R,G,B G R, G

Graph Coloring

Initial Domains Different-color constraint

V1 V2 V3 Each undirected constraint arc denotes two directed constraint arcs.

8

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 Value deleted Arc examined

R,G,B G R, G

V2 V3 V1

Graph Coloring

Initial Domains

Arcs to examine V1-V2, V1-V3, V2-V3

  • Introduce queue of arcs to be examined.
  • Start by adding all arcs to the queue.
slide-5
SLIDE 5

9

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V1 > V2 Value deleted Arc examined

R,G,B G R, G

V2 V3 V1

Graph Coloring

Initial Domains

Arcs to examine V1<V2, V1-V3, V2-V3

  • Vi – Vj denotes two arcs between Vi and Vj.
  • Vi < Vj denotes an arc from Vj and Vi.
  • Delete unmentioned tail values

10

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 none V1 > V2 Value deleted Arc examined

Graph Coloring

Initial Domains R,G,B G R, G

V2 V3 V1 Arcs to examine V1<V2, V1-V3, V2-V3

  • Vi – Vj denotes two arcs between Vi and Vj.
  • Vi < Vj denotes an arc from Vj and Vi.
  • Delete unmentioned tail values
slide-6
SLIDE 6

11

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V2 > V1 none V1 > V2 Value deleted Arc examined

Graph Coloring

Initial Domains R,G,B G R, G

V2 V3 V1 Arcs to examine V1-V3, V2-V3

  • Vi – Vj denotes two arcs between Vi and Vj.
  • Vi < Vj denotes an arc from Vj and Vi.
  • Delete unmentioned tail values

12

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 none V2 > V1 none V1 > V2 Value deleted Arc examined

Graph Coloring

Initial Domains R,G,B G R, G

V2 V3 V1 Arcs to examine V1-V3, V2-V3

  • Vi – Vj denotes two arcs between Vi and Vj.
  • Vi < Vj denotes an arc from Vj and Vi.
  • Delete unmentioned tail values
slide-7
SLIDE 7

13

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R,G,B G R, G

V2 V3 V1 Arcs to examine V1-V3, V2-V3

  • Vi – Vj denotes two arcs between Vi and Vj.
  • Vi < Vj denotes an arc from Vj and Vi.
  • Delete unmentioned tail values

14

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V1>V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R,G,B G R, G

V2 V3 V1 Arcs to examine V1<V3, V2-V3

  • Vi – Vj denotes two arcs between Vi and Vj.
  • Vi < Vj denotes an arc from Vj and Vi.
  • Delete unmentioned tail values
slide-8
SLIDE 8

15

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V1(G) V1>V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R,G,B G R, G

V2 V3 V1 Arcs to examine V1<V3, V2-V3 IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

16

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V1(G) V1>V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R,G,B G R, G

V2 V3 V1 Arcs to examine V1<V3, V2-V3, V2>V1, V1<V3, IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

slide-9
SLIDE 9

17

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V1<V3 V1(G) V1>V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R, G

V2 V3 V1 Arcs to examine V2-V3, V2>V1

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

18

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 none V1<V3 V1(G) V1>V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R, G

V2 V3 V1 Arcs to examine V2-V3, V2>V1

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

slide-10
SLIDE 10

19

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V2 >V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R, G

V2 V3 V1 Arcs to examine V2<V3, V2>V1

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

20

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V2(G) V2 >V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R, G

V2 V3 V1 Arcs to examine V2<V3, V2>V1

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

slide-11
SLIDE 11

21

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V2(G) V2 >V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R, G

V2 V3 V1 Arcs to examine V2<V3, V2>V1 , V1>V2

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

22

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V3 > V2 V2(G) V2 >V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R

V2 V3 V1 Arcs to examine V2>V1 , V1>V2

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

slide-12
SLIDE 12

23

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 none V3 > V2 V2(G) V2 >V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R

V2 V3 V1 Arcs to examine V2>V1 , V1>V2

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

24

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V2>V1 V2(G) V2 -V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R

V2 V3 V1 Arcs to examine V1>V2

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

slide-13
SLIDE 13

25

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 none V2>V1 V2(G) V2 -V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R

V2 V3 V1 Arcs to examine V1>V2

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

26

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V1>V2 none V2>V1 V2(G) V2 -V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R

V2 V3 V1 Arcs to examine

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

slide-14
SLIDE 14

27

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V1(R) V1>V2 none V2>V1 V2(G) V2 -V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R

V2 V3 V1 Arcs to examine

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

28

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V1(R) V1>V2 none V2>V1 V2(G) V2 -V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains R, B G R

V2 V3 V1 Arcs to examine V2>V1, V3>V1

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

slide-15
SLIDE 15

29

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 V3>V1 V2>V1 V1(R) V2-V1 V2(G) V2 -V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains B G R

V2 V3 V1 Arcs to examine

  • Delete unmentioned tail values

IF An element of a variable’s domain is removed, THEN add all arcs to that variable to the examination queue.

30

Constraint Propagation Example

R,G,B G R, G Different-color constraint

V1 V2 V3 none V3>V1 none V2>V1 V1(R) V2-V1 V2(G) V2 -V3 V1(G) V1-V3 none V1 – V2 Value deleted Arc examined

Graph Coloring

Initial Domains B G R

V2 V3 V1 Arcs to examine IF examination queue is empty THEN arc (pairwise) consistent.

slide-16
SLIDE 16

31

Outline

  • What is a constraint satisfaction problem (CSPS)?
  • Solving CSPs
  • Arc-consistency and propagation
  • Analysis of constraint propagation
  • Search

32

What is the Complexity of Constraint Propagation?

Assume:

  • domains are of size at most d
  • there are e binary constraints.

Which is the correct complexity? 1. O(d2) 2. O(ed2 ) 3. O(ed3) 4. O(ed)

slide-17
SLIDE 17

33

Complexity of Constraint Propagation

Assume:

  • domains are of size at most d
  • there are e binary constraints.

Complexity:

  • Straight forward arc consistency is O(ed3)
  • There are 2 * e arcs to check
  • Verifying arc consistency takes O(d2) for each arc.
  • An arc is checked at most O(d) times.

34

Is arc consistency sound and complete?

R, G R, G R, G

Each arc consistent solution selects a value for every variable from the arc consistent domains. Completeness: Does arc consistency rule out any valid solutions?

  • Yes
  • No

Soundness: Is every arc-consistent solution a solution to the CSP?

  • Yes
  • No
slide-18
SLIDE 18

35

Arc consistency doesn’t rule out all infeasible solutions

R, G R, G R, G R, G R, G B, G

Graph Coloring

arc consistent but no solutions arc consistent but 2 solutions, not 8. B,R,G B,G,R

36

Next: To Solve CSPs we combine arc consistency and search

1. Arc consistency (Constraint propagation),

  • eliminates values that are shown locally to not be a

part of any solution. 2. Search

  • explores consequences of committing to particular

assignments. Methods Incorporating Search:

  • Standard Search
  • BackTrack search (BT)
  • BT with Forward Checking (FC)
  • Dynamic Variable Ordering (DV)
  • Iterative Repair
  • Backjumping (BJ)