Incomplete Dynamic Backtracking for Linear Pseudo-Boolean Problems

5 downloads 0 Views 142KB Size Report
feasibility is hard to establish CP methods therefore seem appropriate, and ..... applied to optimisation problems by solving a sequence of satisfaction ..... Using this model CPLEX was able to solve up to N = 9 in a reasonable time (Bosch,.
Annals of Operations Research 130, 57–73, 2004  2004 Kluwer Academic Publishers. Manufactured in The Netherlands. 1

1

2

2

3

3

5 6

Incomplete Dynamic Backtracking for Linear Pseudo-Boolean Problems

OF

4

7

9

STEVEN PRESTWICH ∗

[email protected] Cork Constraint Computation Centre, Department of Computer Science, University College, Cork, Ireland

PR O

8

10 11

13 14 15 16 17 18

Abstract. Many combinatorial problems can be modeled as 0/1 integer linear programs. Problems expressed in this form are usually solved by Operations Research algorithms, but good results have also been obtained using generalised SAT algorithms based on backtracking or local search, after transformation to pseudo-Boolean form. A third class of SAT algorithm uses non-systematic backtracking to combine constraint propagation with local search-like scalability, at the cost of completeness. This paper describes such an algorithm for pseudo-Boolean models. Experimental results on a variety of problems are encouraging, in some cases yielding improved solutions or performance compared to previous algorithms. Keywords: satisfiability, integer programs, local search

TE

19 20 21

D

12

Introduction

22

43

∗ This work has received support from Science Foundation Ireland under Grant 00/PI.1/C075.

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

CO RR

25

UN

24

EC

42

Propositional satisfiability (SAT) algorithms have been successfully applied to many real-world combinatorial problems. SAT is highly expressive and was the first problem shown to be NP-complete. Unfortunately, it is not sufficiently expressive to model some problems in a practical sense, either because weights cannot be expressed or because the models are very large. Some researchers have proposed more general languages including nested equivalences (Li, 2000), exclusive-or (Baumgartner and Massacci, 2000) and disjunctions of conjunctions of literals (Whittemore, Kim, and Sakallah, 2001). A recent language called Regular-SAT (Béjar et al., 2001) generalises the notion of literal to finite domains. A well-established language that subsumes SAT is the integer linear program (ILP): linear constraints on integer (typically 0/1) variables. ILP problems have been solved for decades using Operations Research (OR) algorithms. Broadly speaking, OR methods are most successful at cost reasoning, while Constraint Programming (CP) methods excel at feasibility reasoning. For problems in which feasibility is hard to establish CP methods therefore seem appropriate, and interesting results have been obtained by generalising SAT solvers to ILP. The classical SAT backtracking algorithm is the Davis–Putnam–Logemann–Loveland procedure (DPLL) (Davis, Logemann, and Loveland, 1962) which combines depth-first search with inference rules such as unit propagation. Modern systematic SAT solvers such as Chaff (Moskewicz et al., 2001) are forms of DPLL. Versions of DPLL were extended to ILP (Aloul et al., 2002; Barth, 1995) and performed well on several integer programming

23

44

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

VTEX(GIT) PIPS No:5273114 artty:res (Kluwer BO v.2002/10/03) a5273114.tex; 4/05/2004; 11:52; p. 1

58

3 4 5 6 7 8 9 10 11 12 13 14 15

benchmarks and randomly-generated problems. However, like any depth-first search algorithm DPLL has poor scalability on some classes of problem, and a local search approach often scales much better to large problems. An early local search algorithm for SAT was GSAT (Selman, Levesque, and Mitchell, 1992), which was later improved by a random walk heuristic, giving the Walksat family of algorithms (Selman, Kautz, and Cohen, 1994). Walksat was extended to ILP (Walser, 1997) and performed well on radar surveillance benchmarks and the Progressive Party Problem. Besides systematic backtracking and local search, a third class of algorithm is nonsystematic backtracking. The aim is to combine backtrack-style constraint handling with the scalability of local search, by sacrificing completeness. This approach has been successfully applied to SAT and other combinatorial problems (Prestwich, 2000, 2001, 2002a, 2002b, 2002c). In this paper a nonsystematic SAT backtracker is generalised to ILP and gives good results. Section 1 describes the algorithm, section 2 applies it to a variety of problems, and section 3 draws conclusions. The paper is an extended version of (Prestwich, 2002d).

OF

2

PR O

1

PRESTWICH

16

20 21 22 23 24 25 26

In this section we describe the new algorithm. The background on inference rules is based on (Dixon and Ginsberg, 2002) and other papers. 1.1. Linear pseudo-Boolean models

ILP models contain constraints of the form  wi vi ∼ d,

27

30 31 32 33 34 35 36 37 38 39 40 41 42 43

where ∼ is one of the operators {< , >, , , =}, the weights wi and the constant d are (possibly negative) integers, and the variables vi have domain {0, 1}. Other integer values can be permitted for the vi but such problems can always be transformed into 0/1 form. Any such constraint can be transformed into a normal form involving only  and positive d and wi . To simplify the description and implementation of the algorithm we do this, but find it more convenient to think in terms of  constraints (this makes no formal difference). Our constraints are of the form  wi li  d,

CO RR

29

i

UN

28

TE

19

Nonsystematic backtracking for ILP

EC

18

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

1.

D

17

1

i

where a literal li is either a variable vi or its negation v¯i = 1 − vi , and d and the wi are non-negative. As an example of transformation from ILP to this normal form consider the constraint 3v1 + 2v2 − v3 = 2. This expands to 3v1 + 2v2 − v3  2 and 3v1 + 2v2 − v3  2. In the first inequality the negative weight can be removed by using the fact that −cli is equivalent to cl¯i −c, giving 3v1 +2v2 + v¯3  3. The second inequality

44

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

VTEX(GIT) PIPS No:5273114 artty:res (Kluwer BO v.2002/10/03) a5273114.tex; 4/05/2004; 11:52; p. 2

INCOMPLETE DYNAMIC BACKTRACKING FOR PSEUDO-BOOLEAN PROBLEMS 1 2 3

59

can be expressed as −3v1 − 2v2 + v3  −2. Again the negative weights can be removed giving 3v¯1 + 2v¯2 + v3  3. We shall state constraints in whatever form seems most convenient, but note that they are transformed before being passed to the algorithm.

4

OF

1.2. DPLL generalised to ILP

7

14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

PR O

13

D

12

TE

11

EC

10

The DPLL algorithm can be expressed in terms of the OR concept of cutting planes, a proof system with two inference rules: (i) derive taking a linear com an inequality by bination of two others; (ii) given a constraint wi vi  d derive (wi /x)vi  d/x where x is a common factor of the wi . Using these two rules we can simulate SAT resolution proofs. For example, the SAT clauses a ∨ b ∨ c and b¯ ∨ d are represented by the linear constraints a + b + c  1 and b¯ + d  1. Because b + b¯ = 1 by definition we can apply the first inference rule, adding the constraints to obtain a + c + d  1 which corresponds to the resolvent a ∨ c ∨ d. The second inference rule is invoked when duplicated literals occur. For example, to resolve the clauses a ∨ b ∨ c and a ∨ b¯ we apply the first inference rule to get 2a + c  1. To this we can add the tautologous constraint c  0 giving 2a + 2c  1, then apply the second inference rule to get a + c  1 which corresponds to the resolvent a ∨ c. In DPLL the main inference rule is unit propagation: resolve a unit clause (a clause containing exactly one literal) with other clauses as far as possible; if this creates new unit clauses then resolve those; continue until no more unit clause resolution is possible. This rule is alternated with the assignment of a truth value to a variable, which is equivalent to adding a new unit clause. To keep track of added unit clauses, DPLL implementations associate a domain of truth values dom(v) = {T , F } with each variable v. On reaching a dead-end in which a domain becomes empty, backtracking occurs and the appropriate domain values are restored. (An empty domain corresponds to the derivation of both unit clauses v and v¯ which yield the empty resolvent, implying no solution.) Heuristics control the selection of variables and truth values, and other techniques may be added such as learning, intelligent backtracking and random restarts. Because resolution can be simulated by cutting planes, so can unit propagation and therefore DPLL executions. The same techniques can be applied to pseudo-Boolean models that do not correspond to SAT models, thus generalising DPLL to arbitrary 0/1 ILP models. The ana logue of unit resolution for a constraint ni=1 wi li  d is as follows. Any currently unassigned variable in the constraint whose weight is greater than d − s, where s is the sum of the weights of currently assigned literals in the constraint, can have a domain value removed: 0 if the literal is positive (v) and 1 if it is negative (v). ¯ An implementation technique speeds up execution: in a preprocessing phase before search, sort the variables in each constraint into order of decreasing weight. Then as soon as we find a variable in a constraint whose weight is no greater than d − s we can ignore the rest of the variables in that constraint.

CO RR

9

UN

8

2 3 4

5 6

1

44

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

VTEX(GIT) PIPS No:5273114 artty:res (Kluwer BO v.2002/10/03) a5273114.tex; 4/05/2004; 11:52; p. 3

60

3 4 5 6 7 8 9 10 11 12 13 14

function IDB(b) A = {}, U = {v1 , . . . , vn } while U = {} vi = HA(U ), d = HV(vi ) if propagating vi = d is inconsistent with A if propagating vi = 1 − d is inconsistent with A do min(b, |A|) times (vj = d  ) = HU(A) A = A − {vj = d  }, U = U ∪ {vj } else A = A ∪ {vi = 1 − d}, U = U − {vi } else A = A ∪ {vi = d}, U = U − {vi } return A

OF

2

PR O

1

PRESTWICH

15 16

Figure 1. The IDB algorithm.

18

1.3. Nonsystematic backtracking

19

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

TE

23

EC

22

CO RR

21

Backtracking algorithms can suffer from poor scalability: a wrong decision high in the search tree leads to a subspace containing no solutions, and recovery takes an exponential time. In contrast, local search algorithms (and other stochastic algorithms such as simulated annealing, genetic algorithms, neural networks and ant colonies) often scale far better to large problems. However, when applied to constraint satisfaction problems they do not (usually) benefit from powerful OR and CP methods; instead they typically allow constraints to be violated, but attempt to minimise the violations to obtain a feasible solution. This makes them unsuited to some classes of problem, and a current area of research is the hybridisation of local search with CP and OR techniques. One such hybrid approach is a non-systematic form of backtracking, shown in figure 1, where A is the set of current variable assignments (initially empty) and U is the set of currently unassigned variables (initially containing all the variables). The algorithm begins like a standard backtracker by selecting a variable using a heuristic (HA), assigning a value to it with default given by another heuristic (HV), performing constraint propagation, then selecting another variable; on reaching a dead-end it backtracks then resumes variable selection. The novel feature of the algorithm is the choice of backtracking variable: the variables selected for unassignment are chosen using another heuristic (HU) that does not preserve completeness. As in Dynamic Backtracking (Ginsberg, 1993) only the selected variables are unassigned, without undoing later assignments. Because of this resemblance we call the algorithm Incomplete Dynamic Backtracking (IDB). This particular IDB implementation is called Saturn to reflect its SAT origins. We sometimes refer to IDB as Constrained Local Search because of its local search-like scalability on problems such as random 3-SAT (Prestwich, 2000), and the fact that like a backtracker it never violates a constraint. Unlike Dynamic Backtracking IDB is not

UN

20

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

D

17

1

44

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

VTEX(GIT) PIPS No:5273114 artty:res (Kluwer BO v.2002/10/03) a5273114.tex; 4/05/2004; 11:52; p. 4

INCOMPLETE DYNAMIC BACKTRACKING FOR PSEUDO-BOOLEAN PROBLEMS

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

OF

6

PR O

5

D

4

TE

3

complete and we must sometimes force the unassignment of more than one variable. We do this by adding an integer noise parameter b  1 to the algorithm and unassigning b variables at each dead-end, after undoing the unit propagation that led to the dead-end. The noise parameter must be tuned to problems or problem classes by the user, as in most local search algorithms. There is an implementation issue regarding the combination of IDB and constraint propagation. Suppose we have reached a dead-end after assigning variables v1 , . . . , vk and vk+1 , . . . , vn remain unassigned. We would like to unassign some arbitrary variable vu , where 1  u  k, leaving the domains in the state they would have been in had we assigned only v1 , . . . , vu−1 , vu+1 , . . . , vk . A technique to achieve this has been described in previous papers. Briefly, a counter cv,d is associated with each variable-value pair (v, d), denoting how many constraints would be violated if the assignment v = d were added (or in the case of an already-assigned v, if the current v assignment were replaced by v = d). This information is maintained incrementally, and at any point during the search d ∈ dom(v) if and only if cv,d = 0. Thus domain sizes are maintained for both unassigned and assigned variables. This mechanism is used to maintain binary domains in the current algorithm. It remains to describe the heuristics. The HA heuristic prefers variables with current domain size 1 over those with domain size 2, breaking ties randomly. Conversely, the HU heuristic prefers variables with current domain size 2, also breaking ties randomly. Thus HU exploits the extra domain information provided by the cv,d counters, and in experiments it greatly speeds up convergence to a solution. (Variable selection for [un]assignment takes constant time, unlike in previous Saturn implementations with more complex variable selection heuristics.) The HV heuristic selects the previous assigned value for a variable; these values are recorded, and initially set to a random value. This appears to speed up the rediscovery of consistent partial assignments. However, to avoid stagnation it attempts to use a different (randomly-chosen) value for at least one variable after each dead-end.

EC

2

CO RR

1

1.4. Application to optimisation problems The algorithm described so far applies to constraint satisfaction problems. It can be applied to optimisation problems by solving a sequence of satisfaction problems with an increasingly tighter cost bound (this was done for the Social Golfer problem in section 2.4). An obvious heuristic is to begin the search for each solution in the neighbourhood of the previous solution, but this has not yet been implemented.

38 39 40 41 42 43

UN

36 37

61

2.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

Experimental results

38

This section evaluates Saturn on several combinatorial problems. All experiments are performed on a 733 MHz Pentium III. Several references are made to CSPLib, a Webbased library of combinatorial problems.1 On some of the problems it is possible to add symmetry breaking constraints, but we do not do this because such constraints often make a problem harder to solve by local search (Prestwich, 2003).

44

39 40 41 42 43 44

VTEX(GIT) PIPS No:5273114 artty:res (Kluwer BO v.2002/10/03) a5273114.tex; 4/05/2004; 11:52; p. 5

62

PRESTWICH

3 4 5 6 7 8 9 10 11 12 13 14 15

Suggest Documents