This repository contains solutions developed for a Combinatorial Optimization exercise list. The problems were solved using both a custom metaheuristic and exact optimization models implemented with IBM ILOG CPLEX.
├── optimization_list.pdf
├── Q1/ # Question 1: Bin Packing Metaheuristic
│ ├── bin_packing.cpp # Main source code
│ ├── Makefile
│ └── instance.txt # Input file
│
└── Q2/ # Question 2: Exact Models with CPLEX
├── cans.cpp
├── click.cpp
├── coverage.cpp
├── cvrp.cpp
├── diet.cpp
├── facility.cpp
├── farm.cpp
├── frequency.cpp
├── knapsack.cpp
├── maxflow.cpp
├── nurses.cpp
├── paint.cpp
├── ration.cpp
├── shortest.cpp
├── transport.cpp
├── tsp.cpp
└── Makefile
The Bin Packing problem was implemented in C++ using the ILS (Iterated Local Search) metaheuristic combined with a First Improvement local search strategy.
-
(a) Solution Representation: Structure based on
std::vector, allowing fast access to elements. -
(b) Evaluation Function: Maximization of
$f(x) = \sum L_i^2$ , encouraging bins to be more filled. - (c) Local Search: Random Relocate and Swap moves, accepting the first improving solution found.
-
(d) Stopping Criterion: Time-based control using the
<chrono>library and a user-defined time limit.
Navigate to the Q1 directory:
cd Q1Compile:
makeRun using the default input file:
The script is configured to automatically read data from instance.txt using a time limit of 2 seconds.
make runRun manually:
To change the time limit or use a different input file:
./bin_packing <time_limit_in_seconds> < <input_file>.txtThe instance.txt file must contain:
- The total number of items on the first line.
- The size of each item (between 0.0 and 1.0) on the following lines.
This directory contains several optimization problems modeled in C++ and solved using IBM ILOG CPLEX.
Implemented models include:
- Transportation Problem (
transport.cpp) - Traveling Salesman Problem (TSP) (
tsp.cpp) - Capacitated Vehicle Routing Problem (CVRP) (
cvrp.cpp) - Shortest Path Problem (
shortest.cpp) - Maximum Flow Problem (
maxflow.cpp) - Knapsack Problem (
knapsack.cpp) - Coverage Problem (
coverage.cpp) - Facility Location Problem (
facility.cpp) - Diet Problem (
diet.cpp) - Nurse Scheduling Problem (
nurses.cpp) - Frequency Assignment Problem (
frequency.cpp) - Farm Planning Problem (
farm.cpp) - Ration Problem (
ration.cpp) - Paint Problem (
paint.cpp) - Cans Problem (
cans.cpp) - Clique Problem (
click.cpp)
Navigate to the Q2 directory:
cd Q2To compile a specific model:
make <file_name>Then run the generated executable:
./<file_name>Traveling Salesman Problem (TSP)
make tsp
./tspCapacitated Vehicle Routing Problem (CVRP)
make cvrp
./cvrpTransportation Problem
make transport
./transportShortest Path Problem
make shortest
./shortestMaximum Flow Problem
make maxflow
./maxflowTo remove compiled executables and keep the directory organized:
make clean