This article was automatically translated from the original Turkish version.

Yapay zeka ile oluşturulmuştur.
The knapsack problem is a classic combinatorial optimization problem that models decision-making processes aimed at maximizing benefit under limited resources. It derives its name from the metaphor of packing the most valuable items into a bag with a fixed carrying capacity. The problem first gained attention in 1957 through the work of M. D. Weingartner and was later formalized mathematically in the 1960s through research by George Dantzig on linear programming.
The knapsack problem involves determining which items from a set of various weights and values should be placed in a bag with a specific capacity. The objective is to maximize the total value of the selected items while ensuring that their combined weight does not exceed the bag’s capacity. This fundamental structure aligns with numerous real-world decision problems that seek optimal benefit under constrained resources.
The 0/1 knapsack problem can be formulated as follows:
Although the knapsack problem can be introduced with a simple example, it is a complex problem that embodies a deep decision-making process. Today it is used not only theoretically but also to generate solutions for diverse real-world problems across many sectors: from financial investment decisions to warehouse location planning, personnel assignment to transportation optimization.
Thanks to integration with artificial intelligence, genetic algorithms now enable this problem to be solved more efficiently and rapidly. Moreover, they can handle not only the classical version but also more complex variants with additional constraints such as “forfeit.” In particular, machine learning–enhanced approaches do not merely produce a solution but also improve the efficiency of the solution process over time, offering novel and creative solutions through learning systems.
These advancements demonstrate that the knapsack problem remains a current and dynamic research topic, especially as artificial intelligence techniques are applied to broader domains. In the future, more flexible, adaptive, and industry-specific solutions for this problem are expected. The knapsack problem is not merely an algorithmic challenge; it is the universal counterpart to the question: “How do we make the right decision with limited resources?”
Genetic algorithms (GA), developed within the discipline of artificial intelligence, are widely and effectively used to solve combinatorial problems in the NP-hard class such as the knapsack problem. Genetic algorithms draw inspiration from biological evolutionary processes in nature, simulating mechanisms such as natural selection, crossover, and mutation to explore the solution space. For the knapsack problem, genetic algorithms are structured according to the following steps:
In the first step, a population is created consisting of random individuals representing potential solutions. Each individual is encoded as a binary genetic sequence, where each gene indicates whether an item is selected or not:
For example, the individual [1, 0, 1, 0, 1] indicates that the first, third, and fifth items are included in the knapsack.
The “fitness” of each individual, that is, the quality of the solution, is evaluated using a specific fitness function. This function typically represents the total value of the selected items. However, it also checks whether the total weight exceeds the predefined capacity:
This guides the algorithm toward generating valid solutions.
In the selection phase, individuals with higher fitness values are chosen from the current population to form the next generation. Methods such as roulette wheel selection and tournament selection may be employed. The goal is to transmit the genetic information of good solutions to subsequent generations.
Selected individuals are paired, and portions of their genetic information are exchanged to generate new individuals (i.e., new candidate solutions). The most commonly used crossover method is single-point crossover, in which the genetic sequence is split at a specific point and recombined between two parents to form new combinations.
Mutation is applied to maintain genetic diversity and prevent premature convergence to local optima. In this step, certain genes in some individuals are randomly flipped (e.g., 0 → 1 or 1 → 0). The mutation rate is kept low (typically between 1% and 5%), as a high mutation rate may cause the algorithm to behave randomly.
The above steps are repeated for a specified number of generations or until a stopping criterion is met. Possible stopping criteria include:
As a result of this process, an optimal or near-optimal solution is obtained.
The knapsack problem is not merely a theoretical mathematical exercise; it is a universal optimization framework that models how to make the most effective decisions under limited resources. By its very nature, it directly corresponds to decision-making scenarios across many industries that involve the trade-off between maximum benefit and constrained capacity. In this context, the application areas of the knapsack problem can be summarized as follows:
The knapsack problem is not merely an abstract mathematical formula; it is a universal decision-making framework that models how to make the most effective decisions under limited resources. Due to its relevance to fundamental decision processes such as resource allocation, selection optimization, and maximizing benefit under constrained capacity, it has a broad range of applications. Consequently, it is not only relevant in theoretical studies but also directly applicable across many sectors including manufacturing, finance, logistics, and energy.
Hassan, Omer Mohammed Salih, and Sagvan Ali Saleh. "Comprehensive Analysis of Recent Studies on Using Genetic Algorithms for Optimizing Solutions to the 0/1 Knapsack Problem." European Journal of Applied Science, Engineering and Technology 3, no. 2 (2025): 74-86. Accessed Adresi.
Murawski, Carsten, and Peter Bossaerts. "How humans solve complex problems: The case of the knapsack problem." *Scientific reports* 6, no. 1 (2016): 34851. Accessed Adresi.
Souto, Gabriel, Claudio Miceli, Luidi Simonetti, and Pedro Henrique González. "Machine Learning Assisted Hybrid Genetic Algorithm Applied to the Knapsack Problem with Forfeits." In *International Conference on Machine Learning (ICML)*. 2024. Accessed Adresi.
Zárate-Aranda, José Eduardo, and José C. Ortiz-Bayliss. "Machine-learning-based hyper-heuristics for solving the Knapsack Problem." *Pattern Recognition Letters* (2025). Accessed Adresi.

Yapay zeka ile oluşturulmuştur.
Problem Definition
Mathematical Formulation
Application of the Genetic Algorithm
Step 1: Initialization of the Population
Step 2: Evaluation of the Fitness Function
Step 3: Selection
Step 4: Crossover
Step 5: Mutation
Step 6: Iterative Loop and Stopping Criterion
Real-World Applications of the Knapsack Problem