ICS 275 275 Spr pring ing 2014 2014 Spring 2014 What if the - - PowerPoint PPT Presentation

ics 275 275 spr pring ing 2014 2014
SMART_READER_LITE
LIVE PREVIEW

ICS 275 275 Spr pring ing 2014 2014 Spring 2014 What if the - - PowerPoint PPT Presentation

Chapter 5: General search strategies: Look-ahead ICS 275 275 Spr pring ing 2014 2014 Spring 2014 What if the Constraint network is not backtrack-free? l Backtrack-free in general is too costly so what to do? l Search? l What is


slide-1
SLIDE 1

Chapter 5: General search strategies: Look-ahead

ICS 275 275 Spr pring ing 2014 2014

Spring 2014

slide-2
SLIDE 2

What if the Constraint network is not backtrack-free?

l Backtrack-free in general is too costly so

what to do?

l Search? l What is the search space? l How to search it? Breadth-first? Depth-

first?

Spring 2014

slide-3
SLIDE 3

The search space for a CN

l

Spring 2014

slide-4
SLIDE 4

Search space and the effect of ordering

2,3,5

2,5,6 2,3,4

2,3,4

Z X Y L

Spring 2014

slide-5
SLIDE 5

Dependency on consistency level

l After arc-consistency z=5

and l=5 are removed

l After path-consistency

  • R’_zx
  • R’_zy
  • R’_zl
  • R’_xy
  • R’_xl
  • R’_yl

2,3,5 2,5,6 2,3,4

2,3,4

Z X Y L

Spring 2014

slide-6
SLIDE 6

The effect of higher consistency on search

Spring 2014

slide-7
SLIDE 7

Cost of node’s expansion

l Number of consistency checks for toy problem:

  • For d1: 19 for R, 43 for R’
  • For d2: 91 on R and 56 on R’

l Reminder:

Spring 2014

slide-8
SLIDE 8

Backtracking Search for a Solution

Spring 2014

slide-9
SLIDE 9

Backtracking Search for a single Solution

Spring 2014

slide-10
SLIDE 10

Backtracking Search for *All* Solutions

Spring 2014

slide-11
SLIDE 11

Backtracking Search for *All* Solutions

For all tasks Time: O(exp(n)) Space: linear

Spring 2014

slide-12
SLIDE 12

Spring 2014

Traversing Breadth-First (BFS)?

Not-equal

BFS space is exp(n) while no Time gain use DFS

slide-13
SLIDE 13

Backtracking

l Complexity of extending a

partial solution:

  • Complexity of consistent

O(e log t), t bounds tuples, e constraints

  • Complexity of selectValue

O(e k log t)

Spring 2014

slide-14
SLIDE 14

Improving backtracking

l Before search: (reducing the search space)

  • Arc-consistency, path-consistency
  • Variable ordering (fixed)

l During search:

  • Look-ahead schemes:
  • value ordering,
  • variable ordering (if not fixed)
  • Look-back schemes:
  • Backjump
  • Constraint recording
  • Dependency-directed backtacking

Spring 2014

slide-15
SLIDE 15

Look-ahead: value orderings

l Intuition:

  • Choose value least likely to yield a dead-end
  • Approach: apply constraint propagation at each node in the search

tree

l Forward-checking

  • (check each unassigned variable separately

l Maintaining arc-consistency (MAC)

  • (apply full arc-consistency)

l Full look-ahead

  • One pass of arc-consistency (AC-1)

l Partial look-ahead

  • directional-arc-consistency

Spring 2014

slide-16
SLIDE 16

Generalized look-ahead

slide-17
SLIDE 17

Forward-checking example

Spring 2014

slide-18
SLIDE 18

Spring 2014

Forward-Checking for Value Selection

) (

2

ek O

slide-19
SLIDE 19

Spring 2014

Forward-Checking for Value Ordering

) (

2

ek O

) (

2

ek O

FC overhead:

For each value of a future variable e_u Tests: O(k e_u), for all future variables O(ke) For all current domain O(k^2 e)

slide-20
SLIDE 20

Spring 2014

Forward-Checking for Value Ordering

) (

2

ek O

) (

2

ek O

FW overhead: :

slide-21
SLIDE 21

Forward-checking

) (

2

ek O

Complexity of selectValue-forward-checking at each node:

Spring 2014

slide-22
SLIDE 22

Arc-consistency look-ahead

(Gashnig, 1977)

l Applies full arc-consistency on all un-

instantiated variables following each value assignment to the current variable.

l Complexity:

  • If optimal arc-consistency is used:
  • What is the complexity overhead when AC-1

is used at each node?

) (

3

ek O

Spring 2014

) ( ) (

3 2

ek O ek O

Forward-checking: Full arc-consistency look-ahead With optimal AC:

slide-23
SLIDE 23

MAC: Mmaintaining arc-consistency (Sabin and Freuder 1994)

l Perform arc-consistency in a binary search

tree: Given a domain X={1,2,3,4} the algorithm assigns X=1 (and apply arc- consistency) and if x=1 is pruned, it applies arc-consistency to X={2,3,4}

l If inconsistency is not discovered, a new

variable is selected (not necessarily X)

Spring 2014

slide-24
SLIDE 24

Spring 2014

MAC for Value Ordering

) (

2

ek O

) ( ) (

3 2

ek O ek O

FW overhead: MAC overhead:

slide-25
SLIDE 25

Spring 2014

MAC for Value Ordering

) (

2

ek O

) ( ) (

3 2

ek O ek O

FW overhead: MAC overhead: Arc-consistency prunes x1=red Prunes the whole tree

Not searched By MAC

slide-26
SLIDE 26

Arc-consistency look-ahead: (a variant: maintaining arc-consistency MAC)

Spring 2014

slide-27
SLIDE 27

Full and partial look-ahead

l Full looking ahead:

  • Make one pass through future variables

(delete, repeat-until)

l Partial look-ahead:

  • Applies (similar-to) directional arc-consistency

to future variables.

  • Complexity: also
  • More efficient than MAC

) (

3

ek O

Spring 2014

slide-28
SLIDE 28

Example of partial look-ahead

Spring 2014

slide-29
SLIDE 29

Branching-ahead: Dynamic Value Ordering

Rank order the promise in non-rejected values

  • Rank functions
  • MC (min conflict)
  • MD (min domain)
  • SC (expected solution counts)
  • MC results (Frost and Dechter, 1996)
  • SC – currently shows good performance using IJGP

(Kask, Dechter and Gogate, 2004)

Spring 2014

slide-30
SLIDE 30

Dynamic Variable Ordering (DVO)

l Following constraint propagation, choose the

most constrained variable

l Intuition: early discovery of dead-ends l Highly effective: the single most important

heuristic to cut down search space

l Most popular with FC l Dynamic search rearrangement (Bitner and Reingold, 1975) (Purdon,1983)

Spring 2014

slide-31
SLIDE 31

Spring 2014

Forward-Checking, Variable Ordering

) (

2

ek O

) ( ) (

3 2

ek O ek O

FW overhead: MAC overhead:

slide-32
SLIDE 32

Spring 2014

Forward-Checking, Variable Ordering

) (

2

ek O

) ( ) (

3 2

ek O ek O

FW overhead: MAC overhead:

After X1 = red choose X3 and not X2

slide-33
SLIDE 33

Spring 2014

Forward-Checking, Variable Ordering

) (

2

ek O

) ( ) (

3 2

ek O ek O

FW overhead: MAC overhead:

After X1 = red choose X3 and not X2

slide-34
SLIDE 34

Spring 2014

Forward-Checking, Variable Ordering

) (

2

ek O

) ( ) (

3 2

ek O ek O

FW overhead: MAC overhead:

After X1 = red choose X3 and not X2

slide-35
SLIDE 35

Example: DVO with forward checking (DVFC)

Spring 2014

slide-36
SLIDE 36

Algorithm DVO (DVFC)

slide-37
SLIDE 37

DVO: Dynamic Variable Ordering, More involved

heuristics

l dom: choose a variable with min domain l deg: choose variable with max degree l dom+deg: dom and break ties with max

degree

l dom/deg (Bessiere and Ragin, 96): choose min dom/deg

l dom/wdeg: domain divided by weighted degree.

Constraints are weighted as they get involved in more

  • conflicts. wdeg: sum the weights of all constraints that

touch x.

Spring 2014

slide-38
SLIDE 38

Implementing look-aheads

l Cost of node generation should be reduced l Solution: keep a table of viable domains for

each variable and each level in the tree.

l Space complexity l Node generation = table updating

) ( ) ( ek O k e O

d

) (

2k

n O

Spring 2014

slide-39
SLIDE 39

Branching Strategies (selecting the search space)

(see vanBeek, chapter 4 in Handbook)

l

Spring 2014

slide-40
SLIDE 40

Randomization

l Randomized variable selection (for tie breaking

rule)

l Randomized value selection (for tie breaking

rule)

l Random restarts with increasing time-cutoff l Capitalizing on huge performance variance l All modern SAT solvers that are competitive us

restarts.

Spring 2014

slide-41
SLIDE 41

The cycle-cutset effect

l A cycle-cutset is a subset of nodes in an

undirected graph whose removal results in a graph with no cycles

l A constraint problem whose graph has a

cycle-cutset of size c can be solved by partial look-ahead in time

) ) ((

) 2 ( +

c

k c n O

Spring 2014

slide-42
SLIDE 42

Extension to stronger look-ahead

l Extend to path-consistency or i-consistency or

generalized-arc-consistency

Spring 2014

slide-43
SLIDE 43

Look-ahead for SAT: DPLL

(Davis-Putnam, Logeman and Laveland, 1962) Spring 2014

slide-44
SLIDE 44

Example of DPLL

Spring 2014

slide-45
SLIDE 45

Spring 2014

What is SAT?

Given a sentence:

  • Sentence: conjunction of clauses
  • Clause: disjunction of literals
  • Literal: a term or its negation
  • Term: Boolean variable

Question: Find an assignment of truth values to the Boolean variables such the sentence is satisfied.

( ) ( ) ( )

4 3 2 6 5 4 1

c c c c c c c ¬ ∧ ¬ ∨ ∧ ∨ ∨ ¬ ∨

( )

3 2

c c ¬ ∨

6 1,

c c ¬

1

1 1

= ¬ ⇔ = c c

slide-46
SLIDE 46

Spring 2014

CSP is NP-Complete

l Verifying that an assignment for all

variables is a solution

  • Provided constraints can be checked in

polynomial time

l Reduction from 3SAT to CSP

  • Many such reductions exist in the literature

(perhaps 7 of them)

slide-47
SLIDE 47

Spring 2014

Problem reduction

Example: CSP into SAT (proves nothing, just an exercise)

Notation: variable-value pair = vvp

l vvp → term

  • V1 = {a, b, c, d} yields x1 = (V1, a), x2 = (V1, b), x3 = (V1, c), x4 =

(V1, d),

  • V2 = {a, b, c} yields x5 = (V2, a), x6 = (V2, b), x7 = (V2,c).

l The vvp’s of a variable → disjunction of terms

  • V1 = {a, b, c, d} yields

l (Optional) At most one VVP per variable

4 3 2 1

x x x x ∨ ∨ ∨

( ) ( ) ( ) ( )

4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1

x x x x x x x x x x x x x x x x ∧ ¬ ∧ ¬ ∧ ¬ ∨ ¬ ∧ ∧ ¬ ∧ ¬ ∨ ¬ ∧ ¬ ∧ ∧ ¬ ∨ ¬ ∧ ¬ ∧ ¬ ∧

slide-48
SLIDE 48

Spring 2014

CSP into SAT (cont.)

Constraint:

1.

Way 1: Each inconsistent tuple → one disjunctive clause

  • For example: how many?

2.

Way 2:

a) Consistent tuple → conjunction of terms b) Each constraint → disjunction of these conjunctions

→ transform into conjunctive normal form (CNF)

Question: find a truth assignment of the Boolean variables such that

the sentence is satisfied

)} , ( ), , ( ), , ( ), , ( ), , {(

2 1

a d b c c b b a a a C V

V

=

7 1

x x ¬ ∨ ¬

5 1

x x ∧

( ) ( ) ( ) ( ) ( )

5 4 6 3 7 2 6 1 5 1

x x x x x x x x x x ∧ ∨ ∧ ∨ ∧ ∨ ∧ ∨ ∧