Comparing the performance of the genetic and local search algorithms ...

27 downloads 0 Views 330KB Size Report
s results from flipping a single variable x in V, changing the truth value of x from true to ...... Conference, Las Vegas, Nevada, (2001), pp. 530–535. [30] F. Aloul, I.
Applied Soft Computing 10 (2010) 198–207

Contents lists available at ScienceDirect

Applied Soft Computing journal homepage: www.elsevier.com/locate/asoc

Comparing the performance of the genetic and local search algorithms for solving the satisfiability problems Yousef Kilani Prince Al-Hussein Bin Abdullah II, School of Information Technology, Hashemite University, Elzarqa, Jordan

A R T I C L E I N F O

A B S T R A C T

Article history: Received 6 July 2008 Received in revised form 9 June 2009 Accepted 2 July 2009 Available online 8 August 2009

The satisfiability problem (SAT), as one of the six basic core NP-complete problems, has been the deserving object of many studies in the last two decades [1]. Stochastic local search and genetic algorithms are two current state-of-the-art techniques for solving the SATs. GASAT [2,1] and SAT-WAGA [4] are two current state-of-the-art genetic algorithms for solving SATs. Beside, the discrete lagrangemultiplier (DLM) [8–10] and the exponentiated subgradient algorithms (ESG) [12] are the current stateof-the-art local search algorithms for solving SATs. In this paper, we compare DLM and ESG with GASAT and SAT-WAGA. We show that the performance of the local search-based algorithms: DLM and ESG is better than the performance of the genetic-based algorithms: GASAT and SAT-WAGA. We further analyze the results of the comparisons. We hope these comparisons give light to the researchers while researching in genetic and local search algorithms, help understanding of the reasons for these algorithms’ performance and behaviour and to the new researchers who are in the process of choosing research direction. ß 2009 Elsevier B.V. All rights reserved.

Keywords: Local search algorithms: ESG and DLM Genetic algorithms: GASAT and SAT-WAGA SATs Comparison

1. Introduction The satisfiability problem (SAT), as one of the six basic core NPcomplete problems, has been the deserving object of many studies in the last two decades [1]. In addition to its theoretical importance, SAT has a large number of practical applications such as VLSI test and verification, the design of asynchronous circuits, sports planning and so on [1]. There are many methods of search techniques for solving the SATs like backtrack-based, genetic, neural network and local search algorithms. The genetic algorithm for the SATs (GASAT) [2,1] and SAT-WAGA [4] are the two current state-of-the-art genetic algorithms for solving the SATs. Besides, the discrete lagrange-multiplier (DLM) [8–10] and the exponentiated subgradient algorithm (ESG) [12] are the current state-of-the-art local search algorithms for solving the SATs. Our contribution in this paper is to compare between the stateof-the-art genetic, GASAT and SAT-WAGA, and the local search, DLM and ESG, algorithms for solving the SATs. In addition, We show that the genetic-based and the local search algorithms behaves differently in solving the real instances of the benchmark than the randomly generated instances. We further show that the DLM and ESG have almost the same level of difficulty in solving the

E-mail addresses: [email protected], [email protected]. 1568-4946/$ – see front matter ß 2009 Elsevier B.V. All rights reserved. doi:10.1016/j.asoc.2009.07.012

benchmark instances. This research directs the researchers in the SATs to choose the best performing techniques. The rest of this paper is organized as follows. Section 2 presents the SATs. Section 3 introduces the stat-of-the-art SAT solving algorithms. Sections 4 and 5 present the two state-of-the-art genetic algorithms: GASAT and SAT-WAGA. Sections 6 and 7 present the the two state-of-the-art local search algorithms: ESG and DLM. Section 8 shows the results of the state-of-the-art local search and genetic algorithms and compares betweens them. The last section gives the conclusion remarks. 2. The satisfiability problem A propositional/Boolean variable can take the value of either 0 (false) or 1 (true). Let V ¼ fx1 ; . . . ; xn g be a set of Boolean variables, a literal li is a variable xi or its negation : x [27]. A clause is a disjunction of literals ci ¼ l1 _ l2 . . . _ lni [27]. A literal l is true if l assumes the value 1; l is false otherwise. A clause is satisfied when one of its literals is true. For simplicity we assume that no literal appears in a clause more than once, and no literal and its negation appear in a clause. Let l¯ denote the complement of literal l: l¯ ¼ x¯ if l ¼ x, and l¯ ¼ x if l ¼ x. ¯ The conjunctive normal form propositional logic formula is a conjunction of a set of clauses. There are many encoding techniques to convert a propositional logic formula which is not in a conjunctive normal form to a conjunctive normal form (see for more details [21,22]). A valuation is a complete assignment to all the variables in

Y. Kilani / Applied Soft Computing 10 (2010) 198–207

the SAT. A solution is a valuation that satisfies all the clauses in the SAT. A SAT is a propositional logic formula which consists of a finite set of variables V and a finite set of clauses C ¼ fc1 ; c2 ; . . . ; cm g. The problem is to assign the values: true or false to all the variables in V to satisfy all the clauses in C (i.e. to find an valuation that is a solution). 3. State-of-the-art SAT solving algorithms Over the last 10 years, a lot of impressive progresses have been made in the practical solving of the SAT [27]. All the methods that address this typical NP-complete problem may be divided in two categories: complete ones, usually based on the Davis, Logemann and Loveland procedure [28,29], can prove that a formula is satisfiable or not [27]. Incomplete solvers (also called one-sided solvers) only give an answer if the instance has a given property (generally if it is satisfiable) [27]. There are two types of complete search algorithms: tree-based and nogood-based. The tree-based search algorithms [30,32,33] are variants of the DavisPutnam–Logemann–Loveland algorithm (DPLL) [28]. Most of these algorithms use some kind of problem reduction or pruning like unit propagation [34,31]. The second type uses nogood [35,36] recording to store the eliminated search space. The state-of-the-art complete SAT solvers like Chaff [29], SATzilla [37], MiniSAT [43,44], RSat [38,39,45], CVC3 [45,40,41,45], and OpenSat [42]. These algorithms differ from each other in the way of passing by the search space: tree-based or nogood-based, the way of choosing the next variable in the search to give value, the way of choosing the value for this variable, the backtracking point when the search fails to find a value for a variable that satisfies the clauses with the other labeled variables (i.e. variables taken values), and they may include some other heuristics like restarting the search if it fails to find a solution within a certain limit, i.e. (time or number of flips) and giving weights for the clauses to speed up the search, etc. The incomplete search algorithms searches for a solution heuristically without passing by the whole search space. The weaknesses of these algorithms are not able to determine whether a solution exists or not and it has no guarantee to find a solution if it exists. The incomplete search algorithms include local search, genetic, tabu search and neural networks. For the SAT, the incomplete search algorithms can generally find solutions faster than complete search algorithms [47]. (The stochastic local search algorithms evolved out of the Selman and Kautz’s 1992 GSAT algorithm [17]; [48].) Any local search algorithm has the general local search algorithm backbone (GLSB) plus extra features. The input to GLSB is a set of clauses. Initially, GLSB chooses an valuation as a start point to start searching. Some local search algorithms may choose the start valuation randomly and other algorithms choose the start valuation heuristically. Every valuation s has a neighbourhood nðsÞ which is a set of neighbour valuations. In most of the current state-of-the-art local search algorithms, the neighbour to valuation s results from flipping a single variable x in V, changing the truth value of x from true to false or vice versa, where x is a heuristically chosen variable. The way of choosing x depends on the algorithm used. The start valuation represents the current valuation. GLSB moves from the current valuation to a better neighbour valuation using the function bðnðsÞÞ. One criteria to consider an valuation A better than an valuation B is when A satisfies more clauses than B. The function bðnðsÞÞ chooses one of the best neighbours according to some heuristics. Some local search algorithms may move to an equal neigbour valuation to the current valuation whenever there is no better neigbour valuation. The chosen best neigbour valuation becomes the current valuation. GLSB continues such

199

moves from the current valuation to a better neighbour valuation until it finds a solution or the time or the number of flips limit is over. If it happens that there is no better/(or better or equal) neighbour valuation then it is local minima, trap. GLSB escapes this trap. The extra features like a restart, clause weight and/or tabu list. Local search restarts the search if it could not find a solution within a certain limit in order not to spend too much time searching in one part of the search space. Local search uses a tabu list in order to avoid flipping the same variable within a specific number of flips. It uses clause weights to give a weight for each clause and when there is a trap, it increases the weights of the unsatisfied clauses involved in the trap so that these clauses are forced to be satisfied. The efficiency of a local search algorithm depends on three factors [14]: (1) The size of the search space which depends on the number of variables and the size of the domain of each variable. (2) The search surface (the structure of each constraint and the topology of the constraint connection). (3) The heuristic function (the definition of neighbourhood and how a ‘‘good’’ neighbour is picked). The state-of-the-art local search algorithms like UBCSAT [51], DLM [8,9,26], gNovelty+[48], the exponentiated subgradient algorithm (ESG) [12], and QingTing [55]. UBCSAT [51] is an implementation and experimentation framework for stochastic local search algorithms [51]. It has been developed in strict ANSI C in order to be a platform-independent and tested on some of the popular operating systems: Linux, WidowsXP, and sunOS. UBCSAT is freely downloadable from http://www.satlib.org. DLM [8,9,26] is a discrete Lagrange-multiplier-based local-search method. Section 6 introduces the DLM algorithm. gNovelty+[48] is a variant of the WalkSAT algorithm [54]. gNovelty+ was a gold medal winner in the random category of the 2007 SAT competition [48]. gNovelty+ draws on the features of two other WalkSAT family algorithms: R+AdaptNovelty+[53] and G2WSAT [34], while also successfully employing a dynamic local search clause weighting heuristic to further improve performance [48]. WalkSAT does not use clause weights. WalkSAT chooses the set of neighbours in such a way that each neighbour results from flipping a variable from the currently unsatisfied clauses. The best neigbour is the neighbour that results from flipping the variable satisfying the maximum number of clauses. The exponentiated subgradient algorithm (ESG) is a general-purpose Boolean linear program (BLP) search technique [12]. The ESG is quite similar to DLM with some differences like ESG includes restart while DLM does not make a restart and ESG escapes from the trap by making noise with certain probability or updating the weights of the currently unsatisfied clauses while DLM escapes the trap by increasing the weights of the currently unsatisfied clauses. Section 7 presents the ESG algorithm. QingTing [55] is a SAT solver that combines the unitwalk [57] local search algorithm, the Zhang and Stickel’ unit propagation algorithm [56], and the Chaff’s [29] lazy data structure. QingTing applies the unit propagation technique to modify the current assignment as long as a unit clauses exist. A unit clause is a clause contains one literal. If a clause contains one literal then this literal must be true in order this clause to be satisfied. The unit propagation process assigns a value for such literal to make it true and hence to satisfy the unit clause in which this literal occurs. The genetic algorithms are derived from the evolution processes in nature and is described by Goldberg [11] as: ‘‘genetic algorithms are search algorithms based on the mechanics of natural selection and natural genetics. They combine ‘‘survival of the fittest’’ among string structures with a structure yet randomize information exchange to form a search algorithm with some of the innovative flair of human search. In every generation, a new set of

200

Y. Kilani / Applied Soft Computing 10 (2010) 198–207

artificial creatures (strings) is created using bits and pieces of the fittest of the old; an occasional new part is tried for good measure. While randomized, genetic algorithms are no simple random walk. They efficiently exploit historical information to speculate on new search points with expected performance’’. Mitchell [50] presents an introduction to GAs. In the genetic algorithms, an valuation is called a member. A population is a set of members. Mostly, the genetic algorithms start the search by generating random members in the population. This population represents the current generation. Each member in the current generation is given a fitness value which indicates the goodness of the member. For instance, member A has higher fitness than member B indicates that A satisfies more clauses than B. A member is a solution when it satisfies all the clauses. The GAs uses the genetic operators like crossover and mutation to produce the next generation from the current generation. The crossover chooses two parents (members) from the current generation and it swaps part of these parents to produce children simulating the way the creatures (e.g. human being) produce children by swapping parts of the chromosomes from the parents. These children are inserted in the next generation. The mutation chooses one parent and assigns values to some variables randomly to avoid the genetic algorithms from falling into convergence. In the convergence, most or may all the members in the current generation be similar or nearly similar. After generating the next generation, this generation becomes the current generation. The genetic algorithms continue the process of generating the next generation from the current generation until it finds a solution or the time is over. The state-of-the-art genetic algorithms for solving the SAT include GASAT [2,1,52], and SAT-WAGA [4]. GASAT is a hybrid algorithm of the genetic and tabu search techniques. Section 4 introduces the GASAT algorithm. SAT-WAGA [4] is a genetic algorithms based. Section 5 presents the SAT-WAGA algorithm. A neuron is a cell in the brain whose principal function is the collection, processing and dissemination of electrical signals [59]. The brain’s information-processing capacity is thought to emerge primarily from networks of such neurons [59]. Therefore, the neural network is part of the artificial intelligence aimed to create artificial neural networks. A SAT is represented as a network structure in which the variable assignments are represented by the activation of nodes and the clauses are represented by connections. When the network converges, the set of nodes which are on represents a set of assignments which form a solution. The state-of-the-art neural network for solving the SAT include the Lagrange Programming neural network with Polarized Highorder connections (LPPH) [60] for solving the SAT. LPPH was proposed by Zhang and Nagamatu [47]. Zhang and Nagamatu proposed a parallel execution of the LPPH in which plural instances (the solver) of the LPPH are executed simultaneously to speed up the search. Tabu search algorithms are amongst the most successful local search based methods for the maximum satisfiability problem [61]. Tabu search algorithms uses the tabu list of size x to store the last x flipped variables, where x is a parameter. When tabu search chooses a variable to flip it then prevents the choice of the variables in the tabu list. This restriction is to prevent the same variable from being flipped twice within the x tabu search moves and hence preventing the search from falling in a trap. Note that, in SAT, if a variable is flipped twice then it is the same as not flipping this variable. After each tabu search move the tabu list is updated in a FIFO manner. Some local search algorithms uses the tabu search idea in their implementation. The state-of-the-art tabu search algorithms include tabu search for solving the satisfiability problem (TSSAT) [58]. The aspiration criterion and tabu list structure of TSSAT are different from those of traditional tabu search [58].

Fig. 1. GASAT.

To the best of our knowledge, there is no theoretical comparison backed by experiments among the different methods of the stateof-the-art solvers for solving the SATs. SAT competition [62] which is held annually makes the comparison among SAT solvers with respect to the execution time. In addition, it does not consider all the existing SAT solvers, it considers the solvers which their creators or representers present in the competition. Local search method, unfortunately, do not provide a proof that the returned solution is optimal [63]. It is a common knowledge that this conclusion is for almost all the incomplete search algorithms since most of the incomplete search algorithms include parameters and there is no optimal way to tune these parameters. Most of such parameters have infinite number of values that can take. Therefore, it is impossible to consider all the combinations of the values the parameters can take. Usually, tuning of the parameters is done heuristically. 4. The GASAT algorithm Lardeux et al. [1] and Hao et al. [2] introduce GASAT.1Fig. 1 presents GASAT. In GASAT, each member of the population is a binary string of n bits, where the n bits represent the variables in the problem. Each bit can take the value of either 0 or 1 which are the same values a Boolean variable can take. GASAT starts the search by generating an initial population randomly in which each variable in each member takes a value randomly. Then the fitness value of every member is calculated. The fitness value of a member is equal to the number of clauses which are not satisfied by this member. GASAT chooses a set of the best individuals b from the population, where the size of b is a parameter. It then chooses randomly parents from b. In order to avoid the case in which the selected parents are similar and to keep diversity in the population, GASAT accepts the selected parents if there is a k hamming distance between these selected parents, where k is a parameter. GASAT selects two parents and uses the crossover operator to produce a child. This child is further improved by using the tabu search local search algorithm. In each step (move) of tabu search, GASAT chooses the best variable to flip which is not in the tabu list. The best variable is the variable once flipped satisfies the maximum number of clauses with compare to the other variables. The size of the tabu list and the number of the tabu search moves are parameters in GASAT. The tabu list is a fixed size array of size x. It stores the last x flipped variables. Once a variable is flipped, it is not allowed to be flipped in the coming x flips. After a variable is flipped, the first flipped variable in the tabu list is removed and is replaced by the newly flipped variable (in a FIFO manner). The main goal of the crossover operator in GASAT is to create diversified and potentially promising new individuals [1]. GASAT has three different crossover operators: corrective clause, correc1 The source code is downloadable from http://www.satlive.org/satkwd.jsp?kwd =79.

Y. Kilani / Applied Soft Computing 10 (2010) 198–207

tive clause and truth maintenance, and Fleurent and Ferland. In an experimental comparisons, Lardeux et al. [1] show that the performance of these crossover operators are far better than the classic uniform crossover operator. The classic uniform crossover operator assigns value for each variable by choosing one of the values assigned for this variable y the parents. The three crossover operators produce one child from the parents: Crossover(x, y) ) child z. GASAT uses one of the three crossovers at a time according to the following three cases: a clause is satisfied by the two parents, a clause is satisfied by one parent, and a clause is not satisfied by the two parents. The corrective clause crossover: when a clause c is not satisfied by the two parents x and y, this crossover flips one of the variables v in c to satisfy c. In order to choose v, it passes by all the clauses which are currently unsatisfied by x, y and the child z, where the variables in z initially have no values, and computes dð f Þ for every variable f appears in these clauses, where dð f Þ ¼ im pðx; f Þþ im pðy; f Þ; im pðD; eÞ ¼ satis fiedðD; eÞ  unsatis fiedðD; eÞ, satis fiedðD; eÞ returns the number of unsatisfied clauses that becomes satisfied by flipping e, and unsatis fiedðD; eÞ returns the number of satisfied clauses that becomes unsatisfied by flipping e. The corrective clause crossover flips the variable f which has the maximum value of dð f Þ. The corrective clause and truth maintenance crossover applies the corrective clause crossover and then applies the following procedure. Compute dð f Þ for every variable appears in clause c, where c is a clause satisfied by the two parents and not satisfied by the child z. Finally, the corrective clause and truth maintenance crossover chooses the variable to flip with maximum d. Fleurent and Ferland’s crossover: when a clause c is satisfied by one parent and not satisfied by the other parent, this crossover assigns the values for the variables appearing in c the same values taken in the parent that satisfied c. These variables and their values are then copied to the child z. After applying the previous crossovers, if any variable in z is left with no value, GASAT chooses one of the values for this variable from its parents randomly that is, if v in z has no value, and v has the values 0 and 1 in the parents x and y, respectively, GASAT choose either 0 or 1 randomly.

201

Fig. 2. The SAT-WAGA algorithm.

are given higher chances to be selected more than the members of the low probability and subsequently the set of parents contains more good members than bad members. SAT-WAGA generates the next generation by two steps. In the first step, it generates NumberO fNewMemeber members through the crossover and mutation operations. In a probability ProbCross, SAT-WAGA selects two parents randomly from the ParentSet and it applies the one-point crossover operation to produce two children: z and k. In a probability ProbMut, SAT-WAGA applies the mutation operation on z and k. SATWAGA adds the two children z and k to the next generation. In the second step, SAT-WAGA copies the Po pSize  counter members from the current population p to the next generation, where Po pSize is the number of members in the population. The variables: MaxGenerations; ParentSet; Prob Cross; NumberO fNewMemebers, and ProbMut are parameters. pnext contains the members generated in the first step. 6. The DLM algorithm

5. The SAT-WAGA algorithm The SAT-WAGA [4] algorithm is a genetic algorithm for the SATs. SAT-WAGA represents the SAT in the same way as GASAT: each member of the population is a binary string of n bits, where the n bits represent the variables. Fig. 2 describes the SAT-WAGA algorithm. We have got the source code of SAT-WAGA from the author through a personal communication (by emailing to: [email protected]). We describe SAT-WAGA as follows. Each clause is given a weight. Initially, SATWAGA initializes the weight of a clause to the number of literals in this clause. The weight of the clause c in generation n is denoted by wn ðcÞ. The fitness function of a member returns the sum of all the clauses’ weights which are satisfied by this member. Therefore, the higher the fitness value is the better the member. A convergence is similar to the tarp in local search in which the search is no more progressing from a generation to the next. When there is a convergence, SAT-WAGA increases the weights of the currently unsatisfied clauses, s, by the weight, d, of the best member of the population in the current generation in order to force the search to satisfy these clauses in the coming few generations: wnþ1 ðcÞ ¼ wn ðcÞ þ d; 8 c 2 s. SAT-WAGA selects the set of parents ParentSet from the population of the current generation using a heuristic function which gives high selection probability to the good members and low selection probability to the bad members. By doing so, the members of the high probability

DLM [8–10,26] is a discrete Lagrange-multiplier-based localsearch method for solving the SATs, which are first transformed into a discrete constrained optimization problem. Fig. 3 shows the core of DLM.2 Experiments confirm that the discrete Lagrange multiplier method is highly competitive with other satisfiability problems solving methods [8]. In DLM, each clause c is given a penalty function on states, so cðsÞ ¼ 0 if state s satisfies constraint c, and cðsÞ ¼ 1 otherwise. DLM performs a search for a saddle point of the Lagrangian function Lðs; lÞ ¼ l  cðsÞ ¼ Si li  ci ðsÞ where l are a vector of Lagrange multipliers, one for each constraint, which give the ‘‘penalty’’ for violating that constraint. The saddle point search changes the state to decrease the Lagrangian function, or increase the Lagrange multipliers. In Fig. 3, line 1 shows that the input to DLM is a set of clauses c. Line 2 makes a random initialization to all the variables. Line 3 initializes l to 1. Line 4 repeats the search until it finds a solution or reaches a maximum number of flips. Lðs; lÞ ¼ 0 means no constraint is violated, i.e. cðsÞ ¼ 0, for each constraint c in the problem. Lines 5, 6 and 7 set min, best and unsat to the Lagrangian function of the current state s, empty and the set of all the literals in 2

Downloadable from http://www.manip.crhc.uiuc.edu/Wah.

Y. Kilani / Applied Soft Computing 10 (2010) 198–207

202

where ci is the i th row vector of the constraint matrix C and yi is the real valued Lagrangian multiplier associated with constraint ci . Similar to DLM, yi is the penalty for violating constraint vi ¼ ci cot ~ x  bi . The objective is to minimize Lð~ x; ~ yÞ. Since our work focus on satisfiability problems, in the following we illustrate how to encode a satisfiability problem as BLP problem as taken from [12]. A satisfiability problem of m clauses ~ c ¼ c1 ; . . . ; cm and ki literals in each ci , can be equivalently represented by the BLP: ~ min 0 ~ x sub ject to Cx  ~ k ~ 2 xi 2 f1;1gn ;i¼1;...;n

and

8