getting started with watchmaker api

655 views Asked by At

I am new to Watchmaker framework and interested to build a most basic genetic algorithm solver for tsp to understand how it works and further explore. I have a distance matrix of cities already where each element would be the distance between the city of rowth index and city of column index (diagonal elements will be zero as it will be distance between same cities). I would like to generate few hundreds of initial population, calculate fitness function, take two of best that yields min of fitness function, produce children and so on.. (the basic routine)

My question is,

is my distance matrix enough to be fed as initial population? is it in correct format? which objects should I use for generating initial population?

Technology: Netbeans 7.4 on Ubuntu 12.10 running OpenJDK 1.7 . Planning to add the jar file in the library of my project . Input file (distance matrix) in csv form . Right now, I am merely curious to see the output of generating initial population.

I've not used Java API extensively so correct me if I have asked anything wrong.

1

There are 1 answers

0
Dan Dyer On

An outline of a the API and the main classes you need to use is included in chapter 2 of the user guide. There is also source code for an evolutionary solution to the Travelling Salesman Problem included in the examples. You can also run this example as an applet if you have the Java plugin enabled in your browser.

In the Watchmaker framework your initial population is created by an instance of the CandidateFactory interface. In the above example I have used the included ListPermutationFactory to generate the initial population since each candidate solution is represented as a simple list of cities.

Your matrix sounds fine so long as your fitness evaluator (which you will have to write yourself) can read it and make sense of it. In the example I just hard-coded the distances (see source).