Applied Mathematics and Computation 215 (2009) 1106–1117
Contents lists available at ScienceDirect
Applied Mathematics and Computation journal homepage: www.elsevier.com/locate/amc
A new bounding procedure and an improved exact algorithm for the Max-2-SAT problem Gintaras Palubeckis Department of Practical Informatics, Kaunas University of Technology, Studentu 50-408, 51368 Kaunas, Lithuania
a r t i c l e
i n f o
Keywords: Artificial intelligence Satisfiability Max-SAT Branch-and-bound Tabu search
a b s t r a c t Given a CNF (conjunctive normal form) Boolean expression with clauses of size at most two, the Max-2-SAT problem asks to find a truth assignment to the Boolean variables that makes true the maximum number of clauses. In this paper, we describe an innovative upper bound computation procedure which is centered around the use of equations and inequalities that are satisfied by all solutions to the problem. The procedure is incorporated in a branch-and-bound algorithm for Max-2-SAT. An initial solution to the problem is provided by an iterated tabu search heuristic. We present computational experience on the Max-2-SAT benchmark instances from the Max-SAT Evaluation 2007. The results show that the developed branch-and-bound algorithm is very competitive with the best previously reported techniques. Ó 2009 Elsevier Inc. All rights reserved.
1. Introduction Given a conjunctive normal form (CNF) formula F ¼ C 1 ^ C 2 ^ . . . ^ C m , the Boolean satisfiability (SAT) problem asks whether there exists a truth assignment to the Boolean variables that makes F true. Its natural generalization is the maximum satisfiability problem (Max-SAT for short), which is to find a truth assignment that satisfies the maximum number of clauses in F. The maximum 2-satisfiability (Max-2-SAT) problem is a restricted version of Max-SAT in which each clause C i ; i 2 f1; . . . ; mg, is of size at most two, that is, F contains only binary and unit clauses. The Max-2-SAT problem arises in various contexts, including minimization of the number of breaks in sports scheduling [23], creating optimized cut-out sheets for paper models from textured polygon meshes [30], interconnection routing in the physical design of VLSI circuits [18,34], and inferring autonomous system relationships in the Internet [9–11]. Furthermore, the well-known max-cut and maximum independent set problems can be efficiently (without introducing new variables) modeled as special cases of Max-2-SAT [6,35]. In particular, this fact implies that the decision version of Max-2-SAT is NP-complete. In [26,27], a reduction from the problem of coloring the vertices of a graph to the problem of finding a maximum independent set was presented. This shows that also the graph coloring problem can be cast into the Max-2-SAT framework. Because of the practical importance of the Max-SAT problem, considerable attention has been given to the development of algorithms for its solution. Most of the existing algorithms are based on the branch-and-bound technique. Their success greatly depends on the quality of the bounds used to prune the search tree. Such algorithms were presented in [1,2,5,7,15,21,22,28,29,32,33]. Among them, the algorithms given in [1,29] are specially designed to solve the Max-2-SAT problem. A branch-and-cut algorithm for this problem was developed by de Klerk and Warners [8]. The lower bounds (on the number of unsatisfied clauses) in their algorithm are computed by solving semidefinite programming (SDP) relaxations of Max-2-SAT. The SDP relaxations were compared with linear programming (LP) relaxations in [14]. A cutting plane E-mail address:
[email protected] 0096-3003/$ - see front matter Ó 2009 Elsevier Inc. All rights reserved. doi:10.1016/j.amc.2009.06.043
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117
1107
algorithm using LP relaxation was given in [6]. This algorithm was developed for the Max-2-SAT case. An LP-based branchand-cut algorithm for the general Max-SAT problem was described in [17]. An important research endeavor has been to convert a Max-SAT instance into a series of SAT instances and use a SAT solver to solve them. An example of such an approach can be found in [34]. For problems of large dimension, a few approximation and many heuristic algorithms have been proposed. The former include the 0.87856-approximation algorithm of Goemans and Williamson [13] and 0.940-approximation algorithm of Lewin et al. [20], both developed for the Max-2-SAT problem (for more details, see [23]). A review of heuristic algorithms for Max-SAT is presented in [31]. More recent studies on heuristic techniques in this area include [4,16]. In this paper, we focus on the Max-2-SAT problem. Our main contribution is an innovative procedure for computing upper bounds on the number of satisfied clauses. The procedure is able to provide reasonably tight bounds within very moderate CPU times. Its high efficiency is confirmed by numerical experiments with the developed branch-and-bound algorithm. Basically, a fairly good upper bound is obtained already at the root node of the search tree. The idea behind the bound computation procedure is to reduce the objective function of a binary programming formulation of the problem by progressively adding certain terms to it, which are non-negative for each solution (truth assignment) to the problem. Typically, at the end of this process, the objective function depends only on a few (or even none) binary variables. In addition, it contains a constant term. Simultaneously setting all variables (if any) to 1 gives an upper bound for the global optimum. Throughout the reduction process, the procedure also uses several simplification and inference rules for Max-SAT known in the literature. Our branch-and-bound algorithm starts by invoking an iterated tabu search heuristic for Max-2-SAT. For problem instances amenable to exact solution methods, this heuristic delivers optimal or close-to-optimal truth assignments within a very short, almost negligible amount of time. Thus, the branch-and-bound algorithm is supplied with a tight lower bound at very little computational cost. The remainder of the paper is organized as follows: in Section 2, we consider some families of inequalities and equations satisfied by each solution to the Max-2-SAT problem. They are used in the upper bounding procedure described in Section 3. Section 4 presents our branch-and-bound algorithm. Section 5 gives a brief description of the iterated tabu search heuristic for Max-2-SAT. The results of an empirical evaluation of the proposed algorithms are reported in Section 6. Finally, Section 7 concludes the paper.
2. Valid inequalities xi . In Let x1 ; . . . ; xn denote variables which may take values TRUE and FALSE. A literal li is either a variable xi or its negation the Max-2-SAT problem, each clause in F is either of the form li _ lj or li . The problem can be formulated as a mixed binary xi – a linear program. To this end, we associate to each Boolean variable xi ; i 2 f1; . . . ; ng, a 0–1 variable yi and to its negation 0–1 variable yiþn . Actually, yi and yiþn constitute a pair of variables that are dual in some sense. We map a binary clause xk and, similarly, j is equal to q C r ¼ lk _ lq to a variable zij , where i is equal to k or k þ n depending on whether lk is xk or xq . A unit clause xi (respectively, xi ) is represented by the variable yi (respectively, or q þ n depending on whether lq is xq or yiþn ). In the cases where the index i is not clear from the context, we will assume that the sum i þ n is taken modulo 2n (except the case of i ¼ n). In particular, the variable dual to yi is yiþn if i 6 n, and yin ¼ yiþnmod2n if i > n. We also assume that the order of the subscripts of zij is not significant, i.e., zij and zji represent the same variable. Let P denote the set of all unordered pairs ði; jÞ such that zij is a variable corresponding to some binary clause of the formula F. Similarly, let K be the set of all indices i such that yi is a variable corresponding to some unit clause of F. Now the Max-2-SAT problem can be written as:
maximize
f ðy; zÞ ¼
X ði;jÞ2P
subject to zij 6 yi þ yj
wij zij þ
X
wi yi ;
ð1Þ
i2K
for all ði; jÞ 2 P;
ð2Þ
zij 6 1 for all ði; jÞ 2 P;
ð3Þ
yi 2 f0; 1g for all i ¼ 1; . . . ; 2n; yi ¼ 1 yiþn for all i ¼ 1; . . . ; n;
ð4Þ ð5Þ
where wij (respectively, wi ) is the number of (identical) binary (respectively, unit) clauses mapped to the variable zij (respectively, yi ). Essentially the same formulation was considered in many papers (for example, [2,14,33]). The value of the objective function of (1)–(5) gives the number of satisfied clauses. According to (2), a binary clause is satisfied if and only if at least one of the variables corresponding to its literals is set to 1. Observe that the variables zij ; ði; jÞ 2 P, are continuous. This is correct since they are bounded from above by (3) and the function f is maximized. Obviously, the mixed binary linear program (1)–(5) is redundant, since, using (5), half of the y variables can be eliminated. However, for clarity of presentation, we ignore this possibility and retain the formulation with two 0–1 variables per Boolean variable. It will also be convenient to assume that the variables zij are defined not only for ði; jÞ 2 P but for all pairs in U ¼ fði; jÞji; j ¼ 1; . . . ; 2n; j > i; j – i þ ng. It is important to note that, since all the coefficients in (1) are positive, the variables zij ; ði; jÞ 2 U, can be expressed through y1 ; . . . ; y2n : indeed, from (2) and (3), we have zij ¼ minð1; yi þ yj Þ. We thus see that the auxiliary variables zij are used to linearize the objective function of the problem.
1108
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117
Given an instance F of the Max-2-SAT problem, we can associate to it an edge-weighted graph GðFÞ ¼ ðVðFÞ; EðFÞÞ with vertex set VðFÞ ¼ f1; . . . ; 2ng and edge set EðFÞ ¼ E1 ðFÞ [ E2 ðFÞ [ E3 ðFÞ, where E1 ðFÞ stands for the set of loops fði; iÞji 2 Kg; E2 ðFÞ ¼ P and E3 ðFÞ ¼ fði; i þ nÞji ¼ 1; . . . ; ng. The edges of GðFÞ are assigned one of two colors: green or red. Namely, all the edges in E1 ðFÞ [ E2 ðFÞ are green, whereas all the edges in E3 ðFÞ are red. The weights attached to the green edges are the coefficients of the objective function (1). The weights of the red edges may be deemed to be equal to infinity. The graph GðFÞ will be used in the upper bound computation procedure presented in Section 3. Returning to the program (1)–(5), we define S to be the set of all 0–1 valued solutions ðy; zÞ to it such that zij ¼ minð1; yi þ yj Þ for each ði; jÞ 2 U. The algorithm we present in this paper is centered around the use of equations and inequalities that are satisfied by all solutions in S. Suppose that ði; jÞ; ði þ n; jÞ 2 P for some i 2 f1; . . . ; ng and j 2 f1; . . . ; 2ng. Then the following equation is valid for all ðy; zÞ 2 S:
zij þ ziþn;j ¼ 1 þ yj :
ð6Þ
The above equation, in fact, describes the well-known inference rule, called replacement of almost common clauses, for the Max-2-SAT case (its general form is attributed to Bansal and Raman [3] and is presented as Rule 1 in [22]). The rule says that, for any assignment of values to the Boolean variables, the number of unsatisfied clauses remains the same when the binary xi _ xj in the formula F are replaced by the unit clause xj . Inference rules describing a replacement operclauses xi _ xj and ation with such property are called sound [22]. Notice that the left-hand side of (6) corresponds to a triangle in GðFÞ with two green and one red edges. To define another very useful equation, we assume that there exist i; j 2 K such that ði þ n; j þ nÞ 2 P. Then we can write
yi þ yj þ ziþn;jþn ¼ 1 þ zij :
ð7Þ
Suppose, for simplicity, that i 6 n; j 6 n. Eq. (7) describes an inference rule which replaces the clauses xi ; xj and xi _ xj in F by xi _ xj and an empty clause, which is trivially unsatisfiable. This rule was formulated in [22] (as Rule 3) and also mentioned in [19]. xj with a chain of binary clauses. Using The above discussed rule was generalized in [15,22] by substituting the clause xi _ the y and z variables, this generalization can be defined as follows:
yi1 þ
s1 X
zir þn;irþ1 þ yis þn ¼ 1 þ
r¼1
s1 X
zir ;irþ1 þn ;
ð8Þ
r¼1
where s P 3. Li et al. [22] gave a simple proof that the rule underlying (8) (called Rule 4 in [22]) is sound. Consequently, (8) is valid for all ðy; zÞ 2 S. Eq. (8) is equivalent in some sense to s1 X
zir þn;irþ1 þ 1 ¼
r¼1
s1 X
zir ;irþ1 þn þ yi1 þn þ yis :
ð9Þ
r¼1
Indeed, (8) is obtained by adding up (9) and two equations of type (5): yi1 ¼ 1 yi1 þn and yis þn ¼ 1 yis . The sum in the lefthand side of (9) is formed by following the edges of the odd chain ði1 þ n; i2 ; i2 þ n; i3 ; . . . ; is Þ in the graph GðFÞ. The odd-indexed edges of the chain are green and even-indexed edges are red. We remark that the chain may be closed, that is, (9) also holds for the cases where is ¼ i1 þ n. Along with sound inference rules, we also use inequalities that are satisfied by all feasible solutions of the Max-2-SAT problem. Formally, we say that an inequality ay þ bz 6 a is valid for S if it is met by each pair ðy; zÞ 2 S. To present the basic valid inequalities, we use the graph GðFÞ, though the complete 2n-vertex graph K 2n having the same red edges as GðFÞ is also apt. A class of valid inequalities can be derived by considering complete subgraphs of GðFÞ. Proposition 1. Let k P 3 and G0 ¼ ðV 0 ; E0 Þ be a k-vertex complete subgraph of GðFÞ with no red edge. Then the following inequality is valid for S:
X
zij
ði;jÞ2E0
X
yi 6
i2V 0
k1 2
:
ð10Þ
Proof. For any q 2 f1; . . . ; kg, denote by kðqÞ the value side of (10) for a solution ðy; zÞ 2 S with q of ofthe left-hand exactly k kq k 0 kðqÞ ¼ q. The right-hand side of (10) is equal to ðk 1Þ. the variables in fyi ji 2 V g setto 1. Clearly, 2 2 2 kq 0 0 þ q P k 1. It is easy to see that k ðqÞ is non-increasing up to q ¼ k 1, that is, Thus, (10) holds if k ðqÞ :¼ 2 k0 ðq 1Þ P k0 ðqÞ; q ¼ 2; . . . ; k 1. Now, the validity of (10) is implied by the fact that k0 ðk 1Þ ¼ k 1. h Another class of inequalities valid for S is the class of constraints defined by the odd green cycles in GðFÞ (possibly with chords):
X ði;jÞ2EðcÞ
zij
X i2VðcÞ
yi 6 ðp 1Þ=2;
ð11Þ
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117
1109
where VðcÞ and EðcÞ are the vertex and edge sets of the cycle c, respectively, and p ¼ jVðcÞj P 3. However, inequalities of type (11) did not prove to be useful in our approach to Max-2-SAT. Cycle inequalities of another type are obtained by adding (7) to (11). For example, by adding y2 þ y3 þ z2þn;3þn ¼ 1 þ z23 to z12 þ z13 þ z23 y1 y2 y3 6 1 we get z12 þ z13 þ z2þn;3þn y1 6 2. If p P 5, then this operation can be repeated by taking (7) for i; j 2 VðcÞ such that yi ; yj and zij are still present in the current sum of (11) and (7). In general, we have the following cycle inequality:
X
zij yuðcÞ 6 ðk 1Þ=2;
ð12Þ
ði;jÞ2E ðcÞ
where k P 5 is an odd number, c ¼ ðVðcÞ; EðcÞÞ is a k-vertex cycle in GðFÞ with ðk 1Þ=2 red edges, E ðcÞ is the set of green edges of c, and uðcÞ is the vertex of c whose both incident edges are green. Again, the cycle c may have chords. The odd cycle inequalities were proposed by Cheriyan et al. [6]. They used them in their cutting plane algorithm for the Max-2-SAT problem. Let
X
aij zij þ
ði;jÞ2U
X
bi yi 6 a
ð13Þ
i2VðFÞ
be an inequality that is valid for S. We can associate to it a support graph H ¼ ðVðHÞ; EðHÞÞ with edge set EðHÞ ¼ fði; jÞ 2 Ujaij – 0g and vertex set VðHÞ consisting of the endpoints of the edges in EðHÞ (we assume that bi ¼ 0 for all i 2 VðFÞ n VðHÞ). Many valid inequalities for the Max-2-SAT problem can be constructed by applying certain operations to the graph H. One of them is a vertex splitting operation defined as follows: take a vertex v 2 VðHÞ of degree two and replace it along with incident edges ðs; v Þ and ðp; v Þ by vertices q; r R VðHÞ; q – s þ n; r – p þ n; r – q þ n, and edges ðs; qÞ; ðp; rÞ and ðq; rÞ. We denote the resulting graph by H0 ¼ ðVðH0 Þ; EðH0 ÞÞ. Proposition 2. Let (13) be a valid inequality, H its support graph, v a degree-two vertex of H, and s; p 2 VðHÞ the vertices adjacent to v. If asv > 0 and apv > 0, then the following inequality is valid for S too:
X
a0ij zij þ
X
bi yi 6 a;
ð14Þ
i2VðHÞnfv g
ði;jÞ2EðH0 Þ
where a0sq ¼ asv ; a0pr ¼ apv ; a0qr ¼ bv and a0ij ¼ aij for ði; jÞ 2 EðH0 Þ n fðs; qÞ; ðp; rÞ; ðq; rÞg. Proof. Let ðy; zÞ be any solution in S. Let us denote the value of the left-hand side of (13) (respectively, (14)) at ðy; zÞ by hðy; zÞ 0 (respectively, h ðy; zÞ). There are two cases to consider. 0
1. yq ¼ yr ¼ g 2 f0; 1g. It is easy to see that h ðy; zÞ ¼ hðy0 ; zÞ 6 a, where y0 is obtained from y by flipping the value of yv if yv – g, and y0 ¼ y if yv ¼ g. Hence, (14) is valid for ðy; zÞ. 0 2. yq ¼ 0; yr ¼ 1 (the case of yq ¼ 1; yr ¼ 0 is symmetric). If yv ¼ 1, then h ðy; zÞ ¼ hðy; zÞ a0sq ð1 ys Þ 6 a. Therefore, assume that yv ¼ 0. Then we can write 0
h ðy; zÞ ¼ hðy; zÞ þ bv þ a0pr ð1 yp Þ:
ð15Þ
Now consider ðy0 ; z0 Þ 2 S such that y0v ¼ z0sv ¼ z0pv ¼ 1; y0i ¼ yi for all i 2 VðFÞ n fv g, and z0ij ¼ zij for all ði; jÞ 2 U n fðs; v Þ; ðp; v Þg. It can be easily seen that hðy0 ; z0 Þ ¼ hðy; zÞ þ bv þ asv ð1 ys Þ þ apv ð1 yp Þ. Since hðy0 ; z0 Þ 6 a it follows that 0 hðy; zÞ 6 a bv asv ð1 ys Þ apv ð1 yp Þ. Combining this inequality with (15) gives h ðy; zÞ 6 a asv ð1 ys Þ. If asv > 0, 0 then h ðy; zÞ 6 a. So, the proof is complete. h As an example, we can take the triangle inequality zsp þ zsv þ zpv ys yp yv 6 1 (see (10)). By applying the vertex splitting operation to v, we get the valid inequality zsp þ zsq þ zpr zqr ys yp 6 1. Proposition 2 also holds in the case where (13) is replaced by an equation that is valid for all ðy; zÞ 2 S. Applying this proposition to an equation of type (6) yields
zsq þ zsþn;r zqr 6 1:
ð16Þ
Let c be the cycle defining (12). Suppose that q; r and s in (16) are such that ðq; rÞ 2 E ðcÞ and s R VðcÞ; s – uðcÞ þ n. Then by adding (16) to (12) we get an inequality of type (12) for the cycle c0 obtained from c by replacing the edge ðq; rÞ with the edges ðs; qÞ; ðs þ n; rÞ and ðs; s þ nÞ. All inequalities (12) for odd cycles of length at least seven can be derived in this way. Thus, these inequalities are weaker than the pentagon inequality (i.e., (12) for c with jVðcÞj ¼ 5), which is somewhat unexpected. Next we briefly discuss another simple operation on H which can be used for producing valid inequalities. We call it edge splitting and define as follows. Given an edge ðu; v Þ of H and vertices q; r 2 VðFÞ n VðHÞ; q – u þ n; r – v þ n; r – q þ n, replace ðu; v Þ by the path ðu; q; r; v Þ. We denote the resulting graph by H0 ¼ ðVðH0 Þ; EðH0 ÞÞ. Proposition 3. Let (13) be a valid inequality, H its support graph, and ðu; v Þ an edge of H. If auv > 0; bu 6 auv and bv 6 auv , then the following inequality is valid for S too:
X ði;jÞ2EðH0 Þ
a0ij zij þ
X i2VðHÞnfu;v g
bi yi 6 a;
ð17Þ
1110
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117
where a0uq ¼ bu ; a0qr ¼ auv ; a0rv ¼ bv and a0ij ¼ aij for ði; jÞ 2 EðH0 Þ n fðu; qÞ; ðq; rÞ; ðr; v Þg. 0
Proof. Let ðy; zÞ be any solution in S. Let hðy; zÞ (respectively, h ðy; zÞ) stand for the value of the left-hand side of (13) (respectively, (17)) at ðy; zÞ. We have to examine the following three cases. 0
1. yq ¼ yr ¼ 0. Then h ðy; zÞ ¼ hðy; zÞ auv maxðyu ; yv Þ 6 a since auv > 0. 0 2. yq ¼ yr ¼ 1. Then h ðy; zÞ ¼ hðy; zÞ þ d, where d ¼ auv ð1 maxðyu ; yv ÞÞ þ bu ð1 yu Þ þ bv ð1 yv Þ. Conditions auv > 0; bu 6 0 auv and bv 6 auv imply that d 6 0 for all binary values of yu and yv . Consequently, h ðy; zÞ 6 a. 0 0 3. yq ¼ 0; yr ¼ 1 (the case of yq ¼ 1; yr ¼ 0 is symmetric). Now h ðy; zÞ ¼ hðy; zÞ þ d , where d0 ¼ auv ð1 maxðyu ; yv ÞÞþ 0 bv ð1 yv Þ. Clearly, d0 ¼ 0 if yv ¼ 1, and d0 6 auv þ bv 6 0 if yv ¼ 0. Hence, again h ðy; zÞ 6 a. h As one can see from the statement of the proposition, edge splitting basically amounts to substitution of two y variables by two z variables. As an example, consider the clique inequality for k ¼ 4 (see (10)):
z1;2 þ z1;3 þ z1;4 þ z2;3 þ z2;4 þ z3;4 y1 y2 y3 y4 6 3:
ð18Þ
Splitting the edge ð1; 2Þ gives the valid inequality z5;6 z1;5 z2;6 þ z1;3 þ z1;4 þ z2;3 þ z2;4 þ z3;4 y3 y4 6 3. Before leaving this section, we remark that adding Eq. (7) to a valid inequality also can be viewed as an operation on the support graph H. Indeed, it replaces an edge of H with another edge. For example, if we add (7) to (18) twice (removing edges (1, 2) and (3, 4)), then we get the valid inequality
z1þn;2þn þ z1;3 þ z1;4 þ z2;3 þ z2;4 þ z3þn;4þn 6 5:
ð19Þ 0
3 _ The inequality (19) implies that the corresponding set of binary clauses F ¼ f x1 _ x2 ; x1 _ x3 ; x1 _ x4 ; x2 _ x3 ; x2 _ x4 ; x x4 g is inconsistent. This amounts to say that the number of satisfied clauses in any formula F containing this set cannot be greater than m 1. Therefore, upon identification of a set of clauses like F 0 , an upper bound on the optimal solution value for the Max-2-SAT instance defined by F can be reduced by one. The inequality (19) can be generalized to the case of cliques of size larger than four. With increasing clique size, the number of unsatisfied clauses in the corresponding set (similar to F 0 ) increases too. In the case of the 6-vertex clique, for example, this number is already equal to 2 (only at most 13 clauses out of 15 can be satisfied). 3. An upper bound The purpose of this section is to present an upper bound computation algorithm which is used within a branch-andbound framework for solving the Max-2-SAT problem. The rationale behind the algorithm is to iteratively simplify the objective function f ðy; zÞ by adding suitably selected non-negative functions to it. Let OPTðf Þ denote the maximum number of satisfied clauses for the Max-2-SAT instance defined by the function f. The following fact is obvious. Proposition 4. Let gðy; zÞ P 0 be an inequality (or gðy; zÞ ¼ 0 be an equation) that is valid for all ðy; zÞ 2 S. Then OPTðf Þ 6 OPTðf þ gÞ. Our algorithm proceeds in an iterative manner by choosing appropriate inequalities and equations and adding the lefthand sides of them to the objective function of the problem. Throughout this process, the constant term of the objective function increases while the number of variables decreases. At the end, the upper bound is computed by summing up the additive constant and the weights attached to the variables left, if any. In the algorithm, we use Eqs. (5), (7), (8) and inequalities (12). We denote by Ws ðFÞ; s 2 f3; 5; 7; . . .g, the set of s-vertex cycles in GðFÞ with exactly ðs 1Þ=2 red edges. Similarly, we use Hs ðFÞ ¼ fði1 ; i2 ; i2 þ n; i3 ; i3 þn; . . . ; iðsþ3Þ=2 Þg; s 2 f1; 3; 5; . . .g, to denote the set of s-edge chains in GðFÞ having the following two properties: (1) exactly ðs 1Þ=2 of the edges are red; P and (2) there are loops at the vertices i1 þ n and iðsþ3Þ=2 þ n. We define gðcÞ ¼ ðs 1Þ=2 þ yuðcÞ ði;jÞ2E ðcÞ zij for c 2 Ws ðFÞ, P P and gðPÞ ¼ 1 yaðPÞ ybðPÞ þ ðq;rÞ2E0 ðPÞ zqr ðj;kÞ2E ðPÞ zjk for P ¼ ði1 ; i2 ; i2 þ n; i3 ; i3 þ n; . . . ; iðsþ3Þ=2 Þ 2 Hs ðFÞ, where aðPÞ ¼ i1 þ n; bðPÞ ¼ iðsþ3Þ=2 þ n; E ðPÞ is the set of green edges of P and E0 ðPÞ ¼ fðj þ n; k þ nÞjðj; kÞ 2 E ðPÞg. It is easy to see that gðcÞ P 0 is equivalent to (12), gðPÞ ¼ 0 for P ¼ ði þ n; j þ nÞ 2 H1 ðFÞ is equivalent to (7), and gðPÞ ¼ 0 for P ¼ ði1 þ n; i2 ; i2 þ n; i3 ; i3 þ n; . . . ; is Þ 2 H2s3 ðFÞ is equivalent to (8). The function related to (5) is g i ¼ w0i ð1 yi yiþn Þ, where w0i ¼ minðwi ; wiþn Þ; i 2 f1; . . . ; ng. For i 2 VðFÞ, let NðiÞ ¼ fj 2 VðFÞjði; jÞ 2 Pg be the set of vertices connected to i by green P edges. We define the weighted degree of a vertex i as the sum di ¼ wi þ j2NðiÞ wij (here and in the rest of the paper we assume that wij and wji refer to the same quantity – the weight of the edge ði; jÞ). To simplify the formula F as well as the objective function f ðy; zÞ, we also use four known rules, which we denote here by R1 ; . . . ; R4 . We employ a function Q ðRi ; jÞ ! fTRUE; FALSEg defined over pairs ðRi ; jÞ; i 2 f1; 2; 3g; j 2 VðFÞ : Q ðR1 ; jÞ ¼ TRUE if and only if wj > 0; wjþn > 0; Q ðR2 ; jÞ ¼ TRUE if and only if dj > 0; djþn ¼ 0; Q ðR3 ; jÞ ¼ TRUE if and only if wj P djþn > 0. We implemented the rules R1 ; . . . ; R4 as procedures PR1 ; . . . ; PR4 , respectively. The procedure PR1 , when applied to j 2 VðFÞ, first adds g j to f ðy; zÞ. Next, it checks whether Q ðRi ; kÞ ¼ TRUE for some i 2 f2; 3g; k 2 fj; j þ ng and, if so, then applies PRi to k. At the end, PR1 makes a call to PR4 . The procedure PR2 , when invoked on j 2 VðFÞ, saves NðjÞ as N 0 and sets the variables yj and zkj ; k 2 NðjÞ, to 1 in f ðy; zÞ. Then, like PR1 , it tries to apply PRi ; i ¼ 1; 2; 3, to the vertices in N ðjÞ :¼ N 0 [ fk þ njk 2 N 0 g. The procedure PR3 is an extension of PR2 . In addition to the same operations as performed by PR2 , it also sets the variable yjþn to 0 in
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117
1111
f ðy; zÞ and turns each binary clause containing xj (or xjn if j > n) into a unit clause, thereby increasing wk by wk;jþn and eliminating zk;jþn from f ðy; zÞ for each k 2 Nðj þ nÞ. In the case of PR3 , the values of Q ðRi ; kÞ; i ¼ 1; 2; 3, are checked for each vertex in N ðjÞ [ N ðj þ nÞ. The procedure PR4 runs through all vertices j in VðFÞ and checks whether f P Uðf Þ wj , where f is the value of the best solution found throughout the search process and Uðf Þ is the value of f ðy; zÞ obtained by setting all unassigned variables to 1 (in other words, by taking the sum of the constant term of f ðy; zÞ and the number of clauses in the current formula F). If the above condition is met for j 2 VðFÞ, then the variable xj (or xjn if j > n) and its negation are eliminated from F by applying procedure PR3 . The rules R1 ; . . . ; R4 are well known in the literature. Specifically, R1 is known as complementary unit clause rule (Rule 2 in [22]), R2 as pure literal rule [33], and R3 as dominating unit-clause rule [33]. The analogue of R4 for the problem of minimizing the number of unsatisfied clauses is called in [33] an upper bound rule. Now we are ready to present a detailed description of our algorithm for computing an upper bound on OPTðf Þ. The input to the algorithm includes parameters scycle and schain , which help to limit the length of cycles and, respectively, chains used to modify the function f. The computation of the bound can be terminated prematurely when Uðf Þ becomes not larger than f . The algorithm, named UB (upper bound), goes as follows: UBðf Þ 1. Set s :¼ 5. 2. Select a cycle c 2 Ws ðFÞ such that wuðcÞþn > 0. If no such cycle exists, then go to 3. Otherwise, perform the following operations. Add gðcÞ þ g uðcÞ to f ðy; zÞ (and update GðFÞ accordingly by removing from GðFÞ all green edges of c as well as a loop incident to uðcÞ þ n). Set V 0 :¼ VðcÞ [ fuðcÞ þ ng. Check values of the function Q for the vertices in V 0 and, in the cases where Q ðRi ; jÞ ¼ TRUE for i 2 f1; 2; 3g; j 2 V 0 , apply PRi to j. Execute procedure PR4 . If f P Uðf Þ, then return with the bound Uðf Þ. Otherwise, repeat this step. 3. Select from Ws ðFÞ cycles c and c0 sharing no green edge and such that uðcÞ ¼ uðc0 Þ þ n. If no such pair of cycles exists, then go to 4. Otherwise, add gðcÞ þ gðc0 Þ þ g uðcÞ to f ðy; zÞ, set V 0 :¼ VðcÞ [ Vðc0 Þ and continue as in 2. 4. If Ws ðFÞ is empty, then go to 5. Otherwise, select a cycle c 2 Ws ðFÞ, add gðcÞ or, if wuðcÞþn > 0; gðcÞ þ g uðcÞ to f ðy; zÞ and continue as in 2. 5. If H1 ðFÞ is empty, then go to 6. Otherwise, select an edge P ¼ ðj; kÞ 2 H1 ðFÞ, add gðPÞ to f ðy; zÞ, set V 0 :¼ fj; k; j þ n; k þ ng and continue as in 2. 6. Increase s by 2. If s 6 scycle , then go to 2. Otherwise, set s :¼ 3 and proceed to 7. 7. If Hs ðFÞ is empty, then go to 8. Otherwise, select a chain P ¼ ðVðPÞ; EðPÞÞ 2 Hs ðFÞ, add gðPÞ to f ðy; zÞ, set V 0 :¼ VðPÞ [ fj þ n; k þ ng, where j and k are the endpoints of P, and continue as in 2. 8. Increase s by 2. If s 6 schain , then go to 7. Otherwise return with the bound Uðf Þ. The described algorithm computes the upper bound on the maximum number of satisfied clauses in a formula F whose corresponding graph GðFÞ does not contain triangles with two green and one red edges. This is not restrictive because all such triangles are eliminated from GðFÞ at the initialization stage of the branch-and-bound algorithm. Once emptied, the set W3 ðFÞ remains empty till the termination of the algorithm. We also notice that in the description of UB no specific rules to choose one or two cycles or a chain are given. In our implementation of UB, we used the simplest possible strategy – selection of an arbitrary cycle (or chain). Certainly, other strategies could also be adopted. x2 ; x1 _ x6 ; x1 _ x4 ; x1 _ x7 ; x2 _ x3 ; Example. Consider the CNF formula F given by the set of clauses fx1 _ x6 ; x3 _ x4 ; x3 _ x5 ; x3 _ x7 ; x3 _ x8 ; x3 _ x4 ; x3 _ x8 ; x4 _ x7 ; x4 _ x7 ; x4 _ x8 ; x5 _ x6 ; x5 _ x7 ; x5 _ x8 ; x5 ; x6 _ x7 g. The binary x2 _ clauses of F are represented by the vector ðzij jði; jÞ 2 PÞ in (1). Clearly, all the coefficients wij in (1) are equal to 1. The function x5 . We will apply UB to the Max-2-SAT instance defined f ðy; zÞ also contains the variable y5þ8 corresponding to the unit clause by F assuming that f ¼ 0. We will write f0 for the constant term of the function f ðy; zÞ. Initially, f0 ¼ 0; Uðf Þ ¼ 20. In Step 2, UB selects the cycle (5,6+8,6,7,7+8,5) and adds the left-hand sides of the valid inequalities y5 z5;6þ8 z6;7 z5;7þ8 þ 2 P 0 and 1 y5 y5þ8 P 0 to f ðy; zÞ. This gives f0 ¼ 3 and Uðf Þ ¼ 19. Next, the algorithm selects cycles (3,4+8,4,7+8,7,3) and (3+8,4,4+8,8,8+8,3+8). The number of variables is further reduced by adding y3 z3;4þ8 z4;7þ8 z3;7 þ 2; y3þ8 z3þ8;4 z4þ8;8 z3þ8;8þ8 þ 2 and 1 y3 y3þ8 to f ðy; zÞ. Thus, at the end of Step 3, f0 ¼ 8 and Uðf Þ ¼ 18. Step 4 of UB is executed twice. At the first time, the cycle (1+8,4,4+8,7,7+8,1+8) is selected and y1þ8 z1þ8;4 z4þ8;7 z1þ8;7þ8 þ 2 is added to f ðy; zÞ. The formula corresponding to the resulting function f does not contain variables x4 ; x7 and their negations. Now f0 ¼ 10, while Uðf Þ remains the same as before. During the second execution of Step 4, the cycle (3, 5 + 8, 5, 8 + 8, 8, 3) is selected. Adding y3 z3;5þ8 z5;8þ8 z3;8 þ 2 to f ðy; zÞ increases f0 by 2. Since Q ðR3 ; 3Þ ¼ TRUE, UB applies procedure PR3 which sets y3 to 1 x3 into unit clause x2 (by substituting z2;3þ8 with y2 in f ðy; zÞ). At the end of Step 4, and turns the binary clause x2 _ f ðy; zÞ ¼ 13 þ z1;2þ8 þ z1;6 þ z2þ8;6þ8 þ y1þ8 þ y2 . In Step 5, the edge P ¼ ð1; 2 þ 8Þ 2 H1 ðFÞ is selected. Then both y variables are eliminated by adding gðPÞ ¼ 1 y1þ8 y2 þ z1þ8;2 z1;2þ8 (¼ 0 due to (7)) to f ðy; zÞ. This operation gives f ðy; zÞ ¼ 14 þ z1þ8;2 þ z1;6 þ z2þ8;6þ8 . Since the sets Ws ðFÞ; s 2 f3; 5; 7; . . .g, and Hr ðFÞ; r 2 f1; 3; 5; . . .g, for the residual formula x2 _ x6 g are empty, UB stops with the upper bound Uðf Þ ¼ 17. It can be easily checked that the truth F ¼ f x1 _ x2 ; x1 _ x6 ; assignment x1 ¼ . . . ¼ x5 ¼ FALSE;x6 ¼ TRUE;x7 ¼ FALSE;x8 ¼ TRUE satisfies 17 clauses of the initial formula F (unsatisfied x6 and x5 _ x8 ). Therefore, this assignment is optimal, and the bound delivered by UB for the considclauses are x3 _ x7 ; x5 _ ered Max-2-SAT instance is tight.
1112
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117
4. A branch-and-bound algorithm The algorithm we describe in this section starts with the application of a heuristic to obtain a good initial solution and then generates a sequence of partial assignments of 0–1 values to the variables until the currently best solution is proved to be optimal. This process defines a binary search tree with nodes representing partial assignments. Several steps of the developed branch-and-bound algorithm use variations of the procedures PRi ; i ¼ 1; . . . ; 4, described in Section 3. Basically, these variations may differ from PRi ; i ¼ 1; . . . ; 4, used in UB only in implementation details. To present the algorithm, we adopt notations from the previous section. For a triangle t 2 W3 ðFÞ, we will write gðtÞ ¼ 1þ P yuðtÞ ði;jÞ2E ðtÞ zij , where E ðtÞ stands for the pair of green edges of t and uðtÞ is the common endpoint of these two edges. We denote by VðtÞ the vertex set of t. In order to obtain a solution to (1)–(5) it is sufficient to assign a value to each variable yi ; i ¼ 1; . . . ; n, only. All other variables are expressed through them: yiþn ¼ 1 yi ; i ¼ 1; . . . ; n, according to (5), and zij ¼ minð1; yi þ yj Þ; ði; jÞ 2 U, according to (2) and (3). Using these expressions, we can eliminate zij ; ði; jÞ 2 P, and yiþn , i ¼ 1; . . . ; n, from the right-hand side of (1). We denote the value of the resulting function at a 0–1 vector y ¼ ðy1 ; . . . ; yn Þ by f ðyÞ. The algorithm, named B&B (branch-and-bound), can be described as follows: B&B 1. Apply a heuristic algorithm to a given instance of the Max-2-SAT problem. Let y ¼ ðy1 ; . . . ; yn Þ be the solution produced by this algorithm. Set f :¼ f ðy Þ. If f ¼ m, then go to 9. 2. Execute procedures PR1 ; PR2 ; PR3 in the cases where Q ðRi ; jÞ ¼ TRUE;i 2 f1; 2; 3g; j 2 VðFÞ. Invoke procedure PR4 . Process the triangles in three passes: in the first pass, process t 2 W3 ðFÞ such that wuðtÞþn > 0; in the second pass – pairs of triangles t; t 0 2 W3 ðFÞ sharing no green edge and such that uðtÞ ¼ uðt 0 Þ þ n; in the third pass – all the remaining triangles t 2 W3 ðFÞ. For each t 2 W3 ðFÞ, perform the following operations: (a) add gðtÞ to f ðy; zÞ; (b) if t is selected either in the first pass or, as the second triangle of a pair, in the second pass, then add also g uðtÞ to f ðy; zÞ and make a call to PR4 ; (c) check values of the function Q for the vertices in V 0 :¼ VðtÞ [ fuðtÞ þ ng and, in the cases where Q ðRi ; jÞ ¼ TRUE for i 2 f1; 2; 3g; j 2 V 0 , apply PRi to j. 3. If H1 ðFÞ is empty, then go to 4. Otherwise, select an edge P ¼ ðj; kÞ 2 H1 ðFÞ. Add gðPÞ to f ðy; zÞ. Make a call to PR4 . Invoke procedures PRi ; i ¼ 1; 2; 3, whenever they are applicable (for vertices in fj; k; j þ n; k þ ng) and repeat this step. 4. Perform similar operations as in 3 for Hs ðFÞ; s ¼ 3; 5; . . . ; schain . 5. If all the variables y1 ; . . . ; yn have values assigned, then compare this solution with y , update y and f if the new solution is better, and go to 7. Otherwise, make a copy of the current function f ðy; zÞ and apply UB(f ) to (1)–(5) with this copy in the role of the objective function. If the bound returned by UB is greater than f , then proceed to 6; else go to 7. 6. Select a variable yk ; k 2 f1; . . . ; ng, whose value is not yet determined. Set r :¼ k; l :¼ 0 and go to 8. 7. Backtrack to the last non-fathomed node on the path from the root to the current node of the search tree (a node is said to be fathomed if the optimal value of the related subproblem was proved to be less than or equal to f ). If such a node is found, then set r :¼ p, where p is the index of the y variable that was selected for branching at that node, set l :¼ 1 and go to 8. Otherwise go to 9. 8. Set yr :¼ l. Depending on whether l ¼ 0 or l ¼ 1, apply PR3 to r þ n or r, respectively. Make a call to PR4 and return to 3. 9. Stop with the optimal solution x ¼ ðx1 ; . . . ; xn Þ, where xi ¼ TRUE;i 2 f1; . . . ; ng, if yi ¼ 1, and xi ¼ FALSE otherwise. The number of satisfied clauses is equal to f . As can be seen from the above description, the algorithm starts with two initialization steps. In Step 1 of the algorithm, we have chosen to use an iterated tabu search method as a heuristic for getting an initial solution to Max-2-SAT. We defer the description of this method to the next section. Step 2 performs preliminary simplification of the formula F as well as f ðy; zÞ according to a number of rules. Processing of triangles, in particular, is based on the valid Eq. (6). Further simplification of F is 0 0 performed in Steps 3 and 4. In Step 6, we select a variable for which the product ðwk þ 4dk Þðwkþn þ 4dkþn Þ is largest, where 0 di ¼ di wi ; i 2 fk; k þ ng. We have found that such a criterion is quite suitable by conducting some preliminary tests of the algorithm. In Step 7, the algorithm backtracks up the tree to the node whose branch corresponding to the value l ¼ 1 has not been explored. During backtracking, all reductions of F performed in Steps 3, 4 and 8 while moving from the found non-fathomed node to the current one are undone in reversed order. Thus the function f ðy; zÞ is restored to be the same as it was before fixing yp at 0 in Step 8. We now discuss some aspects of efficient implementation of our branch-and-bound algorithm. First of all, note that it is useful to compare f with Uðf Þ each time the value of Uðf Þ decreases, which may happen in Steps 2–4 and 8. If f P Uðf Þ, then the algorithm can prune the subtree rooted at the current node and backtrack. Another improvement is to use procedure PR4 only in the cases where f P Uðf Þ maxi2K wi . Computational experiments with B&B showed that a significant amount of time was being spent searching for cycles in GðFÞ. A simple strategy to shorten this time is to retain all the cycles selected by UB in memory for each active (non-fathomed) node of the search tree. When applying UB to a son of the active node, these cycles are reused. The procedure UB is modified to handle predefined cycles with priority. However, to produce a
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117
1113
tighter bound, UB should also process additional cycles (provided the union of sets Ws ðFÞ; s ¼ 5; 7; . . . ; scycle , is still nonempty). Fortunately, the number of selected additional cycles typically is very small. Therefore, it is reasonable to expect the branch-and-bound algorithm B&B with modified UB to be superior to the basic B&B version, at least for some classes of Max-2-SAT instances. 5. Iterated tabu search In this section, we briefly describe an implementation of the tabu search method for the Max-2-SAT problem. We preferred to use this method because of its simplicity as well as its ability to find good quality solutions in a short amount of time. It is obvious that the power of the bounding test, and thus computation time, depends on the value of the best solution found throughout the search process. Therefore, it is important to produce a high quality solution early on in the search, best of all, at the root node of the search tree (Step 1 of B&B). For this reason, we decided to develop an iterated tabu search (ITS) algorithm for Max-2-SAT and use it in the initialization step of the branch-and-bound method. Implementations of ITS have shown good performance for other optimization problems with 0–1 variables – the unconstrained binary quadratic optimization problem [24] and the maximum diversity problem [25]. The ITS algorithm alternates between two phases: solution perturbation and tabu search. The presence of the perturbation phase makes the tabu search technique much smarter. In the description of ITS given below, AðyÞ and BðyÞ are n-vectors P P ~j Þ and Bi ðyÞ ¼ wiþn þ j2NðiþnÞ wiþn;j ð1 y ~j Þ; i ¼ 1; . . . ; n, respectively, where with components Ai ðyÞ ¼ wi þ j2NðiÞ wij ð1 y ~j ¼ 1 yjn if j > n, and y is a 0–1 n-vector. Using AðyÞ and BðyÞ, we compute ~j ¼ yj if j 6 n; y y Di ðyÞ; i ¼ 1; . . . ; n : Di ðyÞ ¼ Ai ðyÞ Bi ðyÞ if yi ¼ 0, and Di ðyÞ ¼ Bi ðyÞ Ai ðyÞ if yi ¼ 1. For the 0–1 vector y0 obtained from y by flipping the value of yi (from 0 to 1 or vice versa), we can write f ðy0 Þ ¼ f ðyÞ þ Di ðyÞ. Thus Di ðyÞ gives the increase in the total number of satisfied clauses achieved by setting yi :¼ 1 yi . The algorithm selects a variable to flip from the set fyi ji 2 I0 ðyÞ [ I1 ðyÞg, where I0 ðyÞ ¼ fijyi ¼ 0 and Ai ðyÞ > 0g; I1 ðyÞ ¼ fijyi ¼ 1 and Bi ðyÞ > 0g. Evidently, i 2 I0 ðyÞ means that the Boolean variable xi belongs to at least one clause that is unsatisfied by the truth assignment xj ¼ TRUE;j 2 f1; . . . ; ng, if yj ¼ 1, and xj ¼ FALSE if yj ¼ 0. If i 2 I1 ðyÞ, then the analogous statement is valid for the negation of xi . A formal description are parameters to be discussed below). of the algorithm is given as follows (s and n ITS 1. Randomly generate a 0–1 vector y ¼ ðy1 ; . . . ; yn Þ. Set y :¼ y. Compute vectors AðyÞ ¼ ðA1 ðyÞ; . . . ; An ðyÞÞ and BðyÞ ¼ ðB1 ðyÞ; . . . ; Bn ðyÞÞ. 2. Execute the tabu search procedure TSðy; y Þ. 3. Check if some of the stopping criteria is met. If so, then stop with the solution y of value f ðy Þ. In particular, always stop if f ðy Þ ¼ m. In this case, the truth assignment corresponding to y satisfies all the clauses of the formula F (and thus is provably optimal). If not, then set p :¼ 0, ~I :¼ ; and proceed to 4. 4. If I :¼ ðI0 ðyÞ [ I1 ðyÞÞ n eI is empty, then go to 2. Otherwise, form a set I0 of s0 ¼ minðs; jI jÞ indices i 2 I such that Di ðyÞ P Dj ðyÞ for each i 2 I0 and each j 2 I n I0 (in other words, pick the s0 largest values Di ðyÞ among those with i 2 I ). , then return 5. Randomly select k 2 I0 . Add k to eI. Flip the value of yk . Update vectors AðyÞ and BðyÞ. Increment p by 1. If p < n to 4. Otherwise go to 2. In the above description, y and y stand for the current and, respectively, best found solutions. Initially, both y and y are assigned a random 0–1 vector. Step 2 invokes the tabu search procedure TS. It returns updated y and possibly y . Step 3 requires stopping conditions to be specified. An obvious one is to stop immediately once all the clauses of F become satisfied. Another criterion is needed to halt the search in the cases where OPTðf Þ < m. It may be any, for example, an upper bound on the number of calls to TS or a stopping rule based on the CPU clock. In our experiments, we adopted the latter alternative. Steps 4 and 5 of ITS generate a new starting solution for tabu search. In the loop defined by these steps, the values of at most ¼ qn variables are flipped, where q is a tuning factor for controlling the degree of search diversification. The candidates for n flipping are selected in Step 4. Their number is bounded above by the parameter s whose value is chosen experimentally. As it can be understood from the description of the algorithm, the current best solution y is updated in Step 2 by calling the tabu search procedure TS. Our implementation of TS given below is based on the general guidelines given in [12]. TSðy; y Þ 1. Initialize c and T i ; i ¼ 1; . . . ; n, with 0. Compute ~f ¼ f ðyÞ. 2. Set D :¼ 1; k :¼ 1; q :¼ 0. 3. For i ¼ 1; . . . ; n such that T i ¼ 0 do 3.1. Increment c by 1. If i 2 I0 ðyÞ [ I1 ðyÞ, then proceed to 3.2. Otherwise, repeat 3 for the next i. 3.2. If ~f þ Di ðyÞ > f ðy Þ, then set k :¼ i; q :¼ 1 and go to 5. Otherwise, compare Di ðyÞ with D. If Di ðyÞ > D, then set D :¼ Di ðyÞ; k :¼ i; p :¼ 1. If Di ðyÞ ¼ D, then increment p by one and also set k :¼ i with probability 1=p. 4. If k > 0, then go to 5. Otherwise, form a subset I0 of I :¼ I0 ðyÞ [ I1 ðyÞ consisting of minðr; jI jÞ elements i 2 I for which T i is smallest. Select k 2 I0 at random.
1114
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117
5. Flip the value of yk . Update ~f ; AðyÞ and BðyÞ. If q ¼ 0, then go to 7. Otherwise go to 6. 6. Apply a local search procedure to y. Let y also denote the solution returned by it. Set y :¼ y; ~f :¼ f ðyÞ. , then return. Otherwise, decrement each positive 7. If c is greater than or equal to a predetermined upper limit c T i ; i 2 f1; . . . ; ng, by 1, set T k :¼ s and go to 2. and r . The parameter s is the tabu tenure. We have found The input to TS includes the following three parameters: s; c is the maximum number of iterations allowed. We take that a good choice is to take s ¼ minð20; n=4Þ. The parameter c c ¼ maxð5000; rnÞ, where r is a scaling factor used to control the execution time of TS. The parameter r restricts the cardinality of the set of variables considered as candidates for flipping. This set is built in Step 4, which is executed in the case where the tabu value T i is positive for each i 2 I0 ðyÞ [ I1 ðyÞ. The local search procedure used in Step 6 of TS is a straightforward 1-opt local improvement method. 6. Computational results The main purpose of experimentation was to show that the developed upper bounding procedure can be used to build a Max-2-SAT solver that would be very competitive with the best existing methods. The described branch-and-bound algorithm was coded in the C programming language and run on a Pentium M 1733 MHz notebook. As a testbed for investigating the algorithm, we considered Max-2-SAT instances from the collection of Max-SAT Evaluation 2007 benchmarks (available at http://www.maxsat07.udl.es/). Specifically, the algorithm was tested on the following sets of instances: MAX2SAT 60VARS ðn ¼ 60; m ¼ 200—1200Þ, MAX2SAT 100VARS ðn ¼ 100; m ¼ 200—1200Þ, MAX2SAT 140VARS ðn ¼ 140; m ¼ 200—1200Þ, SPINGLASS ððn; mÞ 2 fð64; 384Þ; ð125; 750ÞgÞ, MAXCUT RANDOM ðn ¼ 60; m ¼ 840—1200Þ, MAXCUT SPINGLASS ðn ¼ 27—125; m ¼ 162—750Þ, and a series of MAXCUT DIMACS sets ðn ¼ 28—64; m ¼ 48—1528Þ. The number of solved instances in each set is displayed in Table 5 given below (see the second column). We note that instances of the max-cut problem in the Max-SAT Evaluation 2007 collection are already converted xi _ xj (details into CNF format. The standard way to do this is to map each edge ði; jÞ of a graph to binary clauses xi _ xj and can be found, e.g., in [29]). For comparison purposes, we also ran the Max-SAT solver MaxSatz developed by Li et al. [22]. The empirical results presented in [22] show that MaxSatz is superior to other state-of-the-art Max-SAT solvers. For some classes of problem instances, MaxSatz is orders of magnitude faster than other methods (see, e.g., Table 2 in [22]). Moreover, MaxSatz was the best performing solver in the Max-SAT Evaluation 2007 (for the results, see http://www.maxsat07.udl.es/). We should notice that MaxSatz is designed to solve the general Max-SAT problem of which Max-2-SAT is a special case. Nevertheless, MaxSatz is able to outperform the existing algorithms specifically designed to deal with only binary and unit clauses. In fact, from the results in [21,22], one can find that MaxSatz is much faster than the algorithms of Alber et al. [1] and Shen and Zhang [29], which were developed for the Max-2-SAT case. Thus, a comparison with MaxSatz, using the same computer, is meaningful in evaluating the performance of our algorithm. Preliminary testing of the algorithm was conducted on several problem instances of smaller sizes. The obtained results helped us select the appropriate values of the algorithm’s parameters. We have set scycle ¼ schain ¼ 9. For tabu search, we used the following parameter settings: s ¼ 10; q ¼ 0:4; r ¼ 5 and r ¼ 1000. In the program implementing our algorithm, the first three values appear as some constants. The run time of ITS was limited to 0.05 s for all instances except for those in MAX2SAT 60VARS and MAXCUT DIMACS c-fat data sets, for which a maximum CPU time limit of 0.03 s per instance was imposed. The results of our computational experiments are summarized in Tables 1–5. Table 1 compares the performance of B&B and MaxSatz on the last 10 instances in the MAX2SAT 140VARS set (other instances have less clauses and are generally easier to solve). The second column of the table gives, for each instance, the number of satisfied clauses in an optimal truth assignment. The next three columns show the results of our algorithm: the upper bound on f ðy; zÞ computed at the initialization step, the CPU time in seconds, and the number of branchings performed. The last two columns provide the CPU time and the
Table 1 Performance on random instances ðn ¼ 140; m ¼ 1200Þ. Instance
OPT
sz140_1200_1 sz140_1200_2 sz140_1200_3 sz140_1200_4 sz140_1200_5 sz140_1200_6 sz140_1200_7 sz140_1200_8 sz140_1200_9 sz140_1200_10
1061 1048 1056 1053 1058 1046 1048 1053 1063 1054
B&B
MaxSatz
UB
Time
Branchings
Time
Branchings
1088 1086 1088 1082 1088 1084 1086 1085 1095 1085
7.1 127.7 33.1 14.6 14.0 250.6 129.8 42.6 14.0 28.4
8733 161,726 40,612 16,710 17,464 317,530 170,671 52,705 16,344 34,615
13.9 321.1 110.7 161.4 36.9 622.0 255.9 122.0 59.4 167.8
22,741 692,032 197,675 296,078 63,075 1,189,034 516,648 213,858 95,584 286,313
1115
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117 Table 2 Performance on the SPINGLASS instances ðn ¼ 125; m ¼ 750Þ. Instance
OPT
spinglass5_1 spinglass5_2 spinglass5_3 spinglass5_4 spinglass5_5 spinglass5_6 spinglass5_7 spinglass5_8 spinglass5_9 spinglass5_10
B&B
671 675 671 679 675 669 671 675 673 673
MaxSatz
UB
Time
Branchings
Time
Branchings
693 695 694 699 696 694 692 694 693 694
76.2 15.7 47.6 6.3 6.8 113.8 41.2 9.3 36.3 27.0
60,163 11,431 38,525 4143 4965 100,321 32,987 6729 27,811 21,293
276.6 45.3 196.0 22.5 56.5 417.3 145.2 50.0 124.5 123.0
818,560 114,705 555,888 52,326 149,065 1,249,269 416,787 130,036 324,764 337,257
Table 3 Performance on MAXCUT random instances ðn ¼ 60; m ¼ 1200Þ. Instance
OPT
max_cut_60_600_1 max_cut_60_600_2 max_cut_60_600_3 max_cut_60_600_4 max_cut_60_600_5 max_cut_60_600_6 max_cut_60_600_7 max_cut_60_600_8 max_cut_60_600_9 max_cut_60_600_10
978 984 985 987 979 984 983 979 982 981
B&B
MaxSatz
UB
Time
Branchings
Time
Branchings
1023 1021 1019 1024 1022 1026 1023 1022 1027 1022
21.2 3.7 3.3 2.7 15.6 6.8 8.8 13.6 6.5 5.9
33,404 5840 5479 4026 25,120 10,718 14,312 23,167 9991 8751
21.4 6.1 6.2 6.1 16.8 8.8 10.1 15.9 8.9 9.9
71,582 17,033 17,545 18,080 54,278 25,077 30,488 51,343 27,018 33,624
Table 4 Performance on the MAXCUT DIMACS instances. Instance
brock200_1 brock400_1 brock400_2 hamming10-4 johnson32-2-4 p_hat300-3 p_hat500-3 p_hat700-3 san200_0.7_1 san200_0.9_1 san200_0.9_2 san200_0.9_3 san400_0.7_1 san400_0.9_1 sanr200_0.9
n
40 40 40 41 42 43 42 42 40 40 40 40 40 40 40
m
1132 1192 1188 1436 1528 1270 1310 1260 1116 1392 1404 1420 1120 1356 1354
OPT
894 937 936 1117 1199 1001 1026 993 879 1079 1088 1100 884 1052 1054
B&B
MaxSatz
UB
Time
Branchings
Time
Branchings
967 1016 1014 1240 1302 1099 1113 1082 957 1189 1206 1217 956 1164 1159
16.5 33.8 22.5 376.0 76.2 24.5 73.7 19.2 24.2 497.5 557.0 555.8 17.5 479.4 176.7
62,590 125,549 78,584 1,516,158 225,827 92,966 278,974 58,872 97,538 2,200,824 2,414,171 2,388,588 64,733 2,140,096 709,082
22.7 45.8 37.4 563.9 141.2 35.5 102.4 47.2 42.0 691.7 860.4 860.8 23.2 641.2 279.3
139,861 297,624 216,595 3,777,202 625,848 189,867 606,274 255,022 293,774 5,654,770 6,834,217 6,939,954 155,301 5,151,203 2,024,977
number of branchings for MaxSatz. Tables 2 and 3 show the results obtained for the last 10 instances in the SPINGLASS and MAXCUT RANDOM benchmark sets, respectively. Their structure is the same as that of Table 1. The results for a selection of difficult instances from the MAXCUT DIMACS data collection are presented in Table 4. This table includes columns for the number of variables n and the number of clauses m in a problem instance. Table 5 gives a summary of the empirical results. It contains the values of the CPU time and the number of branchings averaged over each data set. The number of solved instances in each set is shown in the column headed by N. By inspection of Tables 1–5, it can be seen that B&B performs better than MaxSatz. The superiority of B&B over MaxSatz is more pronounced for random and spinglass instances. Actually, the ratio (MaxSatz Time)/(B&B Time) exceeds 3 for MAX2SAT 140VARS and SPINGLASS data sets and is even larger for MAXCUT SPINGLASS data set (see Table 5). For random max-cut and DIMACS instances, this ratio is about 1.2 and 1.5, respectively. We can also see from the tables that B&B builds smaller search
1116
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117
Table 5 Average results on the Max-SAT Evaluation 2007 benchmarks. Set name
MAX2SAT 60VARS MAX2SAT 100VARS MAX2SAT 140VARS SPINGLASS MAXCUT RANDOM MAXCUT DIMACS brock MAXCUT DIMACS c-fat MAXCUT DIMACS hamming MAXCUT DIMACS johnson MAXCUT DIMACS keller MAXCUT DIMACS p_hat MAXCUT DIMACS san MAXCUT DIMACS sanr MAXCUT SPINGLASS
N
110 110 110 20 40 12 5 3 3 2 12 11 4 3
B&B
MaxSatz
Time
Branchings
Time
Branchings
<0.1 1.0 10.1 19.1 4.8 9.9 0.1 125.4 25.5 2.3 10.5 197.4 47.0 9.0
58 1694 12,918 15,556 7680 36,340 687 505,525 75,410 6397 38,344 859,351 187,863 6958
<0.1 1.9 32.0 73.0 5.9 14.0 0.1 188.4 47.3 6.5 16.6 287.7 74.9 47.2
183 5269 66,238 208,312 19,552 83,317 2378 1,259,878 209,426 24,227 93,636 2,300,728 533,815 132,914
trees than MaxSatz. The reduction in the size of the tree varies from 2.3 (for MAXCUT DIMACS brock) to 19.1 (for MAXCUT SPINGLASS) times. This improvement is achieved through the use of a better bounding mechanism. The relative gap between the optimum and the upper bound, L ¼ 100ðUB OPTÞ=OPT, at the initialization step of B&B is, on the average, less than 4% for all non-DIMACS data sets as well as MAXCUT DIMACS c-fat instances. For the remaining DIMACS data sets, the gap L is in the range 4.3–8.4%. Using UB, we were able to solve 19 instances without branching: 2 instances from MAX2SAT 60VARS ðm ¼ 200Þ, four instances from MAX2SAT 100VARS ðm ¼ 200Þ, 11 instances from MAX2SAT 140VARS (m ¼ 200 and 300), and two instances from MAXCUT DIMACS c-fat data set. In closing this section, it is worth mentioning that the experiments showed the good performance of the ITS algorithm. Optimal solutions were found for all tested problem instances. Hence, the goal of the branching and bounding process was just to prove their optimality. The average time taken by ITS to find an optimal truth assignment did not exceed 0.005 s for all data sets and therefore was an order of magnitude less than the time limit enforced. 7. Concluding remarks In this paper we have developed a branch-and-bound algorithm for the Max-2-SAT problem. The algorithm uses an upper bound which is reasonably tight – for various classes of tested instances, it is about 2–8% from the optimum at the root of the search tree. Moreover, the bound is very cheap to compute. When incorporated in the branch-and-bound framework, it allows to reduce the size of the search tree significantly. The proposed branch-and-bound algorithm is very competitive with existing state-of-the-art algorithms for Max-SAT. It shows very good performance when compared with MaxSatz, which was the best performing solver in the Max-SAT Evaluation 2007. It should be noted, however, that our algorithm does not dominate MaxSatz because the latter can also solve problem instances containing clauses of size 3 and larger. A possible direction of further work is to investigate the usage of additional classes of valid inequalities as well as to devise special rules for their selection during the bound computation. It is an important challenge to invent improved upper bounding mechanisms which would yield tighter bounds than those used in our algorithm and, at the same time, would be very fast. References [1] J. Alber, J. Gramm, R. Niedermeier, Faster exact algorithms for hard problems: a parameterized point of view, Discrete Math. 229 (2001) 3–27. [2] T. Alsinet, F. Manyà, J. Planes, An efficient solver for weighted Max-SAT, J. Global Optim. 41 (2008) 61–73. [3] N. Bansal, V. Raman, Upper bounds for MaxSat: further improved, in: The 10th International Symposium on Algorithms and Computation (ISAAC’99), Chennai, India, December 16–18, 1999, Lect. Notes Comput. Sci., vol. 1741, 1999, pp. 247–258. [4] R. Battiti, P. Campigotto, Reactive search for MAX-SAT: diversification-bias properties with prohibitions and penalties, Technical Report DIT-07-058, Informatica e Telecomunicazioni, University of Trento, Trento, Italy, 2007. [5] B. Borchers, J. Furman, A two-phase exact algorithm for MAX-SAT and weighted MAX-SAT problems, J. Comb. Optim. 2 (1999) 299–306. [6] J. Cheriyan, W.H. Cunningham, L. Tunçel, Y. Wang, A linear programming and rounding approach to Max-2-SAT, in: D.S. Johnson, M.A. Trick (Eds.), Cliques, Coloring, and Satisfiability, DIMACS Series in Discrete Mathematics and Theoretical Computer Science, vol. 26, Amer. Math. Soc., Providence, RI, USA, 1996, pp. 395–414. [7] S. de Givry, J. Larrosa, P. Meseguer, T. Schiex, Solving Max-SAT as weighted CSP, in: The Nineth International Conference on Principles and Practice of Constraint Programming, Kinsale, Ireland, September 29 to October 3, 2003, Lect. Notes Comput. Sci., vol. 2833, 2003, pp. 363–376. [8] E. de Klerk, J.P. Warners, Semidefinite programming approaches for MAX-2-SAT and MAX-3-SAT: computational perspectives, in: P.M. Pardalos, A. Migdalas, R.E. Burkard (Eds.), Combinatorial and Global Optimization, World Scientific, River Edge, NJ, USA, 2002, pp. 161–176. [9] G. Di Battista, T. Erlebach, A. Hall, M. Patrignani, M. Pizzonia, T. Schank, Computing the types of the relationships between autonomous systems, IEEE/ ACM Trans. Network. 15 (2007) 267–280. [10] X. Dimitropoulos, D. Krioukov, M. Fomenkov, B. Huffaker, Y. Hyun, K.C. Claffy, G. Riley, AS relationships: inference and validation, ACM SIGCOMM Comput. Commun. Rev. 37 (2007) 29–40. [11] X. Dimitropoulos, D. Krioukov, B. Huffaker, K.C. Claffy, G. Riley, Inferring AS relationships: dead end or lively beginning? in: The Fourth International Workshop on Efficient and Experimental Algorithms (WEA’05), May 2005, Lect. Notes Comput. Sci., vol. 3503, 2005, pp. 113–125.
G. Palubeckis / Applied Mathematics and Computation 215 (2009) 1106–1117
1117
[12] F. Glover, Tabu search – part I, ORSA J. Comput. 1 (1989) 190–206. [13] M.X. Goemans, D.P. Williamson, Improved approximation algorithms for maximum cut and satisfiability problems using semidefinite programming, J. ACM 42 (1995) 1115–1145. [14] C.P. Gomes, W.-J. van Hoeve, L. Leahu, The power of semidefinite programming relaxations for MAX-SAT, in: The Third International Conference on Integration of AI and OR Techniques in Constraint Programming for Combinatorial Optimization Problems (CPAIOR 2006), Cork, Ireland, May 31 to June 2, 2006, Lect. Notes Comput. Sci., vol. 3990, 2006, pp. 104–118. [15] F. Heras, J. Larrosa, New inference rules for efficient Max-SAT solving, in: Proceedings of the 21st National Conference on Artificial Intelligence, Boston, MA, July 16–20, 2006, AAAI Press, Menlo Park, CA, 2006, pp. 68–73. [16] A. Ishtaiwi, J. Thornton, A. Sattar, Weight redistribution for unweighted MAX-SAT, in: The 20th Australian Joint Conference on Artificial Intelligence, Gold Coast, Australia, December 2–6, 2007, Lect. Notes Comput. Sci., vol. 4830, 2007, pp. 687–693. [17] S. Joy, J.E. Mitchell, B. Borchers, Solving MAX-SAT and weighted MAX-SAT problems using branch-and-cut, Technical Report, Mathematical Sciences, Rensselaer Polytechnic Institute, Troy, NY 12180, 1998. [18] R. Kastner, E. Bozorgzadeh, M. Sarrafzadeh, Pattern routing: use and theory for increasing predictability and avoiding coupling, IEEE Trans. Comput.Aided Des. Integr. Circuits Syst. 21 (2002) 777–790. [19] J. Larrosa, F. Heras, Resolution in Max-SAT and its relation to local consistency in weighted CSPs, in: Proceedings of the 19th International Joint Conference on Artificial Intelligence (IJCAI-05), Edinburgh, Scotland, July 30 to August 5, 2005, pp. 193–198. [20] M. Lewin, D. Livnat, U. Zwick, Improved rounding techniques for the MAX 2-SAT and MAX DI-CUT problems, in: The Nineth International IPCO Conference on Integer Programming and Combinatorial Optimization, Cambridge, Massachusetts, May 27–29, 2002, Lect. Notes Comput. Sci., vol. 2337, 2002, pp. 67–82. [21] C.M. Li, F. Manyà, J. Planes, Detecting disjoint inconsistent subformulas for computing lower bounds for Max-SAT, in: Proceedings of the 21st National Conference on Artificial Intelligence, Boston, MA, July 16–20, 2006, AAAI Press, Menlo Park, CA, 2006, pp. 86–91. [22] C.M. Li, F. Manyà, J. Planes, New inference rules for Max-SAT, J. Artif. Intell. Res. 30 (2007) 321–359. [23] R. Miyashiro, T. Matsui, Semidefinite programming based approaches to the break minimization problem, Comput. Oper. Res. 33 (2006) 1975–1982. [24] G. Palubeckis, Iterated tabu search for the unconstrained binary quadratic optimization problem, Informatica 17 (2006) 279–296. [25] G. Palubeckis, Iterated tabu search for the maximum diversity problem, Appl. Math. Comput. 189 (2007) 371–383. [26] G. Palubeckis, On the recursive largest first algorithm for graph colouring, Int. J. Comput. Math. 85 (2008) 191–200. [27] G. Palubeckis, On the graph coloring polytope, Inf. Technol. Control 37 (2008) 7–11. [28] K. Pipatsrisawat, A. Darwiche, Clone: solving weighted Max-SAT in a reduced search space, in: The 20th Australian Joint Conference on Artificial Intelligence, Gold Coast, Australia, December 2–6, 2007, Lect. Notes Comput. Sci., vol. 4830, 2007, pp. 223–233. [29] H. Shen, H. Zhang, Improving exact algorithms for MAX-2-SAT, Ann. Math. Artif. Intel. 44 (2005) 419–436. [30] R. Straub, H. Prautzsch, Creating optimized cut-out sheets for paper models from meshes, Paper presented at the Nineth SIAM Conference on Geometric Design and Computing, Phoenix, AZ, USA, October 30 to November 3, 2005,
. [31] T. Stützle, H. Hoos, A. Roli, A review of the literature on local search algorithms for MAX-SAT, Technical Report AIDA-01-02, Darmstadt University of Technology, Computer Science Department, Intellectics Group, Darmstadt, Germany, 2001. [32] R.J. Wallace, E.C. Freuder, Comparative studies of constraint satisfaction and Davis–Putnam algorithms for maximum satisfiability problems, in: D.S. Johnson, M.A. Trick (Eds.), Cliques, Coloring, and Satisfiability, DIMACS Series in Discrete Mathematics and Theoretical Computer Science, vol. 26, Amer. Math. Soc., Providence, RI, USA, 1996, pp. 587–615. [33] Z. Xing, W. Zhang, MaxSolver: an efficient exact algorithm for weighted maximum satisfiability, Artif. Intell. 164 (2005) 47–80. [34] H. Xu, R.A. Rutenbar, K. Sakallah, sub-SAT: a formulation for relaxed Boolean satisfiability with applications in routing, IEEE Trans. Comput.-Aided Des. Integr. Circuits Syst. 22 (2003) 814–820. [35] M. Yannakakis, On the approximation of maximum satisfiability, J. Algorithm 17 (1994) 475–502.