- 115 Views
- Uploaded on
- Presentation posted in: General

Generating Diverse Solutions in SAT

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Generating Diverse Solutions in SAT

Alexander Nadel, Intel Israel

IBM; Haifa, Israel

October 31, 2011

- Introduction
- Analysis
- Polarity-based Algorithms
- Variable-based Algorithms
- Local Algorithms
- Global Algorithms

- Conclusion

- Given a propositional formula in CNF, generate a number of solutions that are as diverse as possible
- A solution is a satisfying assignment
- The threshold on the number of solutions is provided by the user

- DiversekSet in CSP is studied since 2005
- See the paper for references

- DiversekSet in SAT
- The first work is our FMCAD’10 paper on semi-formal FPV
- Semi-formal FPV finds bugs in hardware that cannot be identified by other methods
- DiversekSet is the prime reasoning engine

- The problem has a number of additional applications at Intel
- This work is thefirst full-blown paper

- The first work is our FMCAD’10 paper on semi-formal FPV

- The idea:
- Adapt a modern CDCL SAT solver for DiversekSet
- Make minimal changes to remain efficient

- Compact algorithms:
- Invoke the SAT solver once to generate all the solutions
- Restart after a solution is generated

- This work:
- Diversity is achieved by modifying polarity and variable selection heuristics

- Introduction
- Analysis
- Polarity-based Algorithms
- Variable-based Algorithms
- Local Algorithms
- Global Algorithms

- Conclusion

- Quality: the average Hamming distance between the solutions, normalized to [0…1]

Hamming distances matrix

a b c

10 0 0

21 1 0

30 1 1

41 0 0

2

- Quality: the average Hamming distance between the solutions, normalized to [0…1]

Hamming distances matrix

a b c

10 0 0

21 1 0

30 1 1

41 0 0

2

2

- Quality: the average Hamming distance between the solutions, normalized to [0…1]

Hamming distances matrix

a b c

10 0 0

21 1 0

30 1 1

41 0 0

2

2

1

- Quality: the average Hamming distance between the solutions, normalized to [0…1]

Hamming distances matrix

a b c

10 0 0

21 1 0

30 1 1

41 0 0

2

2

1

2

- Quality: the average Hamming distance between the solutions, normalized to [0…1]

Hamming distances matrix

a b c

10 0 0

21 1 0

30 1 1

41 0 0

2

2

1

2

1

- Quality: the average Hamming distance between the solutions, normalized to [0…1]

Hamming distances matrix

a b c

10 0 0

21 1 0

30 1 1

41 0 0

2

2

1

2

1

3

- Quality: the average Hamming distance between the solutions, normalized to [0…1]

Hamming distances matrix

a b c

10 0 0

21 1 0

30 1 1

41 0 0

2

2

1

2

1

3

Hamming Distance

Variables

Solutions

- Quality: the average Hamming distance between the solutions, normalized to [0…1]

Hamming distances matrix

a b c

10 0 0

21 1 0

30 1 1

41 0 0

2

2

1

2

1

3

- We formulate an alternative definition forthe same notion ofquality:
- Induces quality-efficient polarity and variable selection strategies by:
- Allowing one to estimate the contribution of each variable to quality online
- Inducing methods to improve the quality online

- Induces quality-efficient polarity and variable selection strategies by:

- Variable Quality: the number of different pairs, that is {0,1} or {1,0}, amongst distinct pairs of values assigned to the variable

Sa = 0

Start counting…

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Variable quality for a

Different: update Sa!

- Variable Quality: the number of different pairs, that is {0,1} or {1,0}, amongst distinct pairs of values assigned to the variable

Sa = 1

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Different: update Sa!

- Variable Quality: the number of different pairs, that is {0,1} or {1,0}, amongst distinct pairs of values assigned to the variable

Sa = 1

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Equal: do not update Sa

Sa = 1

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Different: update Sa!

Sa = 2

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Different: update Sa!

Sa = 2

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Different: update Sa!

Sa = 3

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Different: update Sa!

Sa = 3

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Equal: do not update Sa

Sa = 3

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Different: update Sa!

Sa = 4

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Different: update Sa!

Sa = 4

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Sa = 4

a b c

10 0 0

21 1 0

30 1 1

41 0 0

Sv= pv nv

Number of 1’s assigned to v

Number of 0’s assigned to v

- Quality: the average variable quality, normalized to [0…1]:

- Both definitions of quality sum up the number of different pairs of values assigned to variables

- Hamming distance-based definition
- Counts the number of different pairs per each pair of rows

a b c

10 0 0

21 1 0

30 1 1

41 0 0

- Variable quality-based definition
- Counts the number of different pairs per variable, that iscolumn by column

a b c

10 0 0

21 1 0

30 1 1

41 0 0

- Quality: the average variable quality, normalized to [0…1]:
- This definition induces DiversekSetalgorithms that improve quality online, e.g.:
- Polarity-based algorithm:
- For a decision variable, pick a polarity that maximizes variable quality after the assignment
- The current partial assignment is taken into account as a solution when calculating quality online

- A simple way to keep track of which polarity maximizes variable quality is provided next

- For a decision variable, pick a polarity that maximizes variable quality after the assignment

- Polarity-based algorithm:

- Variable Potential: difference between the number of 1’s and 0’s assigned to a variable:

v = pv- nv

- Variable Potential: difference between the number of 1’s and 0’s assigned to a variable:

a b c

10 0 0

21 1 0

30 1 1

41 0 0

0 0 -2

v = pv- nv

- The closer variable potential to 0 the higher variable quality
- v = pv– nv= pv– (m – pv)= 2pv – m
- Sv= pv nv= pv (m – pv) = mpv – pv2

- The closer variable potential to 0 the higher variable quality
- Sv= pv nv= pv (m – pv) = mpv – pv2
- v = pv– nv= pv– (m – pv)= 2pv – m

v = 0; Svis max

- The closer variable potential to 0 the higher variable quality
- Sv= pv nv= pv (m – pv) = mpv – pv2
- v = pv– nv= pv– (m – pv)= 2pv – m

Absolute potential moves away from 0; Variable quality drops

- Introduction
- Analysis
- Polarity-based Algorithms
- Variable-based Algorithms
- Local Algorithms
- Global Algorithms

- Conclusion

- Compactness:
- The SAT solver is invoked once
- The solver restarts upon new solution

- Only the polarity selection heuristic is modified
- pGuide’s polarity selection heuristic:
- If the potential is positive, pick 0
- If the potential is negative, pick 1
- If the potential is 0, pick a random value

- Properties:
- Always prefers the value that yields better quality (if such exists)
- The potential is closer to 0 variable quality improves overall quality improves

- Yields the best possible quality given a tautological formula
- Can be easily proven by induction on the number of solutions

- Always prefers the value that yields better quality (if such exists)

- Chooses the polarity randomly
- Unlike pGuide, might choose a polarity which yields worse quality that the second polarity

- pGuide picks values r0,r0’, r1,r1’, r2,r2’, … for every variable
- pRand picks random values
- For 2 solutions:
- The quality is:
- 1 for pGuide: {0, 1} or {1,0}
- 0.5 for pRand: {0, 0} or {0, 1} or {1,0} or {1, 1} with equal probability

- The quality is:

Even m

pGuide

Odd m

pRand:

- 66 instances from semi-formal FPV
- Stats:
- Variables: 213,047 to 910,868
- Clauses: 738,862 to 3,251,382

- All the instances are available by email

- Stats:
- Machines:
- Intel Xeon
- 4Ghz CPU frequency
- 32Gb memory

- Intel Xeon

- pGuide is clearly preferable to pRand, especially for a small number of solutions
- There is a resemblance between the quality function on tautological and real-life formulas
- The quality for real-life formulas is significantly lower
- How one can improve the quality on real-life formulas?

- The idea: take constraints into account by considering the impact of Boolean Constraint Propagation (BCP)
- For a newly selected decision variable:
- For each polarity {0,1}
- Pick
- Propagate with BCP
- Write down the quality Q
- Undo

- Pick the polarity with larger Q

- For each polarity {0,1}
- It is sufficient to measure the delta in the absolute value of the variable potentials for step (3): the lower delta the better quality

- Plain pBCPGuide is too costly in terms of performance
- Performs BCP 2 or 3 times per decision

- Optimizations:
- Continue with the second polarity if it yields better quality (instead of undoing) to save a BCP
- The first polarity should be the inferior one in terms of the impact on variable quality of the decision variable
- To increase the chances that the second polarity yields better quality, in which case only 2 BCPs are required

- pBCPGuide_T
- Use pBCPGuide until T conflicts are encountered from the moment when either:
- The search is started
- A new solution is discovered

- Switch to pGuide after the threshold is reached

- Use pBCPGuide until T conflicts are encountered from the moment when either:

- pGuide is preferable to pRandin terms of both quality and run-time
- pBCPGuide_T is preferable to pGuide in terms of quality, but pays fee in terms of performance
- T regulates the trade-off between quality and run-time
- pBCPGuide_100 seems to achieve an attractive balance between run-time and quality

- Introduction
- Analysis
- Polarity-based Algorithms
- Variable-based Algorithms
- Local Algorithms
- Global Algorithms

- Conclusion

- The idea: change the variable ordering to improve the quality
- Trade-off between run-time and quality:
- The better quality the worse run-time
- We provide ways to control the trade-off

- Our variable-based algorithms are built on top of polarity-based algorithms

- All the clauses are organized in a list
- Both initial and conflict clauses

- The next decision variable is picked from the top-most unsatisfied clause
- VSIDS is used to decide which variable to pick

- Upon conflict, the following clauses are placed in the top:
- The new conflict clause, followed by
- Clauses that participated in its resolution generation

- Local vs. Global
- With respect to the default variable ordering

- Guided vs. Randomized
- Guiding the solver away from previous solutions vs. using randomization over variables
- pGuide vs. pBCPGuide_100
- The underlying polarity-based algorithm

pBCPGuide_100

Guided

pGuide

Random.

Local

Global

- Introduction
- Analysis
- Polarity-based Algorithms
- Variable-based Algorithms
- Local Algorithms
- Global Algorithms

- Conclusion

- Pick variable with the highest absolute value of potential from the top-most non-satisfied clause
- Guided: the higher absolute potential the better quality after the assignment
- Local: makes only minimal modification to the default decision heuristic
- Picks the variable from the same clause as the original CBH, but does not follow VSIDS within that clause

- pGuide: uses pGuide for polarity selection

Local

Global

pBCPGuide_100

Guided

pGuide

Random.

- Pick variable at random from the top-most non-satisfied clause
- Randomized: picks the variable at random
- Local: picks the variable from the same clause as the original CBH, but does not follow VSIDS within that clause
- pGuide: use pGuide for polarity selection

pBCPGuide_100

Guided

pGuide

Random.

Local

Global

pBCPGuide_100

pBCPGuide_100

- How to integrate pBCPGuide_T?
- Run BCP for each polarity for a number of variables and pick the best?
- Too expensive!

- Use pBCPGuide_T as the polarity selection heuristic?
- Yields a slight deterioration in quality as compared to plain pBCPGuide_T!

- The solution: run plain pBCPGuide_T until the threshold, then switch to a variable-based strategy+pGuide

- Run BCP for each polarity for a number of variables and pick the best?

Local

Global

Guided

pGuide

Random.

- Local guided variable-based vs. plain polarity-based
- Moderate improvement in quality for marginal run-time fee

- Guided vs. randomized variable-based
- The guided method yields faster run-time and better quality for a small number of solutions
- The randomized method yields better quality for a large number of solutions
- Breaking dependencies pays off, when the problem is well-explored

- Introduction
- Analysis
- Polarity-based Algorithms
- Variable-based Algorithms
- Local Algorithms
- Global Algorithms

- Conclusion

pBCPGuide_100

pBCPGuide_100

- Global methods: trade run-time for quality by getting away from the default decision heuristic

Guided

pGuide

Random.

Local

Global

pBCPGuide_100

pBCPGuide_100

- Pick the variable with the highest potential from N top-most clauses, including satisfied clauses
- Guided: the higher potential the better quality after the assignment
- Global: makes substantial modification to the default decision heuristic

- Tie-breaking strategies target better performance by trying to get closer to the original CBH:
- Prefer clauses closer to the top-most non-satisfied clauses
- Prefer variables with higher VSIDS scores

Guided

pGuide

Random.

Local

Global

pBCPGuide_100

pBCPGuide_100

- Pick an unassigned variable at random in T% of the cases
- Randomized: the variable choice in randomized
- Global: makes substantial modification to the default decision heuristic

Guided

pGuide

Random.

Local

Global

- Local vs. Global
- Run-time: local came the best
- Quality: global won

- Guided vs. Randomized
- Run-time: guided came the best
- Quality: guided won for a low number of solutions; randomized won for a high number of solutions

- Trade-off between quality and run-time:
- Thresholds can be used for regulating the trade-off between quality and run-time for global strategies:
- Numbers of clauses to consider for guided strategies
- Percent of randomized decisions for randomized strategies

- Thresholds can be used for regulating the trade-off between quality and run-time for global strategies:

- DiversekSet in SAT: generate a user-given number of diverse solutions
- Used in a number of prominent FV flows at Intel

- Compact algorithms:
- The SAT solver is invoked once
- The solver restarts upon new solution

- pGuide-- the fundamental polarity-based algorithm:
- Only polarity selection strategy is modified
- The goal is to balance the number of 1’s and 0’s assigned to each variable in the solutions
- Yields optimal diversification quality given a tautological formula

- On real-world formulas quality can be improved by taking BCP into account and adapting the variable ordering
- One can trade run-time for quality
- We demonstrated how to control the trade-off

Thanks!