Skip to content

Commit 9044ef5

Browse files
authored
Expand README with representations and benchmarks
Added sections for supported representations, benchmark functions, and development guidelines.
1 parent 98d4cff commit 9044ef5

1 file changed

Lines changed: 123 additions & 3 deletions

File tree

README.md

Lines changed: 123 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,131 @@ cfg.elite_ratio = 0.05
205205
cfg.seed = 1
206206
```
207207

208-
## Contributing
208+
## 📊 Supported Representations & Operators
209209

210-
- Keep changes focused and add/update tests when applicable.
211-
- Prefer small PRs: one feature/fix at a time.
210+
### Binary Representation
211+
- **Crossovers**: One-point, Two-point, Uniform
212+
- **Mutations**: Bit-flip
213+
- **Use Cases**: Feature selection, binary optimization
212214

215+
### Real-Valued Representation
216+
- **Crossovers**: Arithmetic, Blend (BLX-α), SBX, One-point, Two-point, Uniform
217+
- **Mutations**: Gaussian, Uniform
218+
- **Use Cases**: Continuous function optimization, parameter tuning
219+
220+
### Integer Representation
221+
- **Crossovers**: One-point, Two-point, Uniform, Arithmetic
222+
- **Mutations**: Random resetting, Creep
223+
- **Use Cases**: Discrete optimization, scheduling problems
224+
225+
### Permutation Representation
226+
- **Crossovers**: Order crossover (OX), Partially mapped crossover (PMX), Cycle crossover
227+
- **Mutations**: Swap, Insert, Scramble, Inversion
228+
- **Use Cases**: Traveling salesman problem, job scheduling
229+
230+
## 🧪 Benchmark Functions
231+
232+
The framework includes 5 standard optimization test functions:
233+
234+
1. **Sphere Function**: Simple unimodal function (baseline)
235+
2. **Rastrigin Function**: Highly multimodal with many local optima
236+
3. **Ackley Function**: One global minimum with many local minima
237+
4. **Schwefel Function**: Deceptive function with global optimum far from local optima
238+
5. **Rosenbrock Function**: Narrow valley, challenging for optimization
239+
240+
## 🔬 Running Benchmarks
241+
242+
The framework includes a comprehensive benchmark suite that tests:
243+
- **Operator Performance**: Speed of crossover, mutation, and selection operators
244+
- **Function Optimization**: Convergence quality on test functions
245+
- **Scalability**: Performance vs. population size and problem dimension
246+
247+
### Benchmark Results
248+
249+
**Operator Performance (typical results on modern CPU):**
250+
| Operator Category | Representative | Throughput |
251+
|-------------------|----------------|------------|
252+
| Binary Crossover | TwoPointCrossover | 2M ops/sec |
253+
| Real Crossover | BlendCrossover (BLX-α) | 5M ops/sec |
254+
| Permutation Crossover | OrderCrossover (OX) | 869K ops/sec |
255+
| Binary Mutation | BitFlipMutation | 1.1M ops/sec |
256+
| Real Mutation | GaussianMutation | 6.6M ops/sec |
257+
| Permutation Mutation | SwapMutation | 20M ops/sec |
258+
| Selection | TournamentSelection | 181K ops/sec |
259+
260+
**Function Optimization (convergence times):**
261+
| Function | Generations | Time (ms) | Best Fitness |
262+
|----------|-------------|-----------|--------------|
263+
| Sphere | 100 | ~1 | >500 |
264+
| Rastrigin | 200 | ~5 | >60 |
265+
| Ackley | 150 | ~4 | >60 |
266+
| Schwefel | 200 | ~7 | Variable |
267+
| Rosenbrock | 300 | ~8 | >200 |
268+
269+
*Results will vary based on hardware, problem configuration, and random seed.*
270+
271+
### Understanding Benchmark Output
272+
273+
The benchmark tool generates:
274+
- **Console output**: Real-time progress and summary statistics
275+
- **benchmark_results.txt**: Detailed results with all metrics
276+
- **benchmark_results.csv**: Machine-readable format (with `--csv` flag)
277+
278+
## 🏗️ Architecture & Efficiency
279+
280+
For a detailed analysis of the framework's architecture, efficiency, and usability across C++, Python, and C, see [ARCHITECTURE.md](ARCHITECTURE.md).
281+
282+
**Key Highlights:**
283+
-**Performance**: Native C++17 with zero-overhead abstractions
284+
- 🔧 **Extensible**: Easy to add custom operators and fitness functions
285+
- 🌐 **Multi-language**: C++ core with Python bindings
286+
- 📊 **Validated**: Comprehensive benchmark suite included
287+
- 🧪 **Tested**: Multiple test programs and sanity checks
288+
289+
## 🔍 Development
290+
291+
### Adding New Operators
292+
293+
1. Create header and implementation files in the appropriate directory
294+
2. Inherit from the base operator class
295+
3. Implement required virtual methods
296+
4. Optionally expose convenience factories alongside `ga::make*` helpers
297+
298+
### Adding New Fitness Functions
299+
300+
1. Add declaration to `simple-GA-Test/fitness-function.h`
301+
2. Implement in `simple-GA-Test/fitness-fuction.cc`
302+
3. Add to the `GAConfig::FunctionType` enum
303+
4. Update the fitness function selection logic
304+
305+
### Building for Development
306+
307+
```bash
308+
# Debug build with symbols
309+
cmake -DCMAKE_BUILD_TYPE=Debug ..
310+
cmake --build .
311+
312+
# Run with debug output
313+
./bin/simple_ga_test
314+
```
315+
316+
## 📝 Output
317+
318+
The program generates:
319+
- **Console output**: Progress information and final results
320+
- **ga_results.txt**: Detailed results including:
321+
- Best fitness values per generation
322+
- Average fitness values
323+
- Best individual's chromosome
324+
- Optimization statistics
325+
326+
## 🤝 Contributing
327+
328+
1. Fork the repository
329+
2. Create a feature branch
330+
3. Make your changes
331+
4. Add tests if applicable
332+
5. Submit a pull request
213333
## License
214334

215335
Apache-2.0

0 commit comments

Comments
 (0)