Skip to content
Simple working examples of heuristic optimization algorithms
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Good Enough Algorithms

Evolutionary algorithms and other heuristic optimizers

This is code associated with talks, workshops, and a blog post I have written about heuristic optimization algorithms. This repository contains the code needed to run four algorithms -- a hill climber, simulated annealing, Metropolis-coupled MCMC, and a genetic algorithm -- to find good solutions to the travelling salesperson problem. The code is written in a modular way that is meant to make it easy to adapt to other optimization problems. This code is written in Python3; for a Python2 implementation, see this repository.

An overview of the directory:

  • contains functions to initialize, mutate, select, and calculate fitness for solutions.
  •,,, and contain implementations of a hill climber, simulated annealing, MCMCMC, and a genetic algorithm, respectively.
  • is a wrapper for all of the specific implementations of the problem. This is a fairly generic wrapper that can be fitted to different optimization problems.
  • is a command line wrapper for
  • provides some functions to display how the different algorithms performed. All .txt files in the ExampleOutput folder can be used in these visualizations.

This code requires the following modules:

  • copy
  • math
  • os
  • pylab
  • random
  • scipy
  • sys

If you run into any problems, please submit an issue!

You can’t perform that action at this time.