24
Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

Embed Size (px)

DESCRIPTION

how constraints improve search  used in partial solution searches where the start state is root of search tree (no variables have assigned values)  at any level of tree, some variables are assigned, some are not  constraints reduce choice for next variable assigned

Citation preview

Page 1: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

Constraint Propagation

influenced by Dr. Rina Dechter, “Constraint Processing”

Page 2: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

why propagate constraints? tightens networks leaves fewer choices for search by

eliminating dead endsBUT propagating can be costly in resources tradeoff between constraint propagation and

search “bounded constraint propagation algorithms”

Page 3: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

how constraints improve search used in partial solution searches

where the start state is root of search tree

(no variables have assigned values) at any level of tree, some variables are

assigned, some are not constraints reduce choice for next variable

assigned

Page 4: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

how constraints improve search

-

v1

v2

v3

v4

choosing v4

satisfy constraints on scopes containing v4 with v1, v2, v3

Page 5: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

example - red/green graph

redgreen

redgreen

redgreen

v1

v2 v3

-

v1

v2

v3

Page 6: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

arc-consistency local consistency property

involves binary constraint and its two variables

any value in the domain of one variable can be extended by a value of the other variable consistent with the constraint

Page 7: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

arc-consistency example

x1, D1 = {1,2,4} {1,2}

x2, D2 = {1,2,4} {2,4}

C12: {(x1,x2) | x1 < x2 } = {(1,2),(1,4),(2,4)}x1

124

x2

124

x1

12.

x2

.24

arc-inconsistent arc-consistent

Page 8: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

enforcing arc-consistency reduces domains

algorithm to make xi arc-consistent w.r.t. xj

Revise(Di) w.r.t. Cij on Sij={xi,xj}for each ai Di

if no aj Dj such that (ai,aj) Cij

delete ai from Di

performance O(k2) in domain size

Page 9: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

reducing search spaces apply arc-consistency to all constraints in

problem space removes infeasible solutions focuses search

arc consistency may be applied repeatedly to same constraints

Page 10: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

interaction of constraints: example

x1, D1 = {1,2,4}

C12: {x1 = x2}

x2, D2 = {1,2,4}

C23: {x2 = x3}

x3, D2 = {1,2,4}

C31: {x1 = 2*x3}

x1

124

x2

124

x3

124

Page 11: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

AC-3 arc-consistency algorithmproblem: R =(X,D,C)AC-3(R)q = new Queue()for every constraint Cij C

q.add((xi,xj)); q.add((xj,xi));while !q.empty()

(xi,xj) = q.get();Revise(Di) wrt Cijif(Di changed)for all k ≠i or jq.add( (xk,xi)

performance O(c.k3) c binary constraints, k domain size

Page 12: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

arc-consistency automated version of problem-solving

activity by people - propagating constraints

Page 13: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

loopholes in arc-consistency

x1, D1 = {1,2}

C12: {x1 ≠ x2}

x2, D2 = {1,2}

C23: {x2 ≠ x3}

x3, D2 = {1,2}

C31: {x1 ≠ x3}

x1

12

x2

12

x2

12

≠ ≠

Page 14: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

stronger constraint checking path-consistency extends arc-consistency

to three variables at once (tightening) global constraints -specialized consistency

for set of variables e.g., alldifferent(x1, …, xm) - equivalent of

permutation set who owns the zebra? problem

fixed sum, cumulative maximum

Page 15: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

constraints in partial solution search space

example problem:V = {x,y,l,z},D = {Dx, Dy, Dl, Dz}

Dx={2,3,4}, Dy={2,3,4}, Dl={2,5,6}, Dz={2,3,5}

C = {Czx, Czy, Czl}: z must divide other variables

2,3,4y

2,5,6l

2,3,4x

2,3,5z

Page 16: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

reducing search space size

1. variable ordering2. arc-consistency (or path-consistency, etc)

i. pre-search check to reduce domainsii. during search check for consistency with

values already assigned

Page 17: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

reducing space size1. variable ordering

Page 18: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

reducing space size

2. arc-consistency

Page 19: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

reducing space size2. path-consistency (tightening)

• Cxl, Cxy, Cyl (slashed subtrees)

Page 20: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

dfs with constraints - detail

extending a partial solution

xk-1

xk

xk+1

4

2

?

D`k+1 = {1,2,3,4}

SELECT-VALUE(D`k+1)

while (! D`k+1 .empty())

a = D`k+1 .pop()

if (CONSISTENT(xk+1=a)) return areturn null // dead end

Page 21: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

dfs algorithm with constraints dfs(X,D,C) returns consistent solutioni=1, D`i = Di

while (1≤ i ≤ n) // n=|X| xi = SELECT-VALUE(D`i) if(xi == null) // dead end i-- // backtrack else i++ D`i = Di

if (i==0) return “no solution”return (x1, x2, …, xn)

Page 22: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

improving search performance changing the resource balance between

constraint propagation and search

do more pruning by consistency checking many strategies e.g., look-ahead algorithms

Page 23: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

look-aheadconsistency

SELECT-FORWARD(D`k+1)while (!D`k+1.empty()) a = D`k+1 .pop() if (CONSISTENT(xk+1=a)) for (i; k+1 < i ≤ n) for all bD`i

if(!CONSISTENT(xi=b)) remove b from D`i

if(D`i.empty()) // xk+1=a is dead end reset all D`j, j>k+1 else return areturn null

SELECT-VALUE(D`k+1)

while (!D`k+1.empty())

a = D`k+1 .pop()

if (CONSISTENT(xk+1=a)) return areturn null

Page 24: Constraint Propagation influenced by Dr. Rina Dechter, “Constraint Processing”

optimization algorithms same strategies can be used in other

search algorithms greedy, etc

example problem - sudoku