A Memetic Algorithm with a Novel Repair Heuristic for the Multiple-Choice Multidimensional Knapsack Problem

: We propose a memetic algorithm for the multiple-choice multidimensional knapsack problem (MMKP). In this study, we focus on ﬁnding good solutions for the MMKP instances, for which feasible solutions rarely exist. To ﬁnd good feasible solutions, we introduce a novel repair heuristic based on the tendency function and a genetic search for the function approximation. Even when the density of feasible solutions over the entire solution space is very low, the proposed repair heuristic could successfully change infeasible solutions into feasible ones. Based on the proposed repair heuristic and effective local search, we designed a memetic algorithm that performs well on problem instances with a low density of feasible solutions. By performing experiments, we could show the superiority of our method compared with previous genetic algorithms.


Introduction
The 0-1 knapsack problem (KP) aims to pick up items for a knapsack to maximize the profit sum of the selected items, as long as the weight sum of the selected items does not exceed the weight capacity b of the knapsack. In formal notation, the KP aims to maximize ∑ n i=1 v i x i subject to ∑ n i=1 w i x i ≤ b, where n is the number of items, v i is the profit of the i-th item, w i is the weight of the i-th item and x i ∈ {0, 1}. The multiple-choice multidimensional knapsack problem (MMKP) is a variant of the knapsack problem with multiple capacity constraints and multiple-choice conditions [1]. In MMKP, there are n classes of items. For class i, there are r i items, and each item j has a non-negative profit value of v ij , a non-negative weight vector of w ij = (w 1 ij , w 2 ij , . . . , w m ij ), and b k is the k-th weight capacity of the knapsack (k = 1, 2, . . . , m), where m is the number of capacity constraints. The formal definition of the MMKP is described as follows [1]: x ij = 1 for i ∈ {1, 2, . . . , n}, and x ij ∈ {0, 1} for i ∈ {1, 2, . . . , n} and j ∈ {1, 2, . . . , r i }.
In the MMKP, only one item can be selected from each class. When the j-th item in the i-th class is added to the knapsack, x ij becomes 1, and for the other j's, x ij is 0. The objective of the MMKP is to maximize the profit sum of the selected items satisfying the capacity constraints. The MMKP has various real-world applications such as the redundancy allocation problem for series-parallel systems [2], quality adaptation and admission control in multimedia services [3], quality-of-service problem for systems that must satisfy multiple requirements [4], and joint resource allocation and routing scheme in networks with cooperative relays [5,6]. A large number of other resource allocation problems can also be transformed into MMKPs. The readers can refer to [7] for more details.
When the constraints of the MMKP are strong, it is very hard to even find feasible solutions. For these kinds of problems to which feasible solutions that satisfy the constraints are difficult to find, applying repair methods can be effective.
Repair methods generally mean strategies that change infeasible solutions into feasible ones under evolutionary computation frameworks. There have been many studies related to various repair strategies [41][42][43][44][45]. In this study, a novel repair heuristic based on the tendency function and an effective memetic algorithm (a memetic algorithm is an extension of the traditional genetic algorithm using a local search technique [46]) are proposed for the MMKP. We propose a repair heuristic that uses a genetic algorithm which differs from a memetic algorithm for solving MMKP and the tendency function. The tendency function is a function specifically designed to suit the characteristics of MMKP for the proposed repair heuristic, and it is defined as one of the main parts of our repair heuristic. It is used for transforming infeasible solutions into feasible ones, and uses tendency parameters to analyze the solution space of the given instance. A genetic algorithm is adopted to attain optimal tendency parameters. Our memetic algorithm combined with the repair heuristic searches both the feasible solution space and the infeasible one. Experimental results demonstrate that our memetic approach performs better than previous genetic algorithms.
The remainder of this paper is organized as follows. Section 2 presents related work based on genetic algorithms. We propose the tendency function and a repair heuristic derived from it in Section 3. Section 4 describes our memetic algorithm combined with the repair heuristic. Experimental results are given in Section 5. Finally, conclusions are presented in Section 6.

Related Work
Parra-Hernandez and Dimopoulos [7] insisted that most heuristic algorithms, Lagrangian relaxation, branch-and-bound methods, and guided local searches for the MMKP have two defects: first, when the constraints of the MMKP are relatively strong, heuristic algorithms easily return local optima and may occasionally not find feasible solutions; second, the time costs needed by these algorithms are quite large.
In this study, we focused on the first problem. A genetic algorithm (GA) [47], which is a global search method based on natural selection, can effectively escape local optima. There have been many GAs for the KP and MKP but only three studies for the MMKP. Liu [48] proposed a simple GA for the MMKP, Rasmy et al. [34] applied various mutation operators over a simple GA, and Zhou and Luo [49] proposed a GA based on multiple populations (MPGA). The above GAs attempted to find good feasible solutions that satisfied the constraints of the MMKP [7]. However, GAs can only find good feasible solutions when the constraints of the MMKP are weak. The MPGA attempted to resolve this problem through multiple populations, which consists of separate populations of feasible solutions and infeasible ones. This could find good feasible solutions even under strong MMKP constraints.
In this paper, the tendency function, repair heuristic, and memetic algorithm are introduced to solve the MMKP. Our repair heuristic searches the solution space and then finds appropriate repair rules for transforming infeasible solutions to feasible ones. Our memetic algorithm attempts to improve the quality of feasible solutions using a repair heuristic. In the next section, the tendency function and repair heuristic derived from the function are described in detail.

Tendency Function and Repair Heuristic Algorithm
We present a constructive procedure (CP) to find a feasible solution for the MMKP which considers the violating amount ∆w k . The initial solution is generated by choosing the most valuable item from each class. The solution is selected considering no constraints, so it can be infeasible. That is, for some ks, the constraint ∑ n i=1 ∑ r i j=1 w k ij x ij ≤ b k may not be satisfied. ∆w k means the violating amount of the k-th constraint, ∑ n i=1 ∑ r i j=1 w k ij x ij − b k . The procedure attempts to reduce ∆w k by changing an item in the most suitable dimension k [1]. If ∆w k is negative or equal to zero for every k, the solution is feasible. CP is described by the steps of Algorithm 1 [7]. This greedy procedure attempts to repair the most violated dimension k 0 which makes ∆w k the largest.
In general, CP finds a feasible solution when the density of the feasible solution is high (Figure 1), but it tends to suffer when the solution space is randomly created and there is no tendency, which means that the density of the feasible solutions is very low. Hence, we designed a more sophisticated repair heuristic using a new tendency utility function concept. Instead of focusing on the most violated dimension, this method tries to find the most suitable class and item to change. Suppose that there is such a function that tells us which class and item pair has the largest tendency to make an given solution feasible when the solution is changed with them. We devised a kind of function, the tendency utility function described in Algorithm 2. It has six parameters which in this study are referred to as tendency parameters. Tendency parameters can be considered as the weights of changing the status of the dimension and the tendency utility can be considered as the weighted sum of these tendency parameters. It is assumed that the appropriate values of tendency parameters are previously determined before calculating the value of the tendency utility function. We cannot just obtain the appropriate values of tendency parameters without analysis, so we also designed a genetic algorithm for finding the appropriate values of tendency parameters. This genetic algorithm is different from a memetic algorithm for solving the MMKP, which is subsequently described in Section 4.
Using tendency utility function and tendency parameters, we designed a repair heuristic based on the tendency function (RHTF). Algorithm 3 shows the steps of the RHTF. If appropriate values for tendency parameters are previously obtained and the corresponding tendency utility function is well defined, RHTF attempts to maximize the tendency utility by changing an item. This process is repeatedly applied to attain a feasible solution. A high tendency utility increases the probability of success in repairing infeasible solutions. RHTF repeatedly applies the tendency function described in Algorithm 3 to attain a feasible solution. The tendency function is also used to define a fitness function in our genetic approximation of the tendency function and works as a repair method in our memetic algorithm.

Algorithm 1
The constructive procedure (CP) for finding a feasible solution.
procedure CP(an instance of the MMKP) the accumulated resources for constraint k Change an item in s that makes the tendency utility the best.

Genetic Approximation of Tendency Function
A genetic approximation of the tendency function (GATF) was designed to provide the optimal tendency parameters to RHTF, which searches the repair rules to find feasible solutions. The GATF provides optimal tendency parameters to the tendency utility function described in the above subsection and our memetic algorithm, which is described later. It uses the RHTF to define a fitness function for optimizing the tendency parameters. We describe the proposed GATF in Algorithm 4.

Algorithm 4
The pseudo-code of our genetic approximation of the tendency function: GATF.

procedure GATF(given solution s)
Randomly create initial population for tendency parameters; while stop condition is met do Choose parent 1 and parent 2 from population by proportional selection; Make offspring by recombining parent 1 and parent 2 using uniform crossover; Mutate offspring by swapping randomly chosen two genes; Get the feasibility of offspring from RHTF(offspring, given solution s) in Algorithm 3; Replace an individual in the population with offspring; end while end procedure • Representation: we represent a solution using a six-integer array since the objective of GATF is to find the appropriate values of six tendency parameters. Array cells correspond to mmi, mmd, ppi, ppd, mp, and pm, which are the members of tendency parameters in Algorithm 2. • Crossover: we used a uniform crossover method [50]. Each member of the tendency parameters is completely independent, and hence, the crossover is performed regardless of gene positions. • Mutation: Two randomly chosen genes among the six genes are swapped. • Fitness: we determine the fitness of a chromosome by examining the degree of changing infeasible solutions to feasible ones by applying the RHTF using the tendency parameters, which are the values of the given chromosome. For a chromosome, we set its fitness value to the repair success rate (i.e., #success #trials ).

Memetic Algorithm for the MMKP
In this section, we propose a memetic algorithm for the MMKP (MAMMKP). Algorithm 5 shows the template of our memetic algorithm.

Algorithm 5
The pseudo-code of our memetic algorithm for the MMKP: MAMMKP.

procedure MAMMKP
Randomly create initial population; while stop condition is met do Choose parent 1 and parent 2 from population by proportional selection; Make offspring by recombining parent 1 and parent 2 using multi-cut circular crossover; Mutate offspring by changing randomly chosen t genes; After all the possible combinations are verified, the best solution among them is recorded. The verification is performed for all three-class combinations, the best three-class combination (s 0 , t 0 , u 0 ) is chosen, and the items of these three classes I s 0 , I t 0 , and I u 0 are replaced by the best values. After determining the optimal values of I s 0 , I t 0 , and I u 0 , the algorithm considers three-class combinations out of the remaining classes except (s 0 , t 0 , u 0 ) again. This process continues until there are no more than three classes left to consider.
Although the proposed local optimization algorithm considers three-class combinations, better solutions can be obtained by considering four-class combinations or five-class combinations. The more combinations are considered, the more areas of the solution space are searched, and consequently, the probability of finding better solutions increases. However, verifying all the possible four-class or five-class combinations takes an excessive amount of time. The complexity of the proposed 3-Opt local optimization process has an upper bound O(( n 3 ) × r 3 × n 3 ), where r is the maximum of the r i 's, since there are ( n 3 ) three-class combinations, each of which has at most r 3 alternative choices, and the number of iterations is less than n 3 . Similarly, the upper bound of the complexity of the 4-Opt local optimization is O(( n 4 ) × r 4 × n 4 ), and it is too costly. Hence, we adopted 3-Opt local optimization in this study, considering the balance between time and solution quality.

•
Representation: a solution is represented by a length-n integer array. The i-th gene means the index of the i-th class item. • Crossover: a simple multi-cut circular crossover is adopted.
• Mutation: t genes are randomly changed. The value of t is limited to five or less. • Repair: we presented a repair heuristic with a tendency function approximated by GATF in Section 3. We repair infeasible solutions using the proposed repair heuristic. • Fitness: if a given solution is feasible, its fitness value is obtained by computing the objective value of the MMKP. However, if a feasible solution is not obtained from the repair heuristic, the fitness value is set to − 1 m ∑ m k=1 w k b k , where m is the number of constraints, and w k indicates the weight sum of the selected items on the k-th resource constraint. Unlike the previous method [49], in the case of a violation, we made the fitness value negative. As this method, strategies to give penalty to infeasible solutions have generally been used to deal with infeasible solutions in GAs [52][53][54]. The method makes the fitness value of an infeasible solution always smaller than the fitness value of a feasible one. According to the proposed fitness function, the greater the number of violated constraints is and the greater the degree of violation is, the smaller the fitness value is. This increases the probability of selecting a feasible solution with a positive fitness value and reduces the probability of selecting an infeasible solution with a negative fitness value. By doing this, we can maintain consistency that the solution with a larger fitness value is always superior to that with a smaller fitness value. This method is also useful for dealing with two different kinds of solutions (feasible solutions and infeasible ones) in a population.
• Replacement: RHTF is most likely to find feasible solutions from infeasible ones even if the density of feasible solutions is very low. However, as shown in Figure 2, the success rate decreases as the density of feasible solutions decreases. When the RHTF fails to repair infeasible solutions, GATF attempts to transform infeasible solutions into feasible ones. Zhou [49] and Htiouech et al. [17] demonstrated that searching both feasible and infeasible solution spaces is necessary for the global optimum. In addition, we do not remove infeasible solutions from the population. Instead of a multi-population, we use the fitness value for a single population that we previously introduced. Therefore, the population is only changed by the fitness values, regardless of the feasibility of the solutions. This is possible because the fitness values of infeasible solutions are always negative. However, if the whole population is filled with feasible solutions, the memetic algorithm may lose the possibility of the performance improvement with the help of infeasible solutions, as we can see in the previous method [49]. To avoid premature convergence, we used a generational GA. The remaining 70% of individuals in the population, except for the top 30%, were replaced with new solutions. By this replacement, the memetic algorithm can avoid falling into local optima.

Experimental Settings
For performance comparison, we tested all the problem instances used in [49]. These are three difficult test instances of mknapcb7, mknapcb8, and mknapcb9 provided by the OR library [55]. We conducted experiments with various constraint strength values [7] from 0.72 to 0.90. First, we investigated the density of feasible solutions by counting the number of feasible solutions among 10 6 randomly generated solutions. Figure 2 shows the results for the problem instance mknapcb8. The smaller the constraint strength value is, the lower the density of feasible solutions. If the f value (constraint strength) is smaller than 0.83, the probability that a given solution is feasible becomes almost zero.
Second, we compared the performances of CP and RHTF by counting the number of cases in which infeasible solutions are changed to feasible ones among 10,000 trials. However, we note that the input of CP was originally the set of the most valuable items in the classes; however, in this MMKP instance, the values are not concerned with weights. Therefore, we input randomly created infeasible solutions. Figure 1 shows the results for the problem instance mknapcb8. In this figure, we can see that the proposed repair heuristic based on the tendency function (RHTF) performs better than the CP. In particular, when the f value is smaller than 0.8, the CP rarely finds feasible solutions, while RHTF performs well, showing relatively high success rates.
The population size and the number of generations in our GA for the approximation of the tendency function (GATF) were set to 30 and 300, respectively. In the GA, the number of feasible solutions for obtaining the fitness of a solution (tendency parameter) was set to 30. The maximum number of iterations of the tendency function in the RHTF was also set to 30.
Our code is written in C++ and ran on Linux Ubuntu 18.04.6 using the CPU of AMD Ryzen Threadripper 2990WX (32-Core) Processor 3.0 GHz and the memory of 64 GB.

Performance of the RHTF
The results comparing the CP and RHTF is given in Figure 1. This shows that the RHTF is more powerful than the CP in almost all f s. When the density of feasible solutions is below 3%, the CP fails but RHTF creates feasible solutions with a success rate of approximately 95%. Even when the density of feasible solutions is extremely low ( f is 0.75), RHTF transforms infeasible solutions into feasible ones with a success rate of nearly 40%.

Performance of the MAMMKP
We compared MAMMKP with three state-of-the-art methods, HMMKP, LGA, and MPGA, previously proposed in other studies. The experimental results of HMMKP, LGA, and MPGA are obtained from [7,48,49], respectively. In MAMMKP, the population size and number of generations were set to 200 and 500, respectively. MAMMKP terminates when 70% of the top 30% of individuals in the population are the same. For each test instance, three or four different values of f were set-where f represents the constraint strength [7].
The experimental results are given in Tables 1-3. Among the results of HMMKP, LGA, and MPGA marked "N/A", this indicates that the corresponding experiment was not tested in previous studies and has no results. Among the previous three methods, HMMKP, LGA, and MPGA, MPGA had the best performance. The average results of MPGA were better than the results of HMMKP. From the results of these tables, it is also observed that MAMMKP outperformed HMMKP for all test cases. This means that MAMMKP showed a better performance than HMMKP, regardless of the number of classes, the number of dimensions, and f values. MAMMKP also showed better results than LGA and MPGA in the minimum and average values for all test cases. In particular, it showed f values of 0.75 and 0.73 on mknapcb8 and mknapcb9, respectively, which are the most difficult test cases in our experiments; thus, MAMMKP showed better results than MPGA in terms of the minimum, average, and maximum values. Furthermore, on mknapcb9 with an f value of 0.72, MPGA could not find feasible solutions, while MAMMKP always obtained feasible ones. We also conducted t-tests to compare the performances of MAMMKP and MPGA. The average results for the problem instance mknapcb7, mknapcb8, and mknapcb9 have p-values of 4.56 × 10 −5 , 1.28 × 10 −6 , and 4.11 × 10 −8 , respectively, by the t-tests. That is, the performance of MAMMKP is significantly better than that of MPGA for the three problem instances. It is also observed that the p-value decreases as the instance number increases. This means that the more difficult the problem is, the better the performance of the MAMMKP compared to the MPGA is.

Concluding Remarks
When there is no concern between THE value and weight in the MMKP, it becomes a very difficult NP-hard problem. However, even on a random solution space, we could show that some repair rules for finding feasible solutions do exist. We could also demonstrate that the proposed method performed well not only in terms of finding the global optimum but also in adapting to the (feasible) solution space. We showed that our single-population GA (MAMMKP) successfully simulated the multi-population GA (MPGA) of [49] and MAMMKP performed better than MPGA.
In this study, a repair heuristic based on a tendency function was designed with human experience through experiments based on genetic algorithms. To improve the tendency function, it would be valuable to gather more information for finding repair rules from not only human experience but also analyzing the MMKP raw dataset. We left the study for designing a more sophisticated tendency function to future work. We also expect that some advanced techniques related to genetic algorithms, such as normalization based on gene similarity [56] and the basis change of binary encoding [57,58], can be adopted to solve this problem.

Institutional Review Board Statement: Not applicable.
Informed Consent Statement: Not applicable.

Data Availability Statement:
The data presented in this study are openly available in the OR library [55].

Conflicts of Interest:
The authors declare no conflict of interest.