Skip to content

A C-based genetic algorithm that solves the bin packing problem by minimizing the number of boxes used while respecting capacity constraints.

Notifications You must be signed in to change notification settings

iiYessine/BinPackOptimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ฆ Genetic Algorithm for the Bin Packing Problem

๐Ÿ“Œ Description

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.


๐Ÿง  Problem Definition

  • 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

โš™๏ธ Algorithm

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

๐Ÿ—๏ธ Implementation Overview

  • solu_t : Represents a candidate solution (chromosome)
  • pop_t : Represents a population of solutions
  • Algo_genetique() : Main genetic algorithm loop
  • selectionner() : Selection operator
  • croisement() : Crossover operator
  • mutation() : Mutation operator
  • ind_validite() : Fitness and feasibility check
  • lire_fichier() : Reads problem parameters from a file

๐Ÿ“„ Input File

The program reads its parameters from projet_param.txt.

Example:

  • B: 10
  • n: 5
  • T: 2 3 4 1 5

Where:

  • B is the box capacity
  • n is the number of objects
  • T contains the object sizes

โ–ถ๏ธ Compile and Run

gcc main.c -o genetic_bin_packing
./genetic_bin_packing

About

A C-based genetic algorithm that solves the bin packing problem by minimizing the number of boxes used while respecting capacity constraints.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published