This project implements and compares various heuristic optimization algorithms, including Genetic Algorithms (GA), Particle Swarm Optimization (PSO), and their variations with local search, to solve complex optimization problems.
- Optimization Algorithms: Includes implementations for:
- Genetic Algorithm (GA)
- Genetic Algorithm with Local Search (GA_LS)
- Particle Swarm Optimization (PSO)
- Particle Swarm Optimization with Local Search (PSO_LS)
- Problem Selection: Dynamically select optimization problems to solve.
- Result Analysis: Compare algorithm performance using:
- Best solution
- Mean and standard deviation across multiple runs
- Visualization: Graphically compare algorithm performance.
- Result Saving: Automatically saves outputs for analysis.
.
├── heuristic
│ ├── algorithms # Contains algorithm implementations
│ ├── problems # Problem definitions
│ └── utils # Utility functions
├── main.py # Entry point for running algorithms
├── README.md # Project documentation
├── requirements.txt # Dependencies
├── results # Stores outputs and plots
├── .gitignore # Git ignore rules
└── .venv # Virtual environment (not included in repo)
- Python 3.10 or higher
- Required libraries are listed in
requirements.txt
.
Key dependencies:
numpy
matplotlib
Install them using:
pip install -r requirements.txt
-
Clone the repository:
git clone https://github.com/Ibrahimghali/heuristic.git cd heuristic-optimization
-
Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the main script:
python main.py
-
Select a problem: Follow the prompts to select an optimization problem to solve.
-
View Results:
- Best, mean, and standard deviation of solutions will be printed in the terminal.
- Output files will be saved in the
results/
directory.
-
Visualize Results:
- Plots will be displayed and saved in
results/plots
.
- Plots will be displayed and saved in
-
Text Results: Outputs for all algorithms are saved in
results/
with filenames corresponding to the algorithm names. -
Plots: Comparative performance plots are saved in
results/plots
.
Example result plot:
We welcome contributions! To contribute:
- Fork the repository.
- Create a feature branch (
git checkout -b feature-name
). - Commit your changes (
git commit -m "Add feature-name"
). - Push to your fork (
git push origin feature-name
). - Open a pull request.
This project is licensed under the MIT License. See LICENSE
for details.