Genetic Algorithm for Restricted Maximum k -Satisfiability in the Hopfield Network

— The restricted Maximum k-Satisfiability MAX-kSAT is an enhanced Boolean satisfiability counterpart that has attracted numerous amount of research. Genetic algorithm has been the prominent optimization heuristic algorithm to solve constraint optimization problem. The core motivation of this paper is to introduce Hopfield network incorporated with genetic algorithm in solving MAX-kSAT problem. Genetic algorithm will be integrated with Hopfield network as a single network. The proposed method will be compared with the conventional Hopfield network. The results demonstrate that Hopfield network with genetic algorithm outperforms conventional Hopfield networks. Furthermore, the outcome had provided a solid evidence of the robustness of our proposed algorithms to be used in other satisfiability problem.

I. InTRoducTIon s Ince decades ago, optimization has provided intensified algorithmic research for the development of constraint satisfaction and Boolean satisfiability. Hybridization between both field are motivated by application in scheduling, VLSI circuit, pattern reconstruction and many other applications. However, the main problem for both area is to assign interpretation or value to variables such that it makes the whole system become feasible [1]. Before it can be considered as optimization problem, both field must merge their character and able to produce their hybridized cost function [2]. Motivated by notable counterpart of Boolean satisfiability, restricted maximum k-satifiability (MAX-kSAT) has been a wide subject in constraint optimization problem. Restricted MAX-kSAT can be defined as a problem to assign value to Boolean variable with k literal per clause that maximize the number of satisfied clauses.
The idea of implementing artificial neural network to provide solution to optimization problem has been utilized by various researcher in artificial intelligence field. It is a fascinating field of study because it provides an alternatives way of doing computation and it is a paradigm towards understanding of the intelligence. It is a pursuit to visualize and represent information processing capabilities of an actual nervous system [3]. Hopfield neural network [4] is a simple recurrent network that has an efficient associative memory and resembled the biological brain [5]. The important property of the Hopfield neural network is the minimization of energy whenever there is any change in inputs. Due to effectiveness of energy changes in Hopfield neural network, several researchers have merged the idea of logic programming with Hopfield neural network. Several celebrated models were developed by Sathasivam [6] and Wan Abdullah [3]. Most of the model employed the cost function based on inconsistencies of the Horn clauses [5]. The cost function of the logic will be exploited in order to find the connection strength that act as a building block of the energy minimization.
Due to the complexity of network when the number of neuron increased, method of searching satisfied interpretation in a given MAX-kSAT clause should comply with traditional Hopfield network. The easiest method that compliment with Hopfield network is exhaustive search method (ES). The combination of exhaustive search method (ES) and Hopfield network namely HNN-MAXkSATES will be utilized to represent the conventional Hopfield network [32].
Genetic algorithm (GA) is increasingly viewed as optimization technique to a wide range of problem. Strictly speaking, genetic algorithm combines the idea of evolutionary improvement, recombination and mutation among the candidate solution. Since Hopfield neural network often providing a local minimum to solution [7], genetic algorithm will be incorporated with Hopfield network to do MAX-kSAT problem. The combination of genetic algorithm and Hopfield neural network were proven effective by many researchers in solving various optimization problem [8,9,10]. Thus, genetic algorithm is introduced in this study to supplement the Hopfield neural network to facilitate the search process of MAX-kSAT solution. HNN-kSATGA indicates the combination of Hopfield network and Genetic algorithm in solving any given MAX-kSAT problem. Although the solution obtained may stuck at local minima, the performance of the MAX-kSAT solution based on this hybrid algorithm was indeed promising.
This paper has been organized as follows. Section II introduces the k-satisfiability (k-SAT) and maximum k-satisfiability (MAX-kSAT). In section III, neuro searching methods including exhaustive search (ES) and genetic algorithm method (GA) in doing MAX-kSAT will be discussed. In section IV, neuro-logic paradigm comprises of the Hopfield model, Wan Abdullah's method and Sathasivam's relaxation method will be discussed. Furthermore, the implementation of our proposed method will be discussed in section V. Finally, section VI and VII enclose the experimental results and conclusion.

A. k-Satisfiability Problem
The k-SAT problem can be delineated as a conundrum of determining satisfiability of sets of clauses comprise of at most k literals per clause (k-CNF formulas). It is a general form of satisfiability problem that can be divided into the randomized satisfiability and maximum satisfiability [41]. Additionally, k-SAT problem can be expressed as k-CNF (k-Conjunctive Normal Form) or Krom formula [38]. Besides, k-SAT problem is considered as a NP problem or non-deterministic problem. Hence, the k-SAT problem involves logic formula that can be translated into an optimization problem. Therefore, the three core components of k-SAT are simplified as follows: 1. Consists of a set of m variables, 1 2 , ,......, m x x x 2. A set of literals. A literal is a variable or a negation of a variable.
3. A set of n distinct clauses: 1 2 , ........ n C C C . Each clause consists of only literals combined by just logical OR "V". Each clause must contain of variables.
In addition, the Boolean values are bipolar, consisting of 1 and -1 that could have exemplified the idea of true or false [45]. Hence, the goal of the k-SAT problem is to decide whether there exits an assignment of truth values to variables that makes the following formula satisfiable.
Where ∧ is a logical AND connector, P denotes the entire Boolean formula for k-SAT. i C is a clausal form of DNF with k variables. In our case, we investigated k=2 and k=3 for our satisfiability problem where the clause in randomized 2-SAT and 3-SAT has the following form:

B. Restricted Maximum k-Satisfiability
Restricted maximum k-Satisfiability problem (MAX-kSAT) can be defined as generalized form of Boolean satisfiability problem [37]. Given a Boolean formula P in conjunctive normal form (CNF) with n clauses containing variable each and positive integer g where g m ≤ . MAX-kSAT can be defined specifying implicitly a pair ( ) , λ θ [44] where λ is the set if all possible solution { } 1, 1 n − and θ is a mapping λ ξ → which is denotes the score of the assignments. ξ is scored based on true clauses. Therefore, MAX-kSAT problem contains of defining the best bipolar/binary assignments to the variables in P that simultaneously satisfies at least g of the m clauses. Moreover, the mission is to decide the "optimized" assignment that can satisfy the maximum number of clauses containing k variables.
Fundamentally, there are 2 n possible solutions to this problems. It was proven that MAX-kSAT is NP-complete problem for any 3 k ≥ . There are numerous classifications of the MAX-kSAT namely, weighted MAXSAT [42] and Partial MAXSAT [43]. However, restricted MAX-kSAT constrained optimization problem that can be included in maximization problem [39]. Additionally, restricted MAX-kSAT can be ventured in logic programming [40]. In this exploration, we limit our analysis to k=2 and k=3. For instance, we can form the following 2-SAT formula: Equation (4) is not possible to satisfy because no particular assignment will drive to all the clauses true. The following Table 1 portrays the truth table for P. Table 1 depicts that entire assignments will not be able to make formula P true. Hence, every clause will be checked in order to compute the maximum number of satisfied clause. All in all, the maximum number of clauses satisfied by the assignment is 3 out of 4.

III. neuRo-seARchIng PARAdIgM
Neuro-searching paradigm consists the algorithmic method in finding the solutions. Previously, Hopfield neural network alone has been utilized in doing logic programming. The usage of Hopfield neural network (HNN) in doing logic programming is proven effective when the number of neurons were small. In order to make a fair comparison between standalone Hopfield neural network and Hopfield neural network incorporated with genetic algorithm, we embedded exhaustive search technique to enhance the traditional HNN in doing MAXkSAT. In this paper, neuro-searching paradigms were used in hunting the maximum number of clauses for restricted maximum 2-satisfiability and restricted maximum 3-satisfiability problem.

A. Exhaustive Search (ES)
Exhaustive search (ES) algorithm can be demarcated as a local search technique for an element with a particular property among combinatorial forte such as permutations, combinations, logics, satisfiability or subsets of a set [32].
Roughly speaking, the ES algorithm will brutally hunt for the total potential clause, even if the search dimension was getting bigger and more complex [5]. Technically, the exhaustive search is the most primitive algorithm for checking the logic satisfaction. ES is theoretically simple to implement. In our exploration, we embedded ES to traditional Hopfield neural network in order to enhance the primitive solution checking by Hopfield neural network. The exhaustive search will facilitate traditional Hopfield neural network to check the satisfaction clause by clause in order to generate the maximum number of satisfied clause.
However, the main drawback of exhaustive search (ES) is the speed of the algorithm [35]. Subsequently, exhaustive search devours more computation time in searching for the maximum number of satisfied clauses completely [28]. In this paper, we will generate random bit strings and compute the number of satisfied clauses directly, clause by clause. It will be a huge possibility that the bit strings are not converging to global maxima during the first iteration of ES. Thus, the iterations will be repeated 100 times. The ES might look decent for the simpler case, but what would happen if we increase the number of clauses?
We will encounter with the complexity of the hybrid network when we attempted with more complex bit strings. Thus, the computation time will become very high if we increase the complexity of the hybrid network. Therefore, the computation complexity is represented as (2 ) n O [6]. For the ES algorithm, the satisfied assignment is gained after performing a 'trial and error' procedure exhaustively. Henceforth, the correct assignment will be stored into the Hopfield's artificial brain in the form of content addressable memory (CAM). Some related work on exhaustive search has been done by a few neural network practicioners such as Aiman & Asrar [27], Kaushik [28], and Zinovik et al. [32]. In this paper, we hybridized ES algorithm with the Hopfield neural network as a network based on logic programming to solve MAX-kSAT problems (HNN-MAX2SATES and HNN-MAX3SATES).

B. .Genetic Algorithm (GA)
Genetic algorithms are robust evolutionary paradigms that have attracted a prolific amount of research in optimization and maximization problem [46]. According to mathematicians' standpoint, the genetic algorithm is a staple computational paradigm inspired from the Darwin's theory of evolution, namely survival for the fittest model [29,30]. For instance, every generation is represented by an array of bit strings similar to the chromosomes of DNA. In our case, we have a set of bit string that represent the interpretation of the MAXkSAT. This is motivated by the previous work by Aiman and Asrar [27] that highlighted on the genetic algorithm to solve randomized 3-SAT problem. On the contrary, the fundamental impetus of genetic algorithm is to find the bit string that maximize the number of satisfied clauses before we incorporate with Hopfield network. Specifically, the genetic algorithm in doing MAXkSAT consists of distinctive stages.

Stage 1: Initialization
In this stage, 100 random populations in the form of bit strings were initialized [27]. Each assignment consists of possible solution to randomized MAXkSAT problem.

Stage 2: Fitness evaluation
Next. all the bit string will undergo fitness evaluation. Each of the correct bit which result in satisfied MAXkSAT clause will be "awarded". During fitness evaluation, the number of satisfied clauses will represent the fitness of the chromosome (bit string). The fitness function is widely used as an objective function by a few notable works [46,47,48]. The objective function of the genetic algorithm is as follows: Specifically, the role of the fitness function is to evaluate the candidate bit strings.

Stage 3: Selection
During this stage, 10 candidate bit strings with the highest fitness will go to the next generation. The selected candidate bit strings will have the privilege to perform the crossover process.

Stage 4: Crossover
During crossover, bit strings will be chosen randomly and the exchange of information between two sub-structure of the bit strings occurred. Bit string. For example, Before crossover The location of crossover in a particular bit string is randomly defined since we want to maintain genetic diversity of the bit strings. Crossover usually increase the number of satisfied clause of the newly bit strings children. This feature helps the best bit string of the generation to survive and improve further. On top of that, the crossover operator imitates the biological amalgamation between two single-chromosomes (haploid) in organisms. After crossover, all the bit strings children undergo fitness evaluation in order to check their corresponding fitness.

Stage 5: Mutation
Mutation operator is the real game changer for genetic algorithm. Local maxima could occur during simulation. Local maxima occurred when the fitness of the bit string varies significantly to the expected maximum fitness. This will create non-improving solution of MAXkSAT clauses. In order to create "out of the blue" bit string, we utilized mutation. Mutation involve flipping the state of the bit string from 1 to -1 or -1 to 1 [27]. Position of the mutation in a particular bit string is random. For example,

After mutation
Bit string A = - 1 1 1 1 The second position of the bit string was flipped from -1 to 1. In this case, different bit string was created after mutation.
Thus, we can calculate the fitness value for the newly formed bit strings [27,36].
Genetic algorithm in doing MAXkSAT has been proven effective by previous researchers to avoid global maxima. If the bit string does not achieve the desired fitness (local maxima), the current bit string will improve further during the next generation via crossover and mutation. Most of the researchers set up to 100 to 1000 generations in order to improve the solution. Since we are dealing bipolar search which only involve 1 or -1, it will be easy for bit strings to converge to global maxima (Maximum fitness). In this paper, we hybridized GA algorithm with the Hopfield neural network as a network based on logic programming to solve MAX-kSAT problems (HNN-MAX2SATGA and HNN-MAX3SATGA).

A. The Hopfield Neural Network
For many years, Hopfield model has been recognized as an effective optimization method [4]. Since the first application of Hopfield network to optimization problem, this approach has well drawn many attention towards various field such as computer network, pattern recognition and scheduling problem. Theoretically, the model comprises of interconnected unit called neurons, forming a network. Computation in Hopfield network is executed by collections of interconnected neurons [4,11]. Most of the literature suggest Hopfield network contains good properties including parallel execution for fast solutions to computationally intensive optimization problems with exceptionally good accuracy [9]. In this connection, we choose Hopfield network to do logic programming because it is well distributed, consist of CAM [12], smooth implementation and easy to blend with other algorithm.
The units in Hopfield nets are called binary threshold unit [13] which can only take bipolar values such as 1 and -1. The paramount definition for unit I's activation, i a are given: Since the weight (connection strength) in Hopfield network is constantly symmetrical, the updating rule maintains as follows [15]: The dynamic is to ensure the energy decrease monotonically which following the activation system. The generalized lypunov energy equation is as followed: This energy function is significant because it establishes the degree of convergence of the network [16,4]. The energy value obtained from the equation will be checked through and will be classified as global or local minimum energy. As it stands, the network is hunting for global minimum energy (correct solution) compared to local minimum energy (wrong solution). The process of obtaining global minimum energy always associated with how we define the weight of the network. In this work, we implemented Wan Abdullah's updating technique to obtain the weights for our network [3,17].

B. Wan Abdullah's Method in Learning MAX-kSAT Clauses
MAX-kSAT can be treated as one of the constrained optimization problem that being carried out on Hopfield neural network. Wan Abdullah's method became the pioneer in weight extraction based on logical inconsistencies [17]. Truth values were assigned to each atoms.
The minimized cost function can be created by maximizing the number of satisfied clauses.
Cost function cost f for both equation (8) and (9) are as followed By comparing equation (12), (13) with equation (9), we obtained synaptic weight for α and φ . The synaptic weights are shown in Table 2 and Table 3.   Normally, weight can be determined by using traditional Hebbian learning concept [18]. Sathasivam has shown that the weight obtained by using Wan Abdullah's method are similar due to clausal MAX-kSAT similarity. Although both method is expected to produce the similar weight, Wan Abdullah's method is proven to minimize the spurious minima produced by logic compared to Hebbian learning [17,18].

C. Network Relaxation
The nature of the solution obtained by Hopfield network can affected by multiple factors. According to Zeng & Martinez [19], the firing and receiving information among neurons can influence the output of the network. In this case, network relaxation helps the network to exchange information efficiently. As the number of neuron increased, more interconnected neurons involved in firing and receiving information. Without proper relaxation mechanism network tend to produce more local minima solution. Since MAX-kSAT contain more clausal constrained, we applied Sathasivam's relaxation technique [14] to ensure the network relaxed to equilibrium states. Information exchange between neurons will be updated based on the following equation Where R denotes the relaxation rate and i h refers to the local field of the network as listed in equation (7). In this case, we consider a constant relaxation R since it will improve the network relaxation compared to dynamic relaxation.

D. Hyperbolic Activation Function
Other than relaxation rate, the choice of activation function can affect the performance of the network. Traditional McCulloch-Pitts activation function is prone to few weaknesses such as computational burdening and lack of efficiency on producing desired result [20]. In order to get network's full potential, we utilized Hyperbolic tangent activation function. The Hyperbolic tangent activation function is written as follows: Where i h refers to the local field of the network. The Hyperbolic tangent can act as an efficient squashing function for local field and produce a well-defined output (between 1 and -1). In addition, the usage of activation function is to avoid the network from collapse into a simple linear function [21].

V. IMPleMenTATIon
The simulations for HNN-MAXkSATGA and HNN-MAXkSATES were executed on Microsoft Visual C++ 2013 for Windows 10. Firstly, the restricted MAX-kSAT clauses were generated randomly. After that, the initial states for the neurons were initialized in the MAX-kSAT clauses. The network evolved until it reached the final state. Once the program had reached the final state, the neuron state was updated via equation (7). As soon as the network relaxed via equation (14), the final state obtained. Furthermore, if the state had remained unaffected for five runs, neurons achieved stable states. Hence, by permitting an ANN to evolve, sooner or later, shall lead to a stable state where the energy function obtained would not change further. Subsequently, the corresponding final energy for the stable state was calculated. If the difference between the final energy and the global minimum energy is within the tolerance value, the solution would be considered as a global solution. Both algorithms were repeated 100 times with 100 neuron combinations. The termination criteria for the final energy was 0.001. Sathasivam et al. [11] highlighted the fact that 0.001 was selected as the termination criteria because it could minimize the statistical errors. The analysis will involve the global minima ratio, ratio of satisfied clause, fitness landscape value, Hamming distance and computation time as the performance measure and indicator.

A. Global Minima Ratio
Global minima ratio is defined as the ratio between the global solutions over total number of runs [18]. Each simulation will produce 10000 bit strings solutions. 0.9524 global minima ratio value shows 9524 bit strings are global minimum and 476 bit strings are local minimum.    [18], if the global minima ratio of the proposed network close to one, almost all solutions in the network reached global minimum energy (global solution). HNN-kMAXGA is able to recall more correct states compared to HNN-MAX-kSATES. The limit for HNN-MAX-kSATES is 60 neurons. After 60 neurons, the network in HNN-MAX-kSATES trapped in trial and error state and consume more time to find the solution. On contrary, HNN-kMAXGA is able to withstand number of neurons up to 70 neurons. Genetic algorithm is proven to reduce the complexity of the searching technique. Unsatisfied bit string can be improved through the crossover among the best offspring (highest fitness). The bit strings are expected to improve in term of fitness (satisfied clauses) as the number of generation increased. As a result, the bit string produced by genetic algorithm achieved global minima compared to traditional exhaustive search method.
Mutation in genetic algorithm was added to reduce the chances for the bit string to reach local maxima (non-improving solution) [22,23]. Besides, less complexity during searching can gives more time for the network to relax. Effective relaxation will reduce the number of suboptimal solution during the computation [14].

B. Ratio of Satisfied Clauses
Ratio of satisfied clauses can be defined as the total number of satisfied clauses over the total number of clauses [24] Table 4 depicts the ratio of the satisfied clauses over total clause obtained HNN-MAX2SATGA, HNN-MAX2SATES and HNN-MAX3SATGA, HNN-MAX3SATES. In maximum satisfiability problem, MAX-2SAT and MAX-3SAT clauses will never be fully satisfied. We can further deduce that, the higher the ratio obtained, the more clauses will be satisfied in any MAX-kSAT problem. According to Table 4, HNN-MAXkSATGA is proven to obtain more satisfied clauses in MAX-kSAT compared to traditional exhaustive search method. As the number of neurons increased, the HNN-MAXkSATGA is still able to maintain the quality of the ratio. On the other hand, HNN-MAXkSATES will produce a lower ratio of satisfied clauses since most of the solution obtained trapped at suboptimal solution (local minima).

C. Fitness Energy Landscape Value
Fitness energy landscape value is associated with each point according to the pattern storing capability. Since Hopfield network concern about the ruggedness of the energy model, the fitness energy landscape must be taken into account. The fitness energy landscape value is based on Kauffman's model [25]. Figure 4 and 5 depicts the fitness energy landscape value obtained for HNN-MAXkSATGA and HNN-MAXkSATES. As observed, the difference in energy for HNN-MAXkSATGA is almost flat (zero) compared to HNN-MAXkSATES. MAX-kSAT clauses is always related to the ruggedness of the energy landscape. The more rugged the energy landscape, the harder it will to obtain good solution [26]. Since the complexity of the solution searching has been reduce drastically by genetic algorithm in HNN-MAXkSATGA, more relaxation time was added before the network retrieve the final states. As a result, HNN-MAXkSATGA has a greater capability to store MAXkSAT pattern compared to HNN-MAXkSATES. Hence, more global minimum energy produced.

D. Hamming Distance
Hamming distance is demarcated as the number of positions at which the corresponding binary values between two strings are different. In our context, Hamming distance measures the closeness of bits between the stable state and the global state of the neurons upon relaxation process [14].  This is due to the power of GA in ascertaining the satisfied clause, especially during the crossover stage where the clause was being improved by certain rate to achieve the highest fitness value. Additionally, HNN-MAXkSATGA would be able to recall the correct states that contributed to the lower hamming distance. Conversely, the exhaustive search algorithm emphasized the trial and error process during clause satisfaction process. When the complexity increased, HNN-MAXkSATES were able to sustain up to 60 neurons and HNN-MAXkSATGA with the limitation until 70 neurons. The main reason is due to the nature of exhaustive search that increased the computation burden to get correct neuron states. Hence, the ability to sustain huge number of neurons is due to the special ability of GA that reduces the computation burden in hunting the correct states.

E. Computation Time
The computation time is an important measure or indicator to analyze the performance of our proposed algorithm. According to our exploration context, the computation time can be delineated as the expanse of time for which our network was used to complete the whole computation process [6,13]. The computation process involves the training and generating the maximum satisfied clauses via our proposed paradigm [14].  A nearer look at the running time indicates as the network become more complex, more computation time are needed to generate the global solutions. Since we deal with MAX-2SAT and MAX-3SAT clauses, the training process consumes more time to minimize the logical inconsistencies than the randomized k-SAT problem. For instance, as the number of neuron increased, the computation time taken to generate the maximum number of clauses also increased. This is due to the fact that maximum k-satisfiability problem will never be fully satisfied, but we can possibly calculate the maximum number of clauses that will be satisfied. Hence, the states retrieved from the network can improve the global solutions that maximize the number of satisfied clauses. Thus, the whole process incurs more computation time. Generally, MAX-3SAT requires more time than MAX-2SAT due to complexity as the number of literals entrenched in the formula also higher.
According to Table 6, HNN-MAX2SATGA and HNN-MAX3SATGA require less computation time compared to the other counterparts, HNN-MAX2SATES and HNN-MAX3SATES. The undoubted evidence beyond that results are due to more neurons being forced to jump the energy barrier to relax into global solutions during the training process [14]. Additionally, the training process by using exhaustive search requires more computational time due to the trial and error process in hunting the maximum number of satisfied assignments. One of the important fact is for the maximum satisfiability problem, MAX-2SAT and MAX-3SAT clauses are never be satisfied 100%. On the contrary, when we implemented genetic algorithm, the computation time was faster due to the crossover and mutation process that speed up the training process. This is due to the fact that the unsatisfied bit string can be enhanced through the crossover among the finest offspring. The mutation process can avoid the bit string to achieve local minima. Hence, the bit string created by genetic algorithm achieved global minima swiftly compared to traditional exhaustive search method.

VII. conclusIon
Inspired by the Darwin's survival of the fittest theory together with biological genetic operators and engaging concept in artificial intelligence, a hybrid paradigm had been proposed. We had successfully develop a network by using genetic algorithm incorporated with Hopfield neural network in performing restricted maximum k-satisfiability logic programming (HNN-MAXkSATGA). The proposed model, later, was compared with a conventional technique; ES with Hopfield neural network (HNN-MAXkSATES). The work, reported in this paper, revealed decent performances of HNN-MAXkSATGA in terms of the global minima ratio, ratio of satisfied clause, Hamming distance, fitness landscape value and the compuatation time. According to the experimental results, the HNN-MAXkSATGA outperformed HNN-MAXkSATES in all of those measures. In addition, the proposed framework provides solid platform for evaluating various type of satisfiability problem. Our future work revolves on the robustness of other metaheuristic technique to solve restricted maximum k-satisfiability problem.