Skip to content
A genetic algorithm implementation in Python for the Traveling Salesman Problem
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Genetic Algorithm implementation in Python for the Traveling Salesman Problem

The main script is the file which contains base classes for creating your own Genetic Algorithm (i.e. import ga; env = ga.Environment(kind=YourKind) where YourKind is some class inheriting IndividualBase) or for simply running the provided implementation of the Traveling Salesman Problem.

Usage for the latter:

Usage: [options]

-h, --help            show this help message and exit
                        Continue till we have reached MAX_GENERATIONS
                        Store POPULATION_SIZE different individuals
                        Set crossover probability to CROSSOVER_RATE (between 0
                        and 1)
                        Set mutation probability to MUTATION_RATE (between 0
                        and 1)
-e ELITISM, --elitism=ELITISM
                        Enable elitism for the top ELITISM results
                        Print intermediate results for every PRINT_INTERVAL
                        generations. Use 0 for no intermediate output
--csv=CSV             Return csv output for easy plotting every CSV
--csv-file=CSV_FILE   Where to write the csv output to (defaults to STDOUT)
-s SAMPLES, --samples=SAMPLES
                        The amount of samples to use. Very useful with csv
                        By default the samples are calculated in parallel, you
                        can change the amount of simultaneous processes with

To generate all output automatically there is also a script called available which automatically try all kinds of different values for elitism, population, mutation and crossover.

If you have any questions, feel free to mail me at: Rick _at_ Fawo _dot_ nl

Something went wrong with that request. Please try again.