building structure into local search for sat 1 chris reeson advanced constraint processing fall 2009...

23
Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar, IJCAI 2007 Focus on How It Works

Post on 19-Dec-2015

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

Building Structure into Local Search for SAT

1

Chris Reeson Advanced Constraint Processing

Fall 2009

By Duc Nghia Pham, John Thornton, and Abdul Sattar, IJCAI 2007

Focus on How It Works

Page 2: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

2

Outline

• Background– SAT & Local Search

• Building blocks– Modeling Structure in SAT with Logic Gates– Variables: Independent, Internal, External– Dependency Lattice

• Solving Structured SAT w/ Local Search– Computing costs with variables sets

• Conclusion

Page 3: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

3

SAT• Given a SAT sentence (in CNF= conjunction of clauses)• Find an assignment to the Boolean variables that satisfies each

clause.

(a b c) (a b) (a c) clause variable

a b c a b c a b a c (a b c) (a b) (a c)0 0 0 1 1 1 10 0 1 1 1 0 00 1 0 1 0 1 00 1 1 1 0 0 01 0 0 0 1 1 01 0 1 1 1 1 11 1 0 1 1 1 11 1 1 1 1 1 1

Page 4: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

4

Quick Review of Local Search• Process

1. Start from a random state (complete assignment of values to variables)

2. Evaluate quality of state3. Explore neighborhood4. Move to a neighbor5. Goto 1 unless you’ve reached

• desired solution quality• max # of iterations• time limit

• Restart process to your heart’s content• Two types of moves

– Improvement– Random

States

Stat

e Q

ualit

y

Page 5: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

5

Outline

• Background– SAT & Local Search

• Building blocks– Modeling Structure in SAT with Logic Gates– Variables: Independent, Internal, External– Dependency Lattice

• Solving Structured SAT w/ Local Search– Computing costs with variables sets

• Conclusion

Page 6: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

6

Idea: Structure in SAT

• The variables are partitioned into – Independent variables– Dependent variables– External variables

• A solution is determined – By the assignment of only the

independent variables– Such as all external variables

evaluate to 1• Advantage: smaller problem,

quicker convergence 2 |Indpdt vars|

0 0 01

1 1 1

0

01 1

1

Page 7: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

7

Logic Gates & Dependencies

• Dependencies between variables are modeled by logic gates

• Four types of logic gates are used: OR, AND, XOR, EQUIV

• Transformation of SAT problem– Cost of transformation?– # & size of alternative

transformations?– For details, read [Ostrowski

+ CP02]

OR

AND

XOR

EQUIV(XNOR)

Page 8: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

8

OR Gate

(a b c) (a b) (a c)is equivalent to

(b c a) (bc a)

bc

a a = (b,c)

a b c a b c a b a c (a b c) (a b) (a c)0 0 0 1 1 1 10 0 1 1 1 0 00 1 0 1 0 1 00 1 1 1 0 0 01 0 0 0 1 1 01 0 1 1 1 1 11 1 0 1 1 1 11 1 1 1 1 1 1

Page 9: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

9

AND Gate

(a b c) (a b) (a c) Is equivalent to

(b c a) (b c a)

b

ca a = (b,c)

a b c ab c a b a c (abc) (ab) (ac)0 0 0 1 1 1 10 0 1 1 1 1 10 1 0 1 1 1 10 1 1 0 1 1 01 0 0 1 0 0 01 0 1 1 0 1 01 1 0 1 1 0 01 1 1 1 1 1 1

Page 10: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

10

XOR Gate

(a b c) (a b c) (a b c) (a b c)is equivalent to

(b c a) (b c a) (b c a) (b c a)

a b c abc abc ab c abc (a b c) (a b c) (a b c) (a b c)

0 0 0 1 1 1 1 1

0 0 1 1 0 1 1 0

0 1 0 1 1 0 1 0

0 1 1 1 1 1 1 1

1 0 0 1 1 1 0 0

1 0 1 1 1 1 1 1

1 1 0 1 1 1 1 1

1 1 1 0 1 1 1 0

bc

a a =(b,c)

Page 11: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

11

EQUIV Gate

(a b c) (a b c) (a b c) (a b c)is equivalent to

(b c a) (bc a) (b c a) (bc a)

bc

a a = (b,c)

a b c abc abc abc a b c (abc)(abc) (abc)(abc)

0 0 0 0 1 1 1 00 0 1 1 1 1 1 10 1 0 1 1 1 1 10 1 1 1 1 1 0 01 0 0 1 1 1 1 11 0 1 1 1 0 1 01 1 0 1 0 1 1 01 1 1 1 1 1 1 1

Page 12: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

12

EQUIV Gate = XNOR Gate

a b c EQUIV XOR0 0 0 0 10 0 1 1 00 1 0 1 00 1 1 0 11 0 0 1 01 0 1 0 11 1 0 0 11 1 1 1 0

• XOR(a b c) (abc) (a b c) (a b c)is equivalent to (bc a) (bc a) (bc a) (bc a)

• Equivalence(a b c) (a b c) (a b c) (a b c)is equivalent to (bc a) (bc a) (bc a) (bc a)

Page 13: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

13

Extending to Three or More Inputs

• AND & OR extend naturally– a = (b,c,d) or a = (b,c,d)

• EQUIV in pairwise fashion – a= (b,c,d) is a= (d, (b,c))

b c d AND OR EQUIV0 0 0 0 00 0 1 0 10 1 0 0 10 1 1 0 11 0 0 0 11 0 1 0 11 1 0 0 11 1 1 1 1

01101001

bcd

a

abcd

ad

cb

Page 14: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

14

Outline

• Background– SAT & Local Search

• Building blocks– Modeling Structure in SAT with Logic Gates– Variables: Independent, Internal, External– Dependency Lattice

• Solving Structured SAT w/ Local Search– Computing costs with variables sets

• Conclusion

Page 15: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

15

Categorizing Variables (1)

• An independent variable is one – That is never dependent

• A dependent variable is one – Whose value is determined

by one or more gates

b

ca

dependentindependent

b

ca

dependent

dc b

independentdependent

dependentindependent

Page 16: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

16

Dependency Lattice

(a b c) (a b) (a c)

(b d c) (b d) (b c)

c d

b

a

or

and

Independent

Dependent

c d b a0 0 0 00 1 0 01 0 0 11 1 1 1

b

ca

independent

dc b

independentdependent

dependent

Page 17: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

17

Categorizing Variables (2)

• An independent variable is one – That is never dependent

• An internal gate is one– That can be recognized within the

structure of the original CNF formula– All dependent variables from the

original problem• An external gate is one

– Where the dependent variable is a clause from the original problem

– Newly created dependent variables

S1=(a b c) (a b) (a c)

(b d c) (b d) (b c)

c d

b

a

or

and

Independent

Internal

S2=(a b c) (a b) (a c)

(b d c) (b d) (b c) (b d)

e

c d

b

a

or

and

Independent

Internaland

External

Page 18: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

18

Solving SAT

• Instantiate all independent variables such that all the external nodes evaluate to true

c d

b

a

or

and

Independent

Dependent

c d b a S1

0 0 0 0 10 1 0 0 11 0 0 1 11 1 1 1 1

e

c d

b

a

or

and

Independent

Internaland

External

c d b a e S2

0 0 0 0 0 00 1 0 0 0 01 0 0 1 0 01 1 1 1 1 1

Page 19: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

19

Outline

• Background– SAT & Local Search

• Building blocks– Modeling Structure in SAT with Logic Gates– Variables: Independent, Internal, External– Dependency Lattice

• Solving Structured SAT w/ Local Search– Computing costs with variables sets

• Conclusion

Page 20: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

20

Local Search for ‘Structured’ SAT

1. Instantiate the independent variables2. Propagate values in the lattice & compute variable

sets3. Compute the make & break cost for each

independent variable 4. Flip the independent variable w/ the smallest flip

cost (makebreak?) or do a random move5. Goto Step 26. Repeat until solution is found (external variables are

all T) or run out of time..

Page 21: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

21

• Start with an assignment of the independent variables• Store at each gate as a variable set

– The independent variables that, when flipped, will change the gate’s value

• Calculate the make cost of flipping an independent variable– The number of external variables that will be made true

• Calculate the break cost of flipping an independent variable– The number of external variables that will be made false

Make & Break Costs & Variable Sets

e

c d

b

a

or

and

and

F F

F

F

F{}

{c} {}e

c d

b

a

or

and

and

F T

F

F

F{c}

{c} {}e

c d

b

a

or

and

and

T T

T

T

T{c, d}

{} {c, d}

Page 22: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

22

Updating Variable Sets

• Start from the independent variable– Flip its value– Propagate change downwards– Stop when a gate’s value and its variable list do not change

v1 v2 v4v3

g1 g2

g3c1

or

or and

F F F T

F

T

F

F

{v3}{v2, v3}{v1,v2,v3} {v2}

AND gate is• T V {parents=T)∪• F V ∩{parents=F} \ {parents=T}∪OR gate is• F V {parents=F}∪• T V ∩{parents=T} \ {parents=F}∪EQUIV • V {parents} \ ∩ {parents}∪

Page 23: Building Structure into Local Search for SAT 1 Chris Reeson Advanced Constraint Processing Fall 2009 By Duc Nghia Pham, John Thornton, and Abdul Sattar,

23

Conclusion

• [Ostrowski+ CP02] used approach in BT search• [Pham+ IJCAI07] used approach in local search• Experiments show strategy is competitive