Next Article in Journal
A Dempster–Shafer, Fusion-Based Approach for Malware Detection
Previous Article in Journal
Laplacian Conditions and Sphericity of Hypersurfaces in the Nearly Kähler 6-Sphere
Previous Article in Special Issue
Rethinking Metaheuristics: Unveiling the Myth of “Novelty” in Metaheuristic Algorithms
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

On Solving the Knapsack Problem with Conflicts

by
Roberto Montemanni
1,* and
Derek H. Smith
2
1
Department of Sciences and Methods for Engineering, University of Modena and Reggio Emilia, 42122 Reggio Emilia, Italy
2
Faculty of Computing, Engineering and Science, University of South Wales, Pontypridd CF37 1DL, UK
*
Author to whom correspondence should be addressed.
Mathematics 2025, 13(16), 2674; https://doi.org/10.3390/math13162674
Submission received: 18 July 2025 / Revised: 8 August 2025 / Accepted: 19 August 2025 / Published: 20 August 2025

Abstract

A variant of the well-known Knapsack Problem is studied in this paper. In the classic problem, a set of items is given, with each item characterized by a weight and a profit. A knapsack of a given capacity is provided, and the problem consists of selecting a subset of items such that the total weight does not exceed the capacity of the knapsack, while the total profit is maximized. In the variation considered in the present work, pairs of items are conflicting, and cannot be selected at the same time. The resulting problem, which can be used to model several real applications, is considerably harder to approach than the classic one. In this paper, we consider a mixed-integer linear program representing the problem and we solve it with a state-of-the-art black-box software. A vast experimental procedure on the instances available from the literature, and adopted in the last decade by the community, indicates that the approach we propose achieves results comparable with, and in many cases better than, those of state-of-the-art methods, notwithstanding that the latter are typically based on more complex and problem-specific ideas and algorithms than the idea we propose.

1. Introduction

The classic Knapsack Problem [1] consists of selecting items from a given set, where each item is associated with a profit and a weight, in such a way that the total weight of the objects selected is below a given threshold and the total profit is maximized. In this work a generalization of the problem, known as the Knapsack Problem with Conflicts (KPC), where pairs ( i , j ) of conflicting items are given, and for each pair at most one item can be part of the final solution. The capacity constraint and the objective remain unchanged.
The KPC arises as a subproblem in several algorithms in the Operations Research domain. For example, it is solved within branch-and-price methods for the Bin-Packing Problem [2] and the Bin-Packing Problem with Conflicts [3]. However, the KPC can be used to model in mathematical terms some real-world applications. For example, in the scheduling domain, where there are tasks that cannot be executed in parallel due to conflicting resources, the problem maps directly into a KPC.
The KPC was originally introduced in [4], where a local-search heuristic and a branch-and-bound method based on Lagrangian relaxation are discussed. In [5] the authors proposed some preprocessing techniques and a different branch-and-bound algorithm. Heuristic methods for the KPC were discussed in [6,7], the latter method being a matheuristic algorithm. Other metaheuristic approaches were finally presented in [8] (scatter search) and [9] (rounding heuristic). The KPC was proven to be NP -hard in [10], where some special cases solvable in polynomial time are also highlighted. Finally, a branch-and-bound exact method based on binary branching was proposed in [3], while another branch-and-bound schema based on an n-ary branching was developed and tested in [11].
In the literature of Graph Theory and Algorithms, several classic optimization problems have been studied in one or more variants involving conflict constraints, demonstrating an increasing popularity of the topic, motivated by the number of related real-world applications. For example, theoretical results, heuristics, and exact algorithms were proposed for the Assignment Problem with Conflicts [12,13,14,15,16]; for the Set-Covering Problem with Conflicts [17,18,19,20]; for the Spanning Tree Problem with Conflicts—The MSTC [12,21,22,23,24,25,26]; for the Shortest-Path Problem with Conflicts [27,28,29,30,31]; and for the Maximum-Flow Problem with Conflicts [32,33,34,35,36,37].
In this paper, a mixed-integer linear programming model for the KPC is considered and solved by the open-source solver CP-SAT, which is part of the Google OR-Tools [38] optimization suite. The aim of the work is to understand if mixed-integer linear programs purely characterized by binary variables (like the one we consider) can be efficiently attacked by a solver (CP-SAT) mainly based on logical reasoning and Lazy Clause Generation [39]. Notice that successful applications of this solver on different optimization problems have been recently proposed [37,40,41]. An extensive experimental campaign on the benchmark instances previously proposed in the recent literature is finally presented and discussed.
The implications of the work are twofold: first, from a theoretical point of view, it extends the understanding of the potentials of the CP-SAT solver on binary linear programming models; second, from a practical point of view, a new approach to attack the real applications that can be model as a KPC is proposed. This approach is simpler to implement than most of those that previously appeared in the literature, since it relies on a black-box solver.
The overall organization of the paper can be summarized as follows. The Knapsack Problem with Conflicts is formally defined in Section 2. Section 3 discusses a mixed-integer linear programming model to represent the problem. In Section 4, the performances of the model are evaluated experimentally on the benchmark instances adopted in the literature in the last decade. The approach we propose is thoughtfully compared with recent state-of-the-art methods from the literature. Conclusions are finally drawn in Section 5.

2. Formal Problem Description

The KPC can be formally defined as follows. Let G = ( V , E ) be a graph where each vertex i V is associated with an item, and each edge { i , j } E models a conflict between the items i and j of V. A profit p i and a weight w i are provided for each item i V , and a capacity c of the knapsack is provided. The aim of the problem is to select a subset S of the items of V such that the total weight of the items of S is not greater than c, and no conflict is violated, which means i , j S , { i , j } E , and the total profit of the selected items is maximized.
An example of a KPC instance and a related optimal solution are depicted in Figure 1.

3. A Mixed-Integer Linear Programming Model

In this section, a mixed-integer linear programming model for the KPC, inspired by that discussed in [3], is presented. Once the model is defined, it fully describes the original optimization problem, and can be solved by black-box solvers to obtain the optimal solution, or at least approximations for it in case the model is too complex.
A variable x i is defined for each item i V . It takes a value of 1 if the item i is selected, 0 otherwise. The optimization problem will therefore search for an assignment of the x variables that maximizes the profit of the selected items, while respecting all the operational constraints. The objective of the optimization and the constraints are formally described through the following model:
max i V p i x i
s . t . i V w i x i c
x i + x j 1 { i , j } E
x i { 0 , 1 }         j V
The objective function (1) imposes the maximization of the profit of the items selected. The operational constraints are imposed as flows. The inequalities (2) force the total weight of the selected items to be lower than or equal to the given capacity c. Observe that so far the model coincides with that of the classic Knapsack Problem. Inequalities (3) model the conflicts, imposing that at most one of a conflicting pair of items can be selected to be part of the solution. The latter constraints characterize the variant of the classic problem studied in the present work, and make the overall problem substantially more difficult from a computational point of view (see, for example, ref. [3]). To complete the formal model, the domain of the x variables has to be finally specified, and this is carried out in (4).

4. Computational Experiments

In Section 4.1, we describe the benchmark instances previously introduced in the literature for validating the algorithms presented in the last decade, and used for the present study. In Section 4.2, the approach we propose is compared from an experimental viewpoint against the other methods available in the literature, and positioned consequently.

4.1. Benchmark Instances

The first benchmark set adopted for the experiments was proposed in [3]. The instances are derived from those originally introduced in [42] for the Bin-Packing Problem. They consist of eight classes, each composed by 10 instances; in the first four classes, the items have weights that follow a uniform distribution in the range [ 20 , 100 ] and the capacity c is 150. The number n of items is 120, 250, 500, and 1000, respectively. The last four classes have weights sampled with a uniform distribution in the range [ 250 , 500 ] and a capacity of 1000. The instances have 60, 120, 349, and 501 items, respectively. A random conflict graph is generated for each instance, with density values in the range from 0.1 to 0.9, making a total of 90 instances for each class. A profit is associated with each item. Profits are either uniformly distributed in the interval [ 1 , 100 ] (R instances, random), or defined as p i = w i + 10 for each item i (C instances, correlated). Three copies of each instance are obtained by considering the original capacity ( C 1 , R 1 ), or a capacity obtained by multiplying the original one by 3 ( C 3 , R 3 ) or 10 ( C 10 , R 10 ). Overall, 4320 instances compose the first dataset.
The second group of instances—again first introduced in [3]—considers very sparse conflict graphs, with the densities 0.001, 0.002, 0.005 and 0.01. Capacities are either 1000 or 2000 and the number of items is 500 or 1000. Ten instances with random profits and ten with correlated profits were generated for each combination of parameters, for a total of 480 instances.
We refer the interested reader to [3] for a comprehensive description of the instances.

4.2. Experimental Results

The model discussed in Section 3 has been solved with the Google OR-Tools CP-SAT solver [38], version 9.12. The experiments have been run on a computer equipped with an Intel Core i7 12700F CPU. The experiments for the methods previously discussed in [3,11], and against which we compare, were run on an a machine equipped with an Intel Xeon CPU E5-2690, which according to [43] is approximately 10% slower than our machine. Moreover, in [11] the experiments were run on a single core, while we let the solver use all the potentialities of the processor. These two factors give an advantage to the approach we propose, although this will not change the outcome of the general experiments.
In details, the methods involved in the presented comparison are:
  • CFS: a combinatorial branch-and-bound algorithm, introduced in [11];
  • BCM: a branch-and-bound algorithm based on binary branching and a strong upper-bounding procedure, introduced in [3];
  • ILP: three integer linear programming models discussed in [11] and solved with ILOG CPLEX 12.8 [44]. For each dataset, the results of the best of the three models are presented (notice that this gives a clear theoretical advantage to the method);
  • CP-SAT: the mixed-integer linear program presented in Section 3 is solved with Google OR-Tools CP-SAT solver 9.12 [38].
Following the trend of the previous literature [3,11], all the methods considered were run for a maximum of 600 s on each instance. This allows for a fair comparison. We decided, however, to also consider longer runs of 3600 s on selected instances for CP-SAT, in order to better understand the behaviour of the solver and its potential. For each group of instances, the number of proven optimal solutions and the average time to find such optimal solutions are reported. For the method CP-SAT, the average optimality gap is also reported for the second benchmark set, in order to also measure the quality of the solutions when optimality could not be proven (this information was unfortunately not available for the other methods). Results in bold highlight improvements of CP-SAT over the state of the art.
The results on the first benchmark set are aggregated by class and type and presented in Table 1 (correlated instances) and Table 2 (random instances), and are aggregated by class and density in Table 3 (correlated instances) and Table 4 (random instances).
The results on the first benchmark set clearly highlight the superiority of the approach we propose, based on CP-SAT. The dominance does not appear to be affected by the details of the instances, and suggests that for these densities that are not in any non-extreme range, the CP-SAT solver firmly outperforms the others. It is the only method able to solve all the instances to optimality, and with computation times orders of magnitude lower than most of the competitors. It is worth observing that the ILP method seems to suffer more than the others when changing the types of instances. In particular, it faces trouble generally on instances of Type 3 and 4, especially for classes C10 and R10. When examining densities, once again problems seem to emerge for the ILP method, especially for values around 0.5, although the main issues seem to be related to class more than density.
The results on the second benchmark set are presented in Table 5 for the correlated instances and in Table 6 for the random instances, with data aggregated by items/capacity and density in both the tables. For these experiments, the results of CP-SAT are reported for both a maximum computation time of 600 and 3600 s.
The results on both correlated and random instances of the second benchmark set suggest that on these problems, characterized by extreme low densities of the conflict graph, the method we propose remains competitive but is slightly inferior to the ILP approach when a maximum computation time of 600 s is considered. We remind the reader, however, that in the ILP column, the best of three different models is reported. It appears that the most critical values of densities are those around 0.02 and 0.05 for all methods. Larger instances with higher capacities are, on the other hand, the most difficult ones for all the approaches, although ILP appears to undergo slightly less critical degradation than the others.
When a longer computation time of 3600 s is considered, CP-SAT enhances its results, showing results comparable to that collected under the ILP column (the best of the three models). This suggests that the approach we propose requires more time on the critical instances where the density of the conflicts is 0.02 or 0.05. For other problems [37], it has been previously observed that CP-SAT could be slower than other methods on the most difficult instances, and this might be motivated by the more complex logical inference associated with larger or more difficult instances. This behaviour appears to be confirmed for the KPC.
Concerning CP-SAT, the method we propose, it is worth observing that even when optimality is not proven, the gap at the end of the computation is always extremely low (apart from the largest instances with density 0.05), demonstrating the effectiveness of the approach.
In conclusion, CP-SAT performs better than the other methods on most of the instances, but under very particular settings such as instances with densities of 0.02 and 0.05, and large instances in general, its superiority vanishes in favor of ILP, probably also due to the slower convergence that appears to characterize CP-SAT.

5. Conclusions

The Knapsack Problem with Conflicts, a problem used to represent, directly or indirectly, several real-world applications, has been studied in this paper.
A formulation based on a mixed-integer linear formulation for the problem has been considered and solved via the open-source solver CP-SAT, part of the Google OR-Tools computational suite.
An extensive experimental procedure has been run to compare the new method with those already available in the literature, and the results indicate that the approach we propose achieves a performance comparable with, and often better than, those of the state-of-the-art solvers available in the literature. Several instances were closed for the first time in the present study, notwithstanding the several other exact approaches developed in the last decade for the problem. However, the approach we propose sometimes appears to converge slower than the best of the other methods. This is especially evident for the largest and most challenging instances.
Lastly, it is important to observe that the good performance of the new approach is achieved in spite of the substantially smaller implementation effort required for the solution we propose when compared with the more complex and problem-dependent methods that appear in the existing literature.

Author Contributions

Conceptualization, R.M. and D.H.S.; methodology, R.M.; software, R.M.; validation, R.M. and D.H.S.; formal analysis, R.M. and D.H.S.; investigation, R.M.; resources, R.M.; data curation, R.M.; writing—original draft preparation, R.M.; writing—review and editing, R.M. and D.H.S.; visualization, R.M. and D.H.S. All authors have read and agreed to the published version of the manuscript.

Funding

The work was partially supported by the Google Cloud Research Credits Program.

Data Availability Statement

The instances used for the experiments, originally introduced in [21,25], are available upon request to the corresponding author.

Acknowledgments

The authors have reviewed and edited the output and take full responsibility for the content of this publication.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Martello, S.; Toth, P. Knapsack Problems: Algorithms and Computer Implementations; John Wiley & Sons, Inc.: Hoboken, NJ, USA, 1990. [Google Scholar]
  2. Wei, L.; Luo, Z.; Baldacci, R.; Lim, A. A New Branch-and-Price-and-Cut Algorithm for One-Dimensional Bin-Packing Problems. INFORMS J. Comput. 2019, 32, 428–443. [Google Scholar] [CrossRef]
  3. Bettinelli, A.; Cacchiani, V.; Malaguti, E. A Branch-and-Bound Algorithm for the Knapsack Problem with Conflict Graph. INFORMS J. Comput. 2017, 29, 457–473. [Google Scholar] [CrossRef]
  4. Yamada, T.; Kataoka, S.; Watanabe, K. Heuristic and exact algorithms for the disjunctively constrained knapsack problem. INFORMS J. Comput. 2002, 43, 2864–2870. [Google Scholar]
  5. Hifi, M.; Michrafy, M. Reduction strategies and exact algorithms for the disjunctively constrained knapsack problem. Comput. Oper. Res. 2007, 34, 2657–2673. [Google Scholar] [CrossRef]
  6. Hifi, M.; Michrafy, M. A reactive local search-based algorithm for the disjunctively constrained knapsack problem. J. Oper. Res. Soc. 2006, 57, 718–726. [Google Scholar] [CrossRef]
  7. Akeb, H.; Hifi, M.; Ould Ahmed Mounir, M.E. Local branching-based algorithms for the disjunctively constrained knapsack problem. Comput. Ind. Eng. 2011, 60, 811–820. [Google Scholar] [CrossRef]
  8. Hifi, M.; Omani, N. An algorithm for the disjunctively constrained knapsack problem. Int. J. Oper. Res. 2012, 13, 22–43. [Google Scholar] [CrossRef]
  9. Hifi, M. An iterative rounding search-based algorithm for the disjunctively constrained knapsack problem. Eng. Optim. 2014, 46, 1109–1122. [Google Scholar] [CrossRef]
  10. Pferschy, U.; Schauer, J. The knapsack problem with conflict graphs. J. Graph Algorithms Appl. 2009, 2, 233–249. [Google Scholar] [CrossRef]
  11. Coniglio, S.; Furini, F.; San Segundo, P. A new combinatorial branch-and-bound algorithm for the Knapsack Problem with Conflicts. Eur. J. Oper. Res. 2021, 289, 435–455. [Google Scholar] [CrossRef]
  12. Darmann, A.; Pferschy, U.; Schauer, J.; Woeginger, G. Paths, trees and matchings under disjunctive constraints. Discret. Appl. Math. 2011, 16, 1726–1735. [Google Scholar] [CrossRef]
  13. Öncan, T.; Zhang, R.; Punnen, A.P. The minimum cost perfect matching problem with conflict pair constraints. Comput. Oper. Res. 2013, 40, 920–930. [Google Scholar] [CrossRef]
  14. Öncan, T.; Altınel, I.K. Iterated exact and heuristic algorithms for the minimum cost bipartite perfect matching problem with conflict constraints. In Proceedings of the 2017 IEEE International Conference on Industrial Engineering and Engineering Management (IEEM), Singapore, 10–13 December 2017; pp. 1032–1036. [Google Scholar]
  15. Öncan, T.; Altınel, I.K. A Branch-and-Bound Algorithm for the Minimum Cost Bipartite Perfect Matching Problem with Conflict Pair Constraints. Electron. Notes Discret. Math. 2018, 64, 5–14. [Google Scholar] [CrossRef]
  16. Öncan, T.; Şuvak, Z.; Akyüz, M.H.; Altınel, I.K. Assignment problem with conflicts. Comput. Oper. Res. 2019, 111, 214–229. [Google Scholar] [CrossRef]
  17. Carrabs, F.; Cerulli, R.; Mansini, R.; Moreschini, L.; Serra, D. Solving the Set Covering Problem with Conflicts on Sets: A new parallel GRASP. Comput. Oper. Res. 2024, 166, 106620. [Google Scholar] [CrossRef]
  18. Jacob, A.; Majumdar, D.; Raman, V. Parameterized complexity of conflict-free set cover. In Computer Science, Theory and Applications; Lecture Notes in Computer Science; Springer: Cham, Switzerland, 2019; Volume 11532, pp. 191–202. [Google Scholar] [CrossRef]
  19. Saffari, S.; Fathi, Y. Set covering problem with conflict constraints. Comput. Oper. Res. 2022, 143, 105763. [Google Scholar] [CrossRef]
  20. Banik, A.; Panolan, F.; Raman, V.; Sahlot, V.; Saurabh, S. Parameterized Complexity of Geometric Covering Problems Having Conflicts. Algorithmica 2020, 82, 1–19. [Google Scholar] [CrossRef]
  21. Zhang, R.; Kabadi, S.; Punnen, A. The minimum spanning tree problem with conflict constraints and its variations. Discret. Optim. 2011, 2, 191–205. [Google Scholar] [CrossRef]
  22. Samer, P.; Urrutia, S. A branch and cut algorithm for minimum spanning trees under conflict constraints. Optim. Lett. 2014, 1, 41–55. [Google Scholar] [CrossRef]
  23. Carrabs, F.; Cerrone, C.; Pentangelo, R. A multi-ethnic genetic approach for the minimum conflict weighted spanning tree problem. Networks 2019, 2, 134–147. [Google Scholar] [CrossRef]
  24. Carrabs, F.; Gaudioso, M. A Lagrangian approach for the minimum spanning tree problem with conflicting edge pairs. Networks 2021, 1, 32–45. [Google Scholar] [CrossRef]
  25. Carrabs, F.; Cerulli, R.; Pentangelo, R.; Raiconi, A. Minimum spanning tree with conflicting edge pairs: A branch-and-cut approach. Ann. Oper. Res. 2019, 298, 65–78. [Google Scholar] [CrossRef]
  26. Montemanni, R.; Smith, D. On Solving the Minimum Spanning Tree Problem with Conflicting Edge Pairs. Algorithms 2025, 18, 526. [Google Scholar] [CrossRef]
  27. Gabow, H.; Maheshwari, S.; Osterweil, L. On Two Problems in the Generation of Program Test Paths. IEEE Trans. Softw. Eng. 1976, SE-2, 227–231. [Google Scholar] [CrossRef]
  28. Krause, K.W.; Goodwin, M.A.; Smith, R.W. Optimal Software Test Planning Through Automated Network Analysis; TRW Systems Group: Cleveland, OH, USA, 1973; pp. 18–22. [Google Scholar]
  29. Srimani, P.K.; Sinha, B.P. Impossible pair constrained test path generation in a program. Inf. Sci. 1982, 28, 87–103. [Google Scholar] [CrossRef]
  30. Blanco, M.; Borndörfer, R.; Brückner, M.; Hoàng, N.D.; Schlechte, T. On the Path Avoiding Forbidden Pairs Polytope. Electron. Notes Discret. Math. 2015, 50, 343–348. [Google Scholar] [CrossRef]
  31. Ferone, D.; Festa, P.; Salani, M. Branch and Bound and Dynamic Programming Approaches for the Path Avoiding Forbidden Pairs Problem. In Optimization and Decision Science, Proceedings of the International Conference “Optimization and Decision Science” (ODS2020), Virtual Conference, 19 November 2020; Cerulli, R., Dell’Amico, M., Guerriero, F., Pacciarelli, D., Sforza, A., Eds.; Springer International Publishing: Cham, Switzerland, 2021; pp. 227–235. [Google Scholar]
  32. Pferschy, U.; Schauer, J. The maximum flow problem with disjunctive constraints. J. Comb. Optim. 2013, 26, 109–119. [Google Scholar] [CrossRef]
  33. Şuvak, Z.; Altınel, I.K.; Aras, N. Exact solution algorithms for the maximum flow problem with additional conflict constraints. Eur. J. Oper. Res. 2020, 287, 410–437. [Google Scholar] [CrossRef]
  34. Carrabs, F.; Cerulli, R.; Mansini, R.; Serra, D.; Sorgente, C. Hybridizing Carousel Greedy and Kernel Search: A new approach for the maximum flow problem with conflict constraints. Eur. J. Oper. Res. 2025, 324, 414–435. [Google Scholar] [CrossRef]
  35. Cerrone, C.; Cerulli, R.; Golden, B. Carousel greedy: A generalized greedy algorithm with applications in optimization. Comput. Oper. Res. 2017, 85, 97–112. [Google Scholar] [CrossRef]
  36. Angelelli, E.; Mansini, R.; Speranza, M.G. Kernel search: A new heuristic framework for portfolio selection. Comput. Optim. Appl. 2012, 51, 345–361. [Google Scholar] [CrossRef]
  37. Montemanni, R.; Smith, D.H. On Solving the Mainimum Spanning Tree Problem with Conflict Constraints. 2025; submitted for publication. [Google Scholar]
  38. Perron, L.; Didier, F. Google OR-Tools—CP-SAT. 2025. Available online: https://developers.google.com/optimization/cp/cp_solver/ (accessed on 14 July 2025).
  39. Stuckey, P.J. Lazy Clause Generation: Combining the Power of SAT and CP (and MIP?) Solving. In Proceedings of the International Conference on Integration of Artificial Intelligence and Operations Research Techniques in Constraint Programming (CPAIOR), Bologna, Italy, 14–18 June 2010; pp. 5–9. [Google Scholar]
  40. Montemanni, R.; Dell’Amico, M. Solving the parallel drone scheduling traveling salesman problem via constraint programming. Algorithms 2023, 16, 40. [Google Scholar] [CrossRef]
  41. Montemanni, R.; Dell’Amico, M.; Corsini, A. Parallel drone scheduling vehicle routing problems with collective drones. Comput. Oper. Res. 2024, 163, 106514. [Google Scholar] [CrossRef]
  42. Falkenauer, E. A hybrid grouping genetic algorithm for bin packing. J. Heuristics 1996, 1, 5–30. [Google Scholar] [CrossRef]
  43. GEne Network Expansion. CPU Performance. 2025. Available online: https://gene.disi.unitn.it/test/cpu_list.php (accessed on 14 July 2025).
  44. IBM. IBM CPLEX Optimizer. 2024. Available online: https://www.ibm.com/de-de/analytics/cplex-optimizer (accessed on 14 July 2025).
Figure 1. (Top) An example of a KPC instance is presented, where for each item the profit is indicated in red and the weight in blue, and edges represent conflicts. The total capacity c is 20, as indicated. (Bottom) An optimal solution with a total profit of 21 and a weight of 19 is represented. Observe that no conflict is violated by the given solution, since for each pair of conflicting items, at most one is selected.
Figure 1. (Top) An example of a KPC instance is presented, where for each item the profit is indicated in red and the weight in blue, and edges represent conflicts. The total capacity c is 20, as indicated. (Bottom) An optimal solution with a total profit of 21 and a weight of 19 is represented. Observe that no conflict is violated by the given solution, since for each pair of conflicting items, at most one is selected.
Mathematics 13 02674 g001
Table 1. Results on the first benchmark set, correlated instances. Aggregation by class and type.
Table 1. Results on the first benchmark set, correlated instances. Aggregation by class and type.
InstancesCFS [11]BCM [3]ILP [11]CP-SAT
Class Type # Opt Sec # Opt Sec # Opt Sec # Opt Sec
C11900.0900.0900.2900.1
2900.0900.0901.1900.3
3900.0900.0908.2901.7
4900.0900.09024.29014.4
5900.0900.0900.0900.0
6900.0900.0900.1900.1
7900.0900.0900.5900.2
8900.0900.0903.6900.7
C31900.0900.0901.5900.0
2900.0900.19025.8900.1
3900.1901.354162.8900.2
4901.69027.321141.9901.9
5900.0900.0900.2900.0
6900.0900.0902.0900.0
7900.0900.19046.5900.1
8900.0900.65935.3900.2
C101900.1901.6903.5900.1
29025.27331.968126.2900.3
36115.95018.222166.0901.6
45047.240108.81575.19014.5
5900.0900.0900.2900.0
6900.5906.8905.3900.1
78635.97024.565143.1900.2
8607.34917.420156.4900.7
Average85.75.683.09.972.967.990.01.6
Table 2. Results on the first benchmark set, random instances. Aggregation by class and type.
Table 2. Results on the first benchmark set, random instances. Aggregation by class and type.
InstancesCFS [11]BCM [3]ILP [11]CP-SAT
Class Type # Opt Sec # Opt Sec # Opt Sec # Opt Sec
R11900.0900.0900.1900.1
2900.0900.0900.8900.2
3900.0900.0904.8901.0
4900.0900.19010.1909.0
5900.0900.0900.0900.0
6900.0900.0900.1900.1
7900.0900.0900.4900.2
8900.0900.1902.7900.8
R31900.0900.0900.4900.0
2900.0900.0905.0900.1
3900.0900.29055.1900.2
4900.1902.350127.2901.9
5900.0900.0900.1900.0
6900.0900.0900.5900.0
7900.0900.0905.0900.1
8900.0900.29064.7900.2
R101900.0900.1901.6900.1
2900.8909.187107.4900.2
38949.96957.033100.0901.0
45123.24025.08333.6909.0
5900.0900.0900.1900.0
6900.0900.2901.5900.1
7901.59017.78091.7900.2
87919.56943.23077.0900.8
Average87.94.086.26.579.541.290.01.1
Table 3. Results on the first benchmark set, correlate instances. Aggregation by class and density.
Table 3. Results on the first benchmark set, correlate instances. Aggregation by class and density.
InstancesCFS [11]BCM [3]ILP [11]CP-SAT
Class Density # Opt Sec # Opt Sec # Opt Sec # Opt Sec
C10.1800.0800.0800.1800.2
0.2800.0800.0800.2800.4
0.3800.0800.0800.4800.7
0.4800.0800.0800.6801.2
0.5800.0800.0801.3801.5
0.6800.0800.0802.7803.2
0.7800.0800.0805.5803.3
0.8800.0800.08014.4805.2
0.9800.0800.08017.5804.0
C30.1800.2800.37711.2800.2
0.2800.1802.47926.7800.4
0.3800.4806.67227.7800.7
0.4800.5809.16641.3801.2
0.5800.5809.65274.6801.6
0.6800.2803.95041.9803.3
0.7800.1801.05011.0803.3
0.8800.0800.26668.4805.2
0.9800.0800.07227.2803.9
C100.14741.43337.34753.3800.1
0.25079.0304.4304.5800.1
0.3501.65064.7303.7800.1
0.47011.5503.748169.0800.2
0.58028.86923.650106.4800.4
0.6801.28052.55038.2800.4
0.7800.1803.75012.4800.5
0.8800.0800.37075.8800.5
0.9800.0800.07128.7800.6
Average76.26.173.88.364.832.080.01.6
Table 4. Results on the first benchmark set, random instances. Aggregation by class and density.
Table 4. Results on the first benchmark set, random instances. Aggregation by class and density.
InstancesCFS [11]BCM [3]ILP [11]CP-SAT
Class Density # Opt Sec # Opt Sec # Opt Sec # Opt Sec
R10.1800.0800.0800.1800.3
0.2800.0800.0800.2800.4
0.3800.0800.0800.3800.8
0.4800.0800.0800.6801.2
0.5800.0800.0800.9801.5
0.6800.0800.0801.6801.8
0.7800.0800.0804.8802.1
0.8800.0800.0805.3802.6
0.9800.0800.0807.2802.2
R30.1800.0800.1800.1800.3
0.2800.0800.1801.0800.4
0.3800.0800.48010.9800.8
0.4800.0800.77835.6801.2
0.5800.0800.87023.3801.6
0.6800.0800.67046.3801.8
0.7800.0800.37053.4802.1
0.8800.0800.17445.2802.5
0.9800.0800.07831.2802.3
R100.17111.26959.97216.0800.1
0.25947.95039.54385.1800.1
0.37042.8503.944139.2800.1
0.4702.07038.95053.8800.2
0.5807.2703.95051.6800.4
0.6800.48011.65016.2800.4
0.7800.1801.35438.5800.5
0.8800.0800.27040.4800.5
0.9790.0790.07544.6800.6
Average78.14.176.66.070.727.980.01.1
Table 5. Results on the second benchmark set, correlated instances. Aggregation by number of items/capacity and density.
Table 5. Results on the second benchmark set, correlated instances. Aggregation by number of items/capacity and density.
InstancesCFS [11]BCM [3]ILP [11]CP-SAT 600 sCP-SAT 3600 s
Items Capacity Density # Opt Sec # Opt Sec # Opt Sec # Opt Gap % Sec # Opt Gap % Sec
50010000.001100.0100.0100.0100.000.1100.000.1
0.002100.0100.6100.0100.000.1100.000.1
0.005100.2106.7100.0100.0013.1100.0013.1
0.01100.89103.3100.090.0230.4100.0073.6
0.021056.71272.7100.3100.0024.8100.0024.8
0.051165.80-1090.690.09204.0100.00218.8
50020000.001104.2100.4100.0100.000.1100.000.1
0.002100.1105.2100.0100.000.2100.000.2
0.005107.38199.6100.090.01100.9100.00362.9
0.01749.80-100.060.045.380.02296.9
0.020-0-96.190.0112.2100.00136.9
0.050-0-0-02.77-01.97-
100010000.001100.1105.4100.0100.000.3100.000.3
0.002100.21011.1100.0100.000.5100.000.5
0.005105.95379.9100.070.0522.5211100.00456.6
0.017163.90-100.120.1484.555540.10522.1
0.020-0-72.450.112.853660.08153.0
0.050-0-0-04.72-03.44-
100020000.001103.1984.7100.0100.008.7100.008.7
0.0021045.87210.3100.080.0236.960990.01188.2
0.0057182.00-100.060.03159.75880.02405.8
0.0140.00-90.160.04100.43670.03196.0
0.020-0-5193.810.82388.10480.111697.2
0.050-0-0-08.21-07.08-
Average6.538.14.598.58.314.07.00.7156.97.90.54226.5
Table 6. Results on the second benchmark set, random instances. Aggregation by number of items/capacity and density.
Table 6. Results on the second benchmark set, random instances. Aggregation by number of items/capacity and density.
InstancesCFS [11]BCM [3]ILP [11]CP-SAT 600 sCP-SAT 3600 s
Items Capacity Density # Opt Sec # Opt Sec # Opt Sec # Opt Gap % Sec # Opt Gap % Sec
50010000.001100.0100.0100.0100.000.1100.000.1
0.002100.0100.1100.0100.000.1100.000.1
0.005100.0100.4100.0100.000.2100.000.2
0.01100.1102.1100.0100.000.1100.000.1
0.02101.21032.8100.0100.000.2100.000.2
0.059132.73133.2101.2100.001.2100.001.2
50020000.001100.0100.1100.0100.000.1100.000.1
0.002100.0100.3100.0100.000.2100.000.2
0.005100.1102.4100.0100.000.2100.000.2
0.011010.49190.7100.0100.000.1100.000.1
0.023116.5139.6100.1100.000.2100.000.2
0.050-0-1081.261.61228.895100.00471.9
100010000.001100.0100.4100.0100.00.2100.00.2
0.002100.0101.6100.0100.00.4100.00.4
0.005100.11016.8100.0100.00.3100.00.3
0.011015.08152.6100.1100.00.2100.00.2
0.024125.71468.8100.6100.00.4100.00.4
0.050-0-9255.032.9139.3100.00943.3
100020000.001100.0102.3100.0100.000.3100.000.3
0.002100.01020.3100.0100.000.6100.000.6
0.005969.52189.9100.0100.000.3100.000.3
0.011565.80-100.1100.000.3100.000.3
0.020-0-102.1100.0010.2100.0010.2
0.050-0-0-012.45-010.51-
Average7.351.96.466.09.514.89.10.7116.79.60.4462.2
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Montemanni, R.; Smith, D.H. On Solving the Knapsack Problem with Conflicts. Mathematics 2025, 13, 2674. https://doi.org/10.3390/math13162674

AMA Style

Montemanni R, Smith DH. On Solving the Knapsack Problem with Conflicts. Mathematics. 2025; 13(16):2674. https://doi.org/10.3390/math13162674

Chicago/Turabian Style

Montemanni, Roberto, and Derek H. Smith. 2025. "On Solving the Knapsack Problem with Conflicts" Mathematics 13, no. 16: 2674. https://doi.org/10.3390/math13162674

APA Style

Montemanni, R., & Smith, D. H. (2025). On Solving the Knapsack Problem with Conflicts. Mathematics, 13(16), 2674. https://doi.org/10.3390/math13162674

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop