Skip to content

Terminal representation of TSP with OX1 crossbreeding.

License

Notifications You must be signed in to change notification settings

alecstem/ga-tsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Genetic TSP

Description

TSP optimized with a genetic algorithm using OX1 crossbreeding, written in C++. Visualization done in terminal window. For now arbitrary node locations are generated on each run, but I'll implement adding nodes manually with the mouse soon enough. Note: since GAs provide heuristic approximations, the solution is not guaranteed to be the most optimal.

How does this work?

Process Implementation
Initial population Accomplished by creating N permutations of a size K vector.
Crossbreeding OX1 method.
Selection Elitist selection (fitness criteria: routes with lowest distance).
Mutation Probability-based std::vector swap.

Challenges

The hardest part about this was implementing the OX1 crossbreeding method. Since TSP relies heavily on order and some structure is necessary (i.e. first and last position must be the same, elements in the middle must be unique, etc.), normal crossbreeding simply cannot be used. I think my implementation of it turned out decently, however it could still be heavily improved I'm sure.

About

Terminal representation of TSP with OX1 crossbreeding.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages