Genetic Algorithms in Rust for Autonomous Agents: An Introduction

This article discusses a possible genetic algorithm implementation in Rust applied to the travelling salesman problem.

Jun 30, 2018 · 7 min read
If this article helped you in someway, consider buying me a coffee :)
Source of image LEFT and RIGHT

Genetic Algorithms Overview


How it Works

How to generate the next population?

Crossover and Mutate

Putting Everything Together

- Randomly initialize a population of individuals
- Determine the fittest individual so far "CHAMPION"
Repeat for a number of iterations
- Generate the next population of individuals based on the previous
- Select parents
- Perform genetic operations such as crossover or clone
- to produce children and possibly mutate
- Get the fittest individual in this population "challenger"
- Replace the "champion" with the "challenger" if it is more fit
The champion's DNA is the best solution we've seen in this simulation run. You might need to make multiple runs to get a better solution.
1. Number of iterations
2. Population size
3. Crossover probability
4. Mutation probability
1. DNA representing the solution
2. The fitness function
3. The selection function
4. Genetic operations such as crossover, clone, and mutation
If this article helped you in someway, consider buying me a coffee :)