• No results found

In this section we introduce the problem of pseudo-Boolean optimization [Roussel and Manquinho, 2009], which uses the more expressive pseudo-Boolean constraints (see Sub- section 2.3) and tries to find a model for the constraints while minimizing (resp. max- imizing) a sum of weighted literals. Even though pseudo-Boolean optimization is not purely SAT-based it can be interpreted as a natural extension to SAT-based optimiza- tion. The performance of pseudo-Boolean optimizers benefits heavily from SAT-based techniques as most techniques can be adapted in a more general form. For example, unit propagation for clauses can be adapted to pseudo-Boolean constraints to identify a forced assignment of a literal.

4.6.1 Problem Description

The problem of pseudo-Boolean optimization is to find a model for a set of pseudo- Boolean constraints such that the sum of a target function is minimized (resp. max- imized). We introduce pseudo-Boolean optimization for the case of linear constraints only (see Subsection 2.3), since non-linear pseudo-Boolean constraints are not required for the use cases discussed in this thesis.

Definition 44. (Pseudo-Boolean Optimization Problem) LetP

jaijxjB bi be a pseudo-

Boolean constraint for each i ∈ I with B ∈ {<, ≤, >, ≥, =}. Let f (x1, . . . , xn) be a target

function mapping Boolean variables to a sum of weighted variables d1x1 + . . . + dnxn

for weights d1, . . . , dn∈ Z. Then the pseudo-Boolean optimization (PBO) problem is to

find a model of the set of pseudo-Boolean constraints that minimizes (or maximizes) the value of the target function:

min f (x1, . . . , xn) = d1x1+ . . . + dnxn s.t. V i∈I  P jaijxjB bi  , B ∈ {<, ≤, >, ≥, =}

Any PBO instance can be transformed into an equivalent PBO instance of the form: min f (x1, . . . , xn) = d1x1+ . . . + dnxn s.t. V i∈I  P jaijxj ≥ bi 

In Section2.3we showed how an arbitrary pseudo-Boolean constraint can be transformed into an equivalent constraint of the form P

jaijxj ≥ bi with non-negative coefficients aij

and non-negative value bi. If the target function f (x1, . . . , xn) has to be maximized, then

this is equivalent to minimizing the target function −f (x1, . . . , xn) = −d1x1+. . .+−dnxn.

Any solution of both optimization problems has the same variable assignment. Moreover, any term dixi of the target function with a negative coefficient di can be eliminated by

replacing the term with di− di¬xi. The resulting offset has to be added to the solution

Example 33 shows a PBO instance and its normalized form.

Example 33. (PBO) Consider the following PBO instance:

max 2x1− 3x2− 5¬x3

s.t. 1x1+ 4x2− 4x3 ≤ 3

−3x1+ 2x2− 3x4 ≥ 0

The normalized form looks as follows with an offset of −3−5 = −7 of the target function: min 2x1+ 3¬x2+ 5x3

s.t. 1¬x1+ 4¬x2+ 4¬x3 ≥ 2

3¬x1+ 2 x2+ 3¬x4 ≥ 6

MaxSAT as Special Case of PBO

A MaxSAT instance (ϕh, ϕs) with ϕs = {c1, . . . , cm} and weights w1, . . . , wm can be

interpreted as a special case of PBO as follows:

max f (s1, . . . , sm) = w1s1+ . . . + wmsm s.t. V ci∈ϕs  ¬si+Pl∈ci1 · l ≥ 1  V c∈ϕh( P l∈c1 · l ≥ 1)

1. (Target function) We define f (s1, . . . , sm) = w1s1 + . . . + wmsm for fresh selector

variables s1, . . . , sm as target function which has to be maximized.

2. (Pseudo-Boolean Constraints) For each soft clause ci ∈ ϕs we add the hard clause

¬si∨ ci to the set of hard clauses. The selector variables ensure that whenever one

of them is assigned to true the corresponding clause ci is taken into account (see

Remark1). Afterwards, each hard clause in ϕh is translated into a pseudo-Boolean

constraint (see Section 2.3).

4.6.2 Algorithms

The problem of pseudo-Boolean optimization has been the subject of research for many years and various solving approaches have been developed [Roussel and Manquinho, 2009]. A common approach is to iteratively call a pseudo-Boolean solver (PBS). See Remark 3 for a short description of pseudo-Boolean solvers. With the help of a pseudo- Boolean solver a linear search or a binary search can be performed by restricting the search space after a better solution was found. This approach is similar to using a SAT solver as a black box for the MaxSAT optimization problem (cf. Algorithm 4.4 and Algorithm 4.5). Also, a branch & bound approach [Land and Doig, 1960, Dakin, 1965] can be used for solving PBO.

Algorithm 4.9: Linear search for computing PBO: pboLS

Input: A set of pseudo-Boolean Constraints ϕ and a target function

f (x1, . . . , xn) = d1x1+ . . . + dnxn to minimize

Output: Tuple (st, β) such that st = true if a solution exists and β being an

assignment with the optimal solution, otherwise st = false

1 solver ← new inc/dec PBS solver 2 solver. add(ϕ)

3 if solver. unsat() then 4 return (false, ∅) 5 β ← solver. model()

6 cost ←Pmi=1di, st ← true 7 while st do

8 solver. add(Pni=1di· xi < cost)

9 st ← solver. sat() 10 if st = true then 11 β ← solver. model() 12 cost ←Pmx i∈βdi 13 return (true, β)

Algorithm4.9 shows the linear search for PBO. In Lines 1 to 4 the solver is initialized, the constraints are added and checked for satisfiability. Afterwards, the solution found is used as initial upper bound (Lines 5–6). The main loop continues as long as a better solution can be found, which is tested by adding the pseudo-Boolean constraintPn

i=1di· xi < cost to ensure that the next solution has less costs (Lines 8–9). Whenever a better

solution is found the current model and costs are updated (Lines 11–12). At last, if no better solution can be found, the current solution is returned (Line 13). The same advantages for linear search for PBO hold as described for linear search for solving MaxSAT (cf. Algorithm 4.4). Linear search performs only successful calls to the solver except for the last call. In our industrial applications finding a model is always faster than proving unsatisfiability. Moreover, the new pseudo-Boolean constraint of each iteration can be added without removing the old constraint, since the new constraint is more restrictive. As a consequence, all learned constraints of previous solver runs can be kept.

One prominent example of a PBO solver, based on linear search, is included within the logic framework SAT4J2 [Le Berre and Parrain, 2010].

2SAT4J homepage:

4.6.3 Enumerating all Solutions

The enumeration of all PBO solutions can be done analogously to the enumeration of all MinCS solutions (see Subsection 4.1.4). We just have to replace the optimization algo- rithm computeMinCS by any PBO optimization algorithm computePBO. The subroutine buildBlockingConstraint has to be modified such that the current model is blocked (see Subsection 4.1.4)

Instead of blocking models, we could also block the resulting value of the target function. For example, the minimal value of the target function is 100. By blocking this value, the next solution shows us the next best target function value. The next solution is at least 101, but there could also be a huge gap. For example, the next solution could yield in 150. Blocking the target function value can be done by adding the pseudo-Boolean constraint Pn

i=1di· xi > v to the set of constraints. Value v is the target function value

of the previous solution.