The 0/1 multidimensional knapsack problem is the 0/1 knapsack problem with m constraints which makes it difficult to solve using traditional methods like dynamic programming or branch and bound algorithms. We present a genetic algorithm for the multidimensional knapsack problem with Java and C++ code that is able to solve publicly available instances in a very short computational duration. Our algorithm uses iteratively computed Lagrangian multipliers as constraint weights to augment the greedy algorithm for the multidimensional knapsack problem and uses that information in a greedy crossover in a genetic algorithm. The algorithm uses several other hyperparameters which can be set in the code to control convergence. Our algorithm improves upon the algorithm by Chu and Beasley in that it converges to optimum or near optimum solutions much faster.
Deep Dive into Genetic Algorithm for the 0/1 Multidimensional Knapsack Problem.
The 0/1 multidimensional knapsack problem is the 0/1 knapsack problem with m constraints which makes it difficult to solve using traditional methods like dynamic programming or branch and bound algorithms. We present a genetic algorithm for the multidimensional knapsack problem with Java and C++ code that is able to solve publicly available instances in a very short computational duration. Our algorithm uses iteratively computed Lagrangian multipliers as constraint weights to augment the greedy algorithm for the multidimensional knapsack problem and uses that information in a greedy crossover in a genetic algorithm. The algorithm uses several other hyperparameters which can be set in the code to control convergence. Our algorithm improves upon the algorithm by Chu and Beasley in that it converges to optimum or near optimum solutions much faster.
Solving the multidimensional knapsack problem using branch and bound or dynamic programming is difficult. Because of the multiple constraints, it is also difficult to obtain a good approximation to the solution such as a greedy algorithm. However, it is possible to use the greedy algorithm as part of a genetic algorithm, and our results show that it works really well. Not only is our algorithm able to exceed the greedy estimate, but for most problem instances, it is able to find the optimum solution. Our algorithm is similar to [2] which uses greedy crossover for the 0/1 knapsack problem. Since the multidimensional knapsack problem has multiple constraints, we assign a weight to each constraint using iteratively computed Lagrangian multipliers. This is similar to the approach in [1] which uses surrogate multipliers. The difference is that we use the multipliers in a greedy crossover which is highly constructive and can find optimum solutions much quicker.
The 0/1 multidimensional knapsack problem is the 0/1 knapsack problem with m constraints which makes it difficult to solve using traditional methods. The 0/1 multidimensional knapsack problem can be stated as: Given n objects each with a value and m constraints (or knapsacks) each with a capacity constraint , maximize the value such that each of the m constraints are satisfied. Each of the m constraints have i weights associated with it. This makes it a general 0/1 integer programming problem.
Such that: , j: 1…m
Our algorithm generates the initial population with the probability of choosing an object 0.5. In a problem with n objects, are chosen on an average. The higher this probability, the faster the algorithm converges; however,
/ n the higher this probability, the more are the chances that the algorithm will converge around the greedy estimate. This way of generating the initial population introduces a lot of invalid solutions (noise) into the population. (Strategies for initial population generation are discussed in [5]). To compensate for invalid solutions, we investigated the use of a highly constructive greedy crossover. The greedy crossover takes the objects with the best utility ratio from parents and constructs one offspring such that it is always a valid solution.
We use Lagrangian multipliers to augment the utility ratio for the multidimensional knapsack problem according to the following steps:
For each object and for each constraint (for that object) the weight (constraint) value is multiplied with the corresponding Lagrangian multiplier and the sum of these values is obtained.
The value obtained in step 1 is then divided by the number of constraints (optional step).
Then, the ratio of the value (profit) and the value obtained in step 2 is obtained which is the profit-weight ratio for that object
Where is the j th Lagrangian multiplier and m is the number of constraints. The greedy crossover simply takes objects from the two parents in non-increasing order of the ratio and constructs one offspring such that it satisfies all constraints.
Our code is written in Java and C++. Any JDK compiler and gcc should work. Benchmark instances that we use in this paper are available at [3]. Our code is available at [4]. Also see [8]. The code requires a data.DAT file in the directory in which the executable resides. Change Constants.java to increase or decrease the number of generations (Constants.GENERATIONS). Change the data file name in Constants.java to use some other Weing/Weish/Sento file. Change the DataProcessor in GeneticAlgorithm.java to ORLIB if required.
We ran our algorithm in publicly available instances. Some results are shown below. More results are available in our git repository [4]. Our algorithm is able to solve most instances completely, reaching the global optimum. m is the number of constraints and n is the number of objects.
Our algorithm can be applied to any 0/1 integer programming problem and the utility ratio is general enough for most types of inequality constraints. We haven’t tried running our algorithm in equality constraints though it should be trivial. Our algorithm is fast and can find optimum solutions quite fast. Instances with larger number of objects are shown in our git repository [4] [8].
Traditional evolutionary algorithms are more suitable for problems in which domain specific knowledge is not available. For problems with partial knowledge of the domain, a genetic algorithm, which uses this domain knowledge, is more likely to succeed, as the results clearly indicate. A good search algorithm should be global in nature with a heuristic introduced to give constructive direction to the algorithm. We introduced a new technique of greedy crossover; it forms the core of our genetic algorithm. As table-1 shows, our algorithm is able to solve to optimality, all of the instances in a short amount of time. Some problems like Weing7 are harder. Future work could be to run the algorithm on larger instan
…(Full text truncated)…
This content is AI-processed based on ArXiv data.