Implementation and experimental evaluation of
The project solves KPC instances through exact Branch and Bound (IBM ILOG CPLEX), under two experimental layers.
Layer 1 (Isolated).
Layer 2 (Commercial).
optimization-project-kpc/
├── instances/ 60 synthetically generated KPC instances
├── scripts/
│ ├── generate_instances.py Instance generation
│ └── plot_results.py Statistical analysis and plots
├── src/
│ ├── main.cpp Solver implementation in C++ with CPLEX
│ ├── Makefile Build configuration for the solver
│ ├── pre_solver_results.csv Layer 1 output, generated at runtime
│ └── post_solver_results.csv Layer 2 output, generated at runtime
├── requirements.txt Python dependencies
└── .gitignore
└── KnapsackProblem_Article.pdf
IBM ILOG CPLEX Optimization Studio with Concert Technology for C++, installed and licensed. The Makefile expects the standard CPLEX installation paths. Adjust CPLEXDIR and CONCERTDIR inside the Makefile if your installation lives elsewhere.
A C++ compiler. The code relies on std::filesystem, which requires at least C++17. Check the CXXFLAGS entry in src/Makefile to confirm the standard flag actually configured for the build.
Python 3.10 or newer.
make.
CPLEX is proprietary software from IBM. This repository does not distribute the solver. A valid license, academic or commercial, is required to compile and run the project.
Clone the repository and install the Python dependencies.
git clone https://github.com/mathk32/optimization-project-kpc.git
cd optimization-project-kpc
pip install -r requirements.txtcontourpy==1.3.3
cycler==0.12.1
fonttools==4.63.0
kiwisolver==1.5.0
matplotlib==3.11.0
numpy==2.5.0
packaging==26.2
pandas==3.0.3
pillow==12.2.0
pyparsing==3.3.2
python-dateutil==2.9.0.post0
seaborn==0.13.2
six==1.17.0
The 60 instances under instances/ were generated by scripts/generate_instances.py, covering 12 combinations of item count (n) and conflict graph density (delta), with 5 instances per combination.
| n (items) | delta (density) |
|---|---|
| 100 | 0.2, 0.4, 0.6, 0.8 |
| 150 | 0.2, 0.4, 0.6, 0.8 |
| 200 | 0.2, 0.4, 0.6, 0.8 |
To regenerate the instances, which is optional since the repository already includes the 60 instances used in the experiments:
python scripts/generate_instances.pycd src
make./kpc_solverThis processes every instance under instances/, solving each one under the four configurations: Most Fractional and Si for Layer 1, default CPLEX and Si for Layer 2. Two output files are produced in src/.
pre_solver_results.csv holds the Layer 1 results. post_solver_results.csv holds the Layer 2 results.
Each row reports, per instance: item count, density, optimal profit, number of explored nodes, CPU time, and optimality status, for both methods being compared.
Note on runtime. Layer 1 disables presolve and cuts, which can lead to very large search trees on low density, larger instances (n around 200, delta around 0.2). Some of these instances may take tens of minutes to solve under this configuration.
cd ../scripts
python plot_results.pyThis script reads both CSV files from src/, runs an integrity check confirming optimal profit parity between the compared methods, prints a statistical summary grouped by density range, and produces the comparative plots.
Across the 60 tested instances.
| Layer | Mean node reduction | Mean time reduction |
|---|---|---|
| 1, Isolated, |
44.31 percent | 34.90 percent |
| 2, Commercial, |
see article | see article |
In Layer 1,
C++17. Used for the solver implementation and the branching callbacks.
IBM ILOG CPLEX, Concert Technology. Used for exact resolution through Branch and Bound.
Python, with pandas, matplotlib, and seaborn. Used for statistical analysis and visualization of the results.