• 沒有找到結果。

Solving Constraint Satisfaction Problems: Arc Consistency and Constraint Propagation

N/A
N/A
Protected

Academic year: 2022

Share "Solving Constraint Satisfaction Problems: Arc Consistency and Constraint Propagation"

Copied!
18
0
0

加載中.... (立即查看全文)

全文

(1)

11

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

(2)

3

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 Djsuch that assignment (x,y) is allowed by constraint Cij

• Or ∀x∈Di∃y∈Djsuch 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}

=

(3)

5

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

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

{1,2,3} {1,2}

Example:Given: Variables V1and 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 consistentif

∀x∈Di∃y∈Djsuch 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 Diof each arc that fails this condition,

•Repeatuntil quiescence:

• If element deleted from Dithen

•check directed arc consistency for each arc with head Di

• Maintain arcs to be checked on FIFO queue (no duplicates).

(4)

7

R,G,B

G R, G

Graph Coloring

Initial Domains

Different-color constraint 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.

(5)

9

V1 > V2

Value deleted Arc examined

R,G,B

G R, G

V2

V3 V1

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

• Vi– Vjdenotes two arcs between Viand Vj.

• Vi < Vj denotes an arc from Vjand 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– Vjdenotes two arcs between Viand Vj.

• Vi < Vj denotes an arc from Vjand Vi.

• Delete unmentioned tail values

(6)

11

R,G,B

G R, G

Different-color constraint 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– Vjdenotes two arcs between Viand Vj.

• Vi < Vj denotes an arc from Vjand 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– Vjdenotes two arcs between Viand Vj.

• Vi < Vj denotes an arc from Vjand Vi.

• Delete unmentioned tail values

(7)

13

none V1 – V2

Value deleted Arc examined

R,G,B

G R, G

V2

V3 V1

Arcs to examine V1-V3, V2-V3

• Vi– Vjdenotes two arcs between Viand Vj.

• Vi < Vj denotes an arc from Vjand 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– Vjdenotes two arcs between Viand Vj.

• Vi < Vj denotes an arc from Vjand Vi.

• Delete unmentioned tail values

(8)

15

R,G,B

G R, G

Different-color constraint 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 tothat variableto 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 tothat variableto the examination queue.

(9)

17

V1<V3

V1(G) V1>V3

none V1 – V2

Value deleted Arc examined

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 tothat variableto 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 tothat variableto the examination queue.

(10)

19

R,G,B

G R, G

Different-color constraint 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 tothat variableto 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 tothat variableto the examination queue.

(11)

21

V2(G) V2 >V3

V1(G) V1-V3

none V1 – V2

Value deleted Arc examined

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 tothat variableto 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 tothat variableto the examination queue.

(12)

23

R,G,B

G R, G

Different-color constraint 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 tothat variableto 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 tothat variableto the examination queue.

(13)

25

none V2>V1

V2(G) V2 -V3

V1(G) V1-V3

none V1 – V2

Value deleted Arc examined

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 tothat variableto 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 tothat variableto the examination queue.

(14)

27

R,G,B

G R, G

Different-color constraint 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 tothat variableto 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 tothat variableto the examination queue.

(15)

29

V3>V1 V2>V1

V1(R) V2-V1

V2(G) V2 -V3

V1(G) V1-V3

none V1 – V2

Value deleted Arc examined

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 tothat variableto 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.

(16)

31

• 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)

(17)

33

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

(18)

35

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)

參考文獻

相關文件

The format string is like a constraint except that there could be place-holder strings like “%s” and “%d” for strings and integers respectively.. The format string F is like

One thing to note is that not all problems are solvable, i.e., some initial board config- urations cannot be altered to reach the desired board configurations by any number of

Price-directed decomposition does not require shared constraint function g be separable, but requires existence of multipliers.. It samples in the space

Two optimization problems (P 1 ) and (P 2 ) are equivalent if the optimal solution of one problem can be transformed to that of the other so that solving one the problems also gives

This leaves you 8 hours of time to allocate between studying t 1 hours at the K-book center, singing for t 2 hours at the KTV, and teaching t 3 hours hours as a private tutor for

In Section 3, the shift and scale argument from [2] is applied to show how each quantitative Landis theorem follows from the corresponding order-of-vanishing estimate.. A number

May not be scanned, copied, or duplicated, or posted to a publicly accessible website, in whole or in part.. Hence, the ellipse and hyperbola are

[r]