This project implements a Genetic Algorithm in C to solve the Bin Packing Problem, a classical NP-hard optimization problem.
The goal is to assign objects to boxes while minimizing the number of boxes used and respecting capacity constraints.
- Each object has a specific size
- Each box has a fixed maximum capacity
- Objects must be assigned to boxes
- The total size of objects in a box cannot exceed its capacity
- The objective is to minimize the number of boxes
The genetic algorithm includes:
- Random generation of valid initial solutions
- Fitness evaluation based on the number of boxes used
- Tournament selection
- One-point crossover
- Random mutation
- Iterative evolution over multiple generations
- Continuous improvement of the best solution found
solu_t: Represents a candidate solution (chromosome)pop_t: Represents a population of solutionsAlgo_genetique(): Main genetic algorithm loopselectionner(): Selection operatorcroisement(): Crossover operatormutation(): Mutation operatorind_validite(): Fitness and feasibility checklire_fichier(): Reads problem parameters from a file
The program reads its parameters from projet_param.txt.
- B: 10
- n: 5
- T: 2 3 4 1 5
Where:
Bis the box capacitynis the number of objectsTcontains the object sizes
gcc main.c -o genetic_bin_packing
./genetic_bin_packing