NPSOLVER A SAT Based Solver For Optimization Problems Norbert - - PowerPoint PPT Presentation

npsolver
SMART_READER_LITE
LIVE PREVIEW

NPSOLVER A SAT Based Solver For Optimization Problems Norbert - - PowerPoint PPT Presentation

NPSOLVER A SAT Based Solver For Optimization Problems Norbert Manthey and Peter Steinke Trento, 16.06.2012 Efficient SAT Solvers During the last decade SAT solvers improved heavily There is an own research field Search heuristics


slide-1
SLIDE 1

NPSOLVER

A SAT Based Solver For Optimization Problems

Norbert Manthey and Peter Steinke

Trento, 16.06.2012

slide-2
SLIDE 2

Efficient SAT Solvers

During the last decade

  • SAT solvers improved heavily
  • There is an own research field

– Search heuristics – Preprocessing and inprocessing – Parameter tuning – . . .

  • Each year, the performance of the tools increases
  • The architecture turned parallel

TU Dresden, 16.06.2012 npSolver slide 2 of 23

slide-3
SLIDE 3

Optimization Problems

Having a solution only is often not enough

  • A solution should be

– nice (nurse rostering) – small (size of a plan) – optimal (number of cargo trains per hour)

TU Dresden, 16.06.2012 npSolver slide 3 of 23

slide-4
SLIDE 4

Optimization Problems

Having a solution only is often not enough

  • A solution should be

– nice (nurse rostering) – small (size of a plan) – optimal (number of cargo trains per hour)

  • Searching the optimal solution is more complex

TU Dresden, 16.06.2012 npSolver slide 3 of 23

slide-5
SLIDE 5

Optimization Problems

Having a solution only is often not enough

  • A solution should be

– nice (nurse rostering) – small (size of a plan) – optimal (number of cargo trains per hour)

  • Searching the optimal solution is more complex
  • Can we use advanced SAT technology efficiently?

TU Dresden, 16.06.2012 npSolver slide 3 of 23

slide-6
SLIDE 6

Outline

Motivation Optimization Problems Details in npSolver Translate PB to SAT Solve the Optimization Problem Demo Conclusion

TU Dresden, 16.06.2012 npSolver slide 4 of 23

slide-7
SLIDE 7

Description of Instances

  • There are hard constraints . . .

– Each train has to go on its route – The cost of these constraints is infinite

  • . . . and soft constraints

– Having less trains carrying the same goods would be nice – Missing such a goal has a price (each)

  • The overall cost has to be minimized

TU Dresden, 16.06.2012 npSolver slide 5 of 23

slide-8
SLIDE 8

How to solve PBO

Problems are described for example as PB instance:

i wixi ⊲ k

  • wi and k are integers
  • ⊲ is a classical relational operators =, >, <, ≤ or ≥

TU Dresden, 16.06.2012 npSolver slide 6 of 23

slide-9
SLIDE 9

How to solve PBO

Problems are described for example as PB instance:

i wixi ⊲ k

  • wi and k are integers
  • ⊲ is a classical relational operators =, >, <, ≤ or ≥
  • Minimize the sum

i wixi TU Dresden, 16.06.2012 npSolver slide 6 of 23

slide-10
SLIDE 10

How to solve PBO

Problems are described for example as PB instance:

i wixi ⊲ k

  • wi and k are integers
  • ⊲ is a classical relational operators =, >, <, ≤ or ≥
  • Minimize the sum

i wixi

Solving:

  • Translate the instance to SAT and get a model J
  • Evaluate r =

i wiJ(xi)

  • Solver formula with new bound r − 1 until the formula is unsatisfiable

TU Dresden, 16.06.2012 npSolver slide 6 of 23

slide-11
SLIDE 11

How to turn MaxSAT into PBO

MaxSAT:

  • Clauses can have weights
  • Minimize the weights of unsatisfied clauses

TU Dresden, 16.06.2012 npSolver slide 7 of 23

slide-12
SLIDE 12

How to turn MaxSAT into PBO

MaxSAT:

  • Clauses can have weights
  • Minimize the weights of unsatisfied clauses

Translate into PBO:

  • Clause Ci with weight wi is turned into Ci ∨ xi
  • We add to the current minimization wi · xi
  • Final result: minimize

i wixi as in PBO TU Dresden, 16.06.2012 npSolver slide 7 of 23

slide-13
SLIDE 13

How to turn WBO into MaxSAT

Weighted Boolean Optimization (WBO):

  • PB instances
  • each PB constraint Di can have a weight wi

TU Dresden, 16.06.2012 npSolver slide 8 of 23

slide-14
SLIDE 14

How to turn WBO into MaxSAT

Weighted Boolean Optimization (WBO):

  • PB instances
  • each PB constraint Di can have a weight wi

Translate into PBO:

  • Constraint Di with weight wi is turned into Di ∨ xi
  • We add to the current minimization wi · xi

TU Dresden, 16.06.2012 npSolver slide 8 of 23

slide-15
SLIDE 15

How to turn WBO into MaxSAT

Weighted Boolean Optimization (WBO):

  • PB instances
  • each PB constraint Di can have a weight wi

Translate into PBO:

  • Constraint Di with weight wi is turned into Di ∨ xi
  • We add to the current minimization wi · xi

Another translation into MaxSAT:

  • Constraint Di with weight wi is translated into clauses Ci,j
  • We turn each clause Ci,j into Ci,j ∨ xi
  • We add to the current minimization wi · xi
  • Note: the number of clauses is not changed

TU Dresden, 16.06.2012 npSolver slide 8 of 23

slide-16
SLIDE 16

Outline

Motivation Optimization Problems Details in npSolver Translate PB to SAT Solve the Optimization Problem Demo Conclusion

TU Dresden, 16.06.2012 npSolver slide 9 of 23

slide-17
SLIDE 17

Reason for npSolver

Why do we implement npSolver?

  • Its a good idea to use SAT solvers
  • We can use any SAT solver (also parallel, default: glucose)
  • PB instances are mixed with clauses and cardinality constraints
  • Existing solvers (e.g. MiniSat+) do not support all features
  • We can utilize incremental solving

TU Dresden, 16.06.2012 npSolver slide 10 of 23

slide-18
SLIDE 18

Outline

Motivation Optimization Problems Details in npSolver Translate PB to SAT Solve the Optimization Problem Demo Conclusion

TU Dresden, 16.06.2012 npSolver slide 11 of 23

slide-19
SLIDE 19

Why should we translate PB into SAT?

We measured the distribution of constraints in the PB competition instances

  • 90 % can be translated with clauses best (including BDD-path)
  • Almost 10 % are general PB constraints
  • There are very few cardinality constraints (for special encoding)
  • There are only a few very large constraints

TU Dresden, 16.06.2012 npSolver slide 12 of 23

slide-20
SLIDE 20

Why should we translate PB into SAT?

We measured the distribution of constraints in the PB competition instances

  • 90 % can be translated with clauses best (including BDD-path)
  • Almost 10 % are general PB constraints
  • There are very few cardinality constraints (for special encoding)
  • There are only a few very large constraints

Note:

  • The measurement reflects all the constraints
  • The distribution per instance can be different
  • Currently, we support up to 64 bits

TU Dresden, 16.06.2012 npSolver slide 12 of 23

slide-21
SLIDE 21

When to use which encoding?

What to do after the PB constraint have been read?

  • Turn them into a ≤ type constraint
  • Turn all weights into positive weights
  • Determining the type of the constraint

– trivial, at-most-one, at-most-k – general PB constraint with BDD, BDD-path or ADDERs

  • Picking the right encoding
  • Translating to SAT

TU Dresden, 16.06.2012 npSolver slide 13 of 23

slide-22
SLIDE 22

When to use which encoding?

What to do after the PB constraint have been read?

  • Picking the right encoding
  • Translating to SAT

Encoding AMO 2-product Sorting NW BDDs Watch Dog Adder NW absolute 611859 19227 112253 22967061 517 567 relative 2.58 % 0.08 % 0.47 % 96.86 % 0.00 % 0.00 % TU Dresden, 16.06.2012 npSolver slide 13 of 23

slide-23
SLIDE 23

Details AMO

There are several ways to encode the at-most one constraint

  • Pairwise encoding
  • Sequential counters
  • Log-encoding

TU Dresden, 16.06.2012 npSolver slide 14 of 23

slide-24
SLIDE 24

Details AMO

There are several ways to encode the at-most one constraint

  • Pairwise encoding
  • Sequential counters
  • Log-encoding
  • 2-product encoding (best asymptotic bound: 2n + 4 · √n + O( 4

√n))

TU Dresden, 16.06.2012 npSolver slide 14 of 23

slide-25
SLIDE 25

Details AMO

There are several ways to encode the at-most one constraint

  • Pairwise encoding
  • Sequential counters
  • Log-encoding
  • 2-product encoding (best asymptotic bound: 2n + 4 · √n + O( 4

√n))

  • Split-AMO

– We split a bigger AMO and introduce fresh variables – x1 + · · · + xn ≤ 1 (y +

⌊ n

2 ⌋

  • i=1

xi ≤ 1) (¬y +

n

  • i=⌊ n

2 ⌋+1

xi ≤ 1) – Produces ∼ 3n clauses, best for small n

TU Dresden, 16.06.2012 npSolver slide 14 of 23

slide-26
SLIDE 26

Details AMO

There are several ways to encode the at-most one constraint

  • Pairwise encoding
  • Sequential counters
  • Log-encoding
  • 2-product encoding (best asymptotic bound: 2n + 4 · √n + O( 4

√n))

  • Split-AMO

– We split a bigger AMO and introduce fresh variables – x1 + · · · + xn ≤ 1 (y +

⌊ n

2 ⌋

  • i=1

xi ≤ 1) (¬y +

n

  • i=⌊ n

2 ⌋+1

xi ≤ 1) – Produces ∼ 3n clauses, best for small n – Is there a reference for this?

TU Dresden, 16.06.2012 npSolver slide 14 of 23

slide-27
SLIDE 27

Details on BDDs

BDDs can be understood as dynamic programming approach

  • The weights of satisfied literals are summed up iteratively
  • Per input variable the sum either stays or increases (ITE gate)
  • If the bounds are reached, the translation can be stopped

– The current sum is bigger than k

  • Usually, only 2 clauses per node are needed for encoding a gate
  • For incremental solving, only the last bound needs to be altered

TU Dresden, 16.06.2012 npSolver slide 15 of 23

slide-28
SLIDE 28

Details on BDDs

BDDs can be understood as dynamic programming approach

  • The weights of satisfied literals are summed up iteratively
  • Per input variable the sum either stays or increases (ITE gate)
  • If the bounds are reached, the translation can be stopped

– The current sum is bigger than k

  • Usually, only 2 clauses per node are needed for encoding a gate
  • For incremental solving, only the last bound needs to be altered
  • Note: we do not re-use gates yet among multiple PB constraints
  • Note: if the path in the BDD to 0 are few, we encode the clauses

TU Dresden, 16.06.2012 npSolver slide 15 of 23

slide-29
SLIDE 29

Outline

Motivation Optimization Problems Details in npSolver Translate PB to SAT Solve the Optimization Problem Demo Conclusion

TU Dresden, 16.06.2012 npSolver slide 16 of 23

slide-30
SLIDE 30

How to solve PBO

npSolver offers two main methods to search for an optimal solution

  • Top-down search, by decreasing the bounds
  • Binary search, always partitioning the remaining search space

TU Dresden, 16.06.2012 npSolver slide 17 of 23

slide-31
SLIDE 31

How to solve PBO

npSolver offers two main methods to search for an optimal solution

  • Top-down search, by decreasing the bounds
  • Binary search, always partitioning the remaining search space
  • We include an interface to incremental solvers via pipes

TU Dresden, 16.06.2012 npSolver slide 17 of 23

slide-32
SLIDE 32

How to solve PBO

npSolver offers two main methods to search for an optimal solution

  • Top-down search, by decreasing the bounds
  • Binary search, always partitioning the remaining search space
  • We include an interface to incremental solvers via pipes
  • Surprisingly, non-incremental is best, both searches are equally well

TU Dresden, 16.06.2012 npSolver slide 17 of 23

slide-33
SLIDE 33

How to solve PBO

npSolver offers two main methods to search for an optimal solution

  • Top-down search, by decreasing the bounds
  • Binary search, always partitioning the remaining search space
  • We include an interface to incremental solvers via pipes
  • Surprisingly, non-incremental is best, both searches are equally well

For MaxSAT, we decrease the number of k in the cardinality constraint

  • Encoding the constraint needs several clauses
  • Encoding a PB depends on k
  • E.g. for weighted MaxSAT the constraint is huge
  • By reducing k by some r, we can approximate and save clauses
  • Final constraint:

i⌈ wi r ⌉ < ⌊ k r ⌋ TU Dresden, 16.06.2012 npSolver slide 17 of 23

slide-34
SLIDE 34

Incremental Solving

  • For the top-down approach, the solver can be kept
  • Saving learned clauses should improve the search

TU Dresden, 16.06.2012 npSolver slide 18 of 23

slide-35
SLIDE 35

Incremental Solving

  • For the top-down approach, the solver can be kept
  • Saving learned clauses should improve the search

PB Encoder CP2 Optimization Constraint Iterative Solver SAT Solver BDD, Sorting Network, . . . PB F F′ F′

i, Ui

J′

i

TU Dresden, 16.06.2012 npSolver slide 18 of 23

slide-36
SLIDE 36

Incremental Solving

  • For the top-down approach, the solver can be kept
  • Saving learned clauses should improve the search
  • In binary search, a new solver has to be created for failed formulas

PB Encoder CP2 Optimization Constraint Iterative Solver SAT Solver BDD, Sorting Network, . . . PB F F′ F′

i, Ui

J′

i

TU Dresden, 16.06.2012 npSolver slide 18 of 23

slide-37
SLIDE 37

Outline

Motivation Optimization Problems Details in npSolver Translate PB to SAT Solve the Optimization Problem Demo Conclusion

TU Dresden, 16.06.2012 npSolver slide 19 of 23

slide-38
SLIDE 38

How to use the tool

With npSolver, you can:

  • Displays its parameters
  • Easily encode PB into SAT (also MaxSAT and WBO)
  • Gives statistics about the translation
  • Use a SAT solver of your choice as solver
  • Force the translation to a specific encoding

TU Dresden, 16.06.2012 npSolver slide 20 of 23

slide-39
SLIDE 39

How to use the tool

With npSolver, you can:

  • Displays its parameters
  • Easily encode PB into SAT (also MaxSAT and WBO)
  • Gives statistics about the translation
  • Use a SAT solver of your choice as solver
  • Force the translation to a specific encoding

Ongoing work includes

  • Giving access to each encoding via a library
  • Adding special cases for the “=” constraint (BDD,Adder)
  • Support more encodings
  • Improve modularity
  • Furthermore: Optimization with (parallel) MaxSAT solvers?

TU Dresden, 16.06.2012 npSolver slide 20 of 23

slide-40
SLIDE 40

Outline

Motivation Optimization Problems Details in npSolver Translate PB to SAT Solve the Optimization Problem Demo Conclusion

TU Dresden, 16.06.2012 npSolver slide 21 of 23

slide-41
SLIDE 41

Where can you find the tool?

http://tools.computational-logic.org

We (soon) provide

  • Statically linked binaries
  • The source code of the current version (under GPL 2)
  • We will put updates and fixes online

TU Dresden, 16.06.2012 npSolver slide 22 of 23

slide-42
SLIDE 42

Thanks for your attention

The solver is available at http://tools.computational-logic.org TU Dresden, 16.06.2012 npSolver slide 23 of 23