## org.apache.mahout.ga.watchmaker.travellingsalesman
Class RouteEvaluator

    java.lang.Object
      org.apache.mahout.ga.watchmaker.travellingsalesman.RouteEvaluator

All Implemented Interfaces:
  org.uncommons.watchmaker.framework.FitnessEvaluator<List<String>>

    public class RouteEvaluator

extends Object
implements org.uncommons.watchmaker.framework.FitnessEvaluator<List<String>>

Fitness evalator that measures the total distance of a route in the travelling salesman problem. The fitness score of a route is the total distance (in km). A route is represented as a list of cities in the order that they will be visited. The last leg of the journey is from the last city in the list back to the first.
The original code is from the Watchmaker project (https://watchmaker.dev.java.net/).

Constructor Summary
`RouteEvaluator(DistanceLookup distances)`

Method Summary
`double` `getFitness(List<String> candidate, List<? extends List<String>> population)` Calculates the length of an evolved route.
`boolean` `isNatural()` Returns false since shorter distances represent fitter candidates.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RouteEvaluator

    public RouteEvaluator(DistanceLookup distances)

Parameters:
  `distances` - Provides distances between a set of cities.

Method Detail

### getFitness

    public double getFitness(List<String> candidate,
                             List<? extends List<String>> population)

  Calculates the length of an evolved route.

  Specified by:
    `getFitness` in interface `org.uncommons.watchmaker.framework.FitnessEvaluator<List<String>>`
  Parameters:
    `candidate` - The route to evaluate.
    `population` -
  Returns:
    The total distance (in kilometres) of a journey that visits each city in order and returns to the starting point.

### isNatural

    public boolean isNatural()

  Returns false since shorter distances represent fitter candidates.

  Specified by:
    `isNatural` in interface `org.uncommons.watchmaker.framework.FitnessEvaluator<List<String>>`
  Returns:
    false

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