Dave Thomas' challenge on The Panda's Thumb inspired me to code a genetic algorithm (GA) to solve the Steiner Problem. I've extracted the core GA engine from that code to allow it to be reused in other problem domains.


The GA engine is quite simple, consisting at present of less than 200 lines of code. The symbols exported from the org.softwarematters.ga package include utilities, generic functions, and core GA capabilities:


Applying the GA engine to a problem consists of following a few simple steps:

  1. Create a class to represent the characteristics of the problem
  2. Implement a method to create instances of the problem class
  3. Implement the required generic functions for the problem:
    • genome-length
    • fitness
    • fitness-comparator
  4. Implement a terminator function
  5. Run solve

The Steiner Problem and Dawkin's Weasel examples show how to use the GA engine.

Source Code

The code is available in two files:

Planned Enhancements

I've got a number of enhancements in the pipeline, including:

Please contact me by email if you have any questions, comments, or suggestions.