tasks
Class TSPTask

java.lang.Object
  extended by api.Task
      extended by tasks.TSPTask
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Task>

public class TSPTask
extends Task

Class for computing TSP. May reduce to further TSP tasks.

See Also:
Serialized Form

Constructor Summary
TSPTask(int[] path, int[] remaining, TaskId taskId, TaskId successorId, int successorInputIndex, double[][] coords)
          TSPTask constructor
 
Method Summary
 Result execute()
          Executes the TSPTask
 boolean executeOnServer()
          Method for checking whether this task should execute on the server
 boolean isWorseThan(TSPResult res)
          determines whether we can prune, if the lower bnd on this partial path is greater than the best path found so far.
 TSPResult permute(int[] v, int start)
          Find the minimum TSP tour by exhaustively try all permutations
 
Methods inherited from class api.Task
compareTo, getShared, getSuccessorId, getSuccessorInputIndex, getTaskId, sendEvent, setComputer, updateShared
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TSPTask

public TSPTask(int[] path,
               int[] remaining,
               TaskId taskId,
               TaskId successorId,
               int successorInputIndex,
               double[][] coords)
TSPTask constructor

Parameters:
coords -
path - the ordered path up to this point
remaining - the unordered remaining cities
taskId - the task id
successorId - the successor task id
successorInputIndex - the input index of the successor.
Method Detail

executeOnServer

public boolean executeOnServer()
Description copied from class: Task
Method for checking whether this task should execute on the server

Specified by:
executeOnServer in class Task
Returns:

isWorseThan

public boolean isWorseThan(TSPResult res)
determines whether we can prune, if the lower bnd on this partial path is greater than the best path found so far.

Parameters:
res - Result that stores current best distance.
Returns:
true if we can prune, false otherwise.

execute

public Result execute()
Executes the TSPTask

Specified by:
execute in class Task
Returns:
a Container of TSPTask execution results

permute

public TSPResult permute(int[] v,
                         int start)
Find the minimum TSP tour by exhaustively try all permutations

Parameters:
v - the array of city indices
start - the array position to begin the permutations
Returns:
a TSPResult storing the minimum path