This project implements the Horse Herd Optimization Algorithm (HHOA) to solve the Flow Shop Scheduling Problem (FSSP). HHOA is a nature-inspired metaheuristic algorithm that mimics the social behavior of horses in a herd, providing an effective approach for combinatorial optimization problems.
The Flow Shop Scheduling Problem is a classical NP-hard scheduling optimization problem where n jobs must be processed on m machines in the same order, with the objective of minimizing the total completion time (makespan).
HHOA-FSSP/
βββ src/
β βββ core/ # Core problem representation
β β βββ ProblemInstance.h/.cpp # FSSP instance management
β β βββ Solution.h/.cpp # Solution representation & evaluation
β βββ algorithm/ # HHOA implementation
β β βββ HHOA.h/.cpp # Main optimization algorithm
β β βββ Horse.h/.cpp # Individual horse with behaviors
β β βββ HorseHerd.h/.cpp # Population management
β βββ utils/ # Utility classes
β β βββ Random.h/.cpp # Thread-safe random generation
β β βββ Timer.h/.cpp # Performance measurement
β β βββ Logger.h/.cpp # Multi-level logging system
β βββ main.cpp # Command-line interface
βββ data/
β βββ instances/ # Test problem instances
β β βββ test_6x5.txt # Small test case (6 jobs, 5 machines)
β β βββ test_10x10.txt # Medium test case (10 jobs, 10 machines)
β β βββ test_20x5.txt # Large test case (20 jobs, 5 machines)
β βββ results/ # Algorithm execution logs
βββ tests/ # Unit testing framework
βββ docs/ # Comprehensive documentation
βββ build/ # Compiled binaries
βββ CMakeLists.txt # Cross-platform build system
βββ benchmark.sh # Performance benchmarking script
βββ PROJECT_SUMMARY.md # Detailed project completion report
The Horse Herd Optimization Algorithm (HHOA) is a nature-inspired metaheuristic algorithm that mimics the social behavior of horses in a herd. The algorithm consists of six key behavioral phases:
- π± Grazing behavior: Local search around current positions using 2-opt and insertion operations
- πΆ Roaming behavior: Exploration of new solution areas to maintain diversity
- π Following behavior: Non-leader horses learn from the best horse (leader)
- π Mating behavior: Crossover operations to combine good solutions
- π² Mutation: Random changes to prevent premature convergence
- β° Aging: Population renewal mechanism to maintain dynamics
- Early termination when no improvement is found for 100 iterations
- Mixed initialization with 80% random and 20% greedy solutions
- Adaptive parameters that adjust based on search progress
- Elite preservation to maintain best solutions found
The Flow Shop Scheduling Problem involves:
- n jobs to be processed sequentially
- m machines in a fixed processing order (Machine 1 β 2 β ... β m)
- Each job has specific processing times on each machine
- Objective: Minimize makespan (total completion time)
- C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)
- CMake 3.12 or higher
- Make or Ninja build system
# Clone and navigate to project directory
cd HHOA-FSSP
# Create build directory
mkdir build && cd build
# Configure and build
cmake ..
make
# Alternative: Build with specific number of cores
make -j$(nproc)# Run unit tests
./bin/hhoa_fssp_tests
# Test basic functionality
./bin/hhoa_fssp --iterations 100# Run with default parameters (30 horses, 1000 iterations)
./bin/hhoa_fssp
# Specify custom number of iterations
./bin/hhoa_fssp --iterations 500
# Adjust population size
./bin/hhoa_fssp --population 50
# Load custom problem instance
./bin/hhoa_fssp --file ../data/instances/test_20x5.txt
# Combine multiple options
./bin/hhoa_fssp --iterations 2000 --population 40| Option | Description | Default |
|---|---|---|
--iterations N |
Maximum number of iterations | 1000 |
--population N |
Population size (number of horses) | 30 |
--file PATH |
Load problem instance from file | Built-in 10x10 |
--help |
Show usage information | - |
# Execute unit tests
./bin/hhoa_fssp_tests
# Run benchmark script
../benchmark.shThe algorithm demonstrates excellent optimization performance:
- Initial makespan: ~1266-1300 (varies with random initialization)
- Final makespan: ~1214-1230 (typical improvement of 3-7%)
- Execution time: ~200ms for complete optimization
- Convergence: Usually within 100-200 iterations
=========================================
Horse Herd Optimization Algorithm
for Flow Shop Scheduling Problem
=========================================
Problem Instance: TestInstance_10x10
Jobs: 10, Machines: 10
Starting HHOA optimization...
Population: 30, Iterations: 1000
=== OPTIMIZATION RESULTS ===
Best Makespan: 1214
Execution Time: 192.986 ms
Iterations: 103
Total Improvements: 4
Best Solution:
Job Sequence: J5 -> J8 -> J7 -> J1 -> J9 -> J10 -> J3 -> J4 -> J2 -> J6
Makespan: 1214
The following parameters control the algorithm behavior:
- Population Size: 30 horses (24 random + 6 greedy initialization)
- Grazing Intensity: 0.8 (high local search intensity)
- Roaming Rate: 0.3 (30% of horses roam per iteration)
- Exploration Rate: 0.5 (moderate exploration)
- Following Rate: 0.7 (high learning from leader)
- Crossover Rate: 0.8 (high reproduction rate)
- Mutation Rate: 0.2 (moderate mutation)
- Early Termination: 100 iterations without improvement
For small problems (< 10 jobs):
- Reduce population to 15-20
- Increase mutation rate to 0.3
- Use fewer iterations (100-300)
For large problems (> 20 jobs):
- Increase population to 50-100
- Reduce mutation rate to 0.1
- Use more iterations (1000-5000)
The project includes comprehensive testing:
# Core functionality tests
./bin/hhoa_fssp_tests
# Performance benchmarking
../benchmark.sh
# Manual testing with different instances
./bin/hhoa_fssp --file ../data/instances/test_6x5.txt
./bin/hhoa_fssp --file ../data/instances/test_20x5.txt- Algorithm Description: docs/algorithm_description.md
- Project Summary: PROJECT_SUMMARY.md
- Code Documentation: Inline comments and Doxygen-style headers
The modular design allows for easy extensions:
- New Problem Types: Implement additional scheduling variants
- Algorithm Variants: Modify behavioral parameters or add new behaviors
- Performance Optimizations: Add parallel processing or GPU acceleration
- Visualization: Create graphical representations of solutions
- Machine Learning: Integrate adaptive parameter tuning
This project demonstrates:
- Modern C++ programming practices (C++17)
- Professional software engineering principles
- Metaheuristic algorithm implementation
- Performance optimization techniques
- Comprehensive testing and documentation
This project is available under the MIT License.
- Developer: Implementation of HHOA-FSSP
- Date: June 2025
- Course: Metaheuristic Algorithms
This implementation serves as both a practical optimization tool and an educational resource for understanding nature-inspired algorithms and their application to combinatorial optimization problems.