Salesman example: findOptimalPath issues

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Salesman example: findOptimalPath issues

thealy
I'm wrestling with the basic TravellingSalesman.java example to try and
understand JGAP in general. I've copied the code into NetBeans so I can
use the debugger.

I started by pushing up the number of cities so I could play with the
number of evolutions, population size, etc. I was attempting to use the
setAcceptableCost method when I got stuck. I attempted to set the value
to CITIES+1. My results were not consistent at all.

So I dragged the Salesman.java into the debugger under my own package,
along with SalesmanFitnessFunction. I let the acceptable cost default to
-1. I found that the code below (from within findOptimalPath method of
Salesman) ALWAYS exits on the first loop since I'm getting best fitness
values like 1.073741809E9 in this loop, and acceptable cost is -1 (default).

     Evolution:

         for (int i = 0; i < getMaxEvolution(); i++) {

            population.evolve();
            best = population.getFittestChromosome();

 >>>           if (best.getFitnessValue() >= getAcceptableCost()) {

               break Evolution;
            }
         }
         // Return the best solution we found.
         // ----------------------------------
         return(best);


When the sample program exits, it displays the "score" value that seems
to be what I really want to compare to my "acceptable cost" i.e if there
are 15 cities, I will accept any score < 17 for example.

I don't understand what this how this code (from main of
TravellingSalesman.java):

      System.out.println("Score " +
(Integer.MAX_VALUE / 2 - optimal.getFitnessValue()));

Relates to the values like 1.073741809 E9 that I'm seeing in the
evolution loop.

Sorry if I'm making some bonehead newbie error here, but what am I missing?

Thanks,

Terry

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
jgap-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgap-users