org.apache.mahout.ga.watchmaker.travellingsalesman
Class EvolutionaryTravellingSalesman

java.lang.Object
  extended by org.apache.mahout.ga.watchmaker.travellingsalesman.EvolutionaryTravellingSalesman
All Implemented Interfaces:
TravellingSalesmanStrategy

public class EvolutionaryTravellingSalesman
extends Object
implements TravellingSalesmanStrategy

Evolutionary algorithm for finding (approximate) solutions to the travelling salesman problem.
The original code is from the Watchmaker project (https://watchmaker.dev.java.net/).
Modified to use Mahout whenever requested.


Constructor Summary
EvolutionaryTravellingSalesman(DistanceLookup distances, org.uncommons.watchmaker.framework.SelectionStrategy<? super List<String>> selectionStrategy, int populationSize, int eliteCount, int generationCount, boolean crossover, boolean mutation, boolean mahout)
          Creates an evolutionary Travelling Salesman solver with the specified configuration.
 
Method Summary
 List<String> calculateShortestRoute(Collection<String> cities, ProgressListener progressListener)
          Calculates the shortest route using a generational evolutionary algorithm with a single ordered mutation operator and truncation selection.
 String getDescription()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EvolutionaryTravellingSalesman

public EvolutionaryTravellingSalesman(DistanceLookup distances,
                                      org.uncommons.watchmaker.framework.SelectionStrategy<? super List<String>> selectionStrategy,
                                      int populationSize,
                                      int eliteCount,
                                      int generationCount,
                                      boolean crossover,
                                      boolean mutation,
                                      boolean mahout)
Creates an evolutionary Travelling Salesman solver with the specified configuration.

Parameters:
distances - Information about the distances between cities.
selectionStrategy - The selection implementation to use for the evolutionary algorithm.
populationSize - The number of candidates in the population of evolved routes.
eliteCount - The number of candidates to preserve via elitism at each generation.
generationCount - The number of iterations of evolution to perform.
crossover - Whether or not to use a cross-over operator in the evolution.
mutation - Whether or not to use a mutation operator in the evolution.
mahout - Whether or not to use Mahout for evaluation.
Method Detail

getDescription

public String getDescription()
Specified by:
getDescription in interface TravellingSalesmanStrategy
Returns:
A description of the strategy.

calculateShortestRoute

public List<String> calculateShortestRoute(Collection<String> cities,
                                           ProgressListener progressListener)
Calculates the shortest route using a generational evolutionary algorithm with a single ordered mutation operator and truncation selection.

Specified by:
calculateShortestRoute in interface TravellingSalesmanStrategy
Parameters:
cities - The list of destinations, each of which must be visited once.
progressListener - Call-back for receiving the status of the algorithm as it progresses.
Returns:
The (approximate) shortest route that visits each of the specified cities once.


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.