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

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

All Implemented Interfaces:
  TravellingSalesmanStrategy

    public class BruteForceTravellingSalesman

extends Object
implements TravellingSalesmanStrategy

Naive brute-force solution to the travelling salesman problem. It would take about a day and a half to brute-force the 15-city travelling salesman problem on a home computer using this implementation. However, this is a not the best possible implementation that is guaranteed to find a the shortest route (for example there is no branch-and-bound optimisation).
The original code is from the Watchmaker project (https://watchmaker.dev.java.net/).

Constructor Summary
`BruteForceTravellingSalesman(DistanceLookup distances)`

Method Summary
`List<String>` `calculateShortestRoute(Collection<String> cities, ProgressListener progressListener)` To reduce the search space we will only consider routes that start and end at one city (whichever is first in the collection).
`String` `getDescription()`

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

Constructor Detail

### BruteForceTravellingSalesman

    public BruteForceTravellingSalesman(DistanceLookup distances)

Parameters:
  `distances` - Information about the distances between cities.

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)

  To reduce the search space we will only consider routes that start and end at one city (whichever is first in the collection). All other possible routes are equivalent to one of these routes since start city is irrelevant in determining the shortest cycle.

  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. May be null.
  Returns:
    The shortest route that visits each of the specified cities once.

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