Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Darwin

A genetic algorithm simulator that models population evolution through natural selection, crossover, and mutation. Built as a C++ educational project demonstrating Darwinian evolution principles.

Overview

Darwin reads an initial population of individuals from an input file, where each individual has a chromosome represented as a sequence of natural numbers. Over a specified number of generations, the program applies:

  • Crossover – pairs of individuals exchange genetic material to produce offspring
  • Fitness evaluation – individuals are scored based on chromosome properties
  • Selection – weaker individuals are eliminated and stronger ones reproduce

The result is a final evolved population written to an output file.

Project Structure

Darwin/
├── Darwin.cpp          # Full version of the simulator
├── Darwin LITE/
│   ├── DarwinLITE.cpp  # Lightweight version
│   └── inFile.txt      # Sample input population
├── doxygen/
│   ├── html/           # Generated HTML documentation
│   └── latex/          # Generated LaTeX documentation
├── inFile.txt          # Sample input population
└── README.md

Building

Compile with any C++ compiler that supports the C++ standard library. The full version uses the Windows API (<windows.h>) for colored console output.

g++ -o Darwin Darwin.cpp

For the lightweight version:

g++ -o DarwinLITE "Darwin LITE/DarwinLITE.cpp"

Usage

./Darwin -i <input_file> -o <output_file> -w <extinction_coeff> -r <reproduction_coeff> -p <generations> -k <crossover_pairs>

Parameters

Flag Description Constraints
-i Path to input file with initial population (.txt) Required
-o Path to output file for final population (.txt) Required
-w Extinction coefficient 0 ≤ w ≤ 1
-r Reproduction coefficient 0 ≤ r ≤ 1
-p Number of generations to simulate p ≥ 1
-k Number of crossover pairs per generation k ≥ 1

Example

./Darwin -i inFile.txt -o outFile.txt -w 0.4 -r 0.7 -p 3 -k 5

Input File Format

Each line represents one individual. The line starts with the individual's number followed by a sequence of space-separated natural numbers forming its chromosome:

1. 164 790 402 529 678 250 752 740
2. 580 74 490 374 452 376 414 652 18 132 862 144 781 790 67
3. 101 781 578 585 615 754

Documentation

API documentation is available in the doxygen/ directory. Open doxygen/html/index.html in a browser to view the generated HTML documentation.

Author

Krzysztof Koźlik – November 2020

About

Program symulujący ewolucje populacji osobników zapisywanych w pliku tekstowym

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages