drasys.or.graph.tsp
Class Composite

java.lang.Object
  |
  +--drasys.or.graph.tsp.Composite
Direct Known Subclasses:
Genius

public class Composite
extends java.lang.Object
implements ConstructI

This class implements a composite TSP algorithm by combining a construction algorithm with an improvement algorithm. A composite TSP algorithm is one that has a construction phase followed by an improvement phase. In the TSP package all basic algorithms are implemented as either a pure construction or improvement class with the associated interface. This class implements the composite algorithm by constructing an initial tour using the construction algorithm and then improving it with the improvement algorithm.


Constructor Summary
Composite(ConstructI construct, ImproveI improve)
           
Composite(ConstructI construct, ImproveI improve, GraphI graph)
           
 
Method Summary
 double constructClosedTour()
          Construct a closed tour solution.
 double constructOpenTour()
          Construct an open tour solution with arbitrary end points.
 double constructOpenTour(java.lang.Object originKey, java.lang.Object destinationKey)
          Construct a tour with explicit end points.
 double constructOpenTourFrom(java.lang.Object originKey)
          Construct an open tour solution with an explicit origin and arbitrary destination.
 double constructOpenTourTo(java.lang.Object destinationKey)
          Construct an open tour solution with an explicit destination and arbitrary origin.
 ConstructI getConstructAlgorithm()
           
 double getCost()
          Returns the cost of the solution tour.
 ImproveI getImproveAlgorithm()
           
 java.util.Vector getTour()
          Returns the solution tour.
 java.util.Vector rotateClosedTour(java.util.Vector tour, java.lang.Object key)
          Rotates the closed tour until the vertex that matches key is the vertex that is repeated on both ends.
 void selectVertex(boolean select)
          Selects all of the vertices in the graph to be in the tour if 'select' is true.
 void selectVertex(boolean[] select)
          Selects all of the vertices whose corresponding element in 'select' is true.
 void selectVertex(java.lang.Object key, boolean select)
          Selects the vertex to be in the tour if 'select' is true.
 void setEdgeKey(java.lang.Object edgeKey)
          Sets the edge key for the construction and improvement algorithms.
 void setGraph(GraphI graph)
          Sets the graph for the construction and improvement algorithms.
 void setProperties(PropertiesI properties)
          Sets the edge properties object for the construction and improvement algorithms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Composite

public Composite(ConstructI construct,
                 ImproveI improve)

Composite

public Composite(ConstructI construct,
                 ImproveI improve,
                 GraphI graph)
Method Detail

getConstructAlgorithm

public ConstructI getConstructAlgorithm()

getImproveAlgorithm

public ImproveI getImproveAlgorithm()

setGraph

public void setGraph(GraphI graph)
Sets the graph for the construction and improvement algorithms.

setProperties

public void setProperties(PropertiesI properties)
Sets the edge properties object for the construction and improvement algorithms.

setEdgeKey

public void setEdgeKey(java.lang.Object edgeKey)
Sets the edge key for the construction and improvement algorithms. The default value for 'edgeKey' is null.

getCost

public double getCost()
Returns the cost of the solution tour.
Throws:
GraphError - if no solution was created.

getTour

public java.util.Vector getTour()
Returns the solution tour.
Throws:
GraphError - if no solution was created.

constructOpenTour

public double constructOpenTour(java.lang.Object originKey,
                                java.lang.Object destinationKey)
                         throws TourNotFoundException,
                                VertexNotFoundException
Construct a tour with explicit end points. An open tour is one where the origin and destination vertices are different.
Specified by:
constructOpenTour in interface ConstructI
Throws:
TourNotFoundException - if the tour can not be constructed.

constructOpenTourFrom

public double constructOpenTourFrom(java.lang.Object originKey)
                             throws TourNotFoundException,
                                    VertexNotFoundException
Construct an open tour solution with an explicit origin and arbitrary destination. An open tour is one where the origin and destination vertices are different.
Specified by:
constructOpenTourFrom in interface ConstructI
Throws:
TourNotFoundException - if the tour can not be constructed.

constructOpenTourTo

public double constructOpenTourTo(java.lang.Object destinationKey)
                           throws TourNotFoundException,
                                  VertexNotFoundException
Construct an open tour solution with an explicit destination and arbitrary origin. An open tour is one where the origin and destination vertices are different.
Specified by:
constructOpenTourTo in interface ConstructI
Throws:
TourNotFoundException - if the tour can not be constructed.

constructOpenTour

public double constructOpenTour()
                         throws TourNotFoundException
Construct an open tour solution with arbitrary end points. An open tour is one where the origin and destination vertices are different.
Specified by:
constructOpenTour in interface ConstructI
Throws:
TourNotFoundException - if the tour can not be constructed.

constructClosedTour

public double constructClosedTour()
                           throws TourNotFoundException
Construct a closed tour solution. A closed tour is one where the origin and destination vertices are the same.
Specified by:
constructClosedTour in interface ConstructI
Throws:
TourNotFoundException - if the tour can not be constructed.

selectVertex

public void selectVertex(boolean[] select)
Selects all of the vertices whose corresponding element in 'select' is true. Unselects all of the vertices whose corresponding element in 'select' is false. All of the vertices are selected by default when the algorithm is constructed.
Specified by:
selectVertex in interface ConstructI

selectVertex

public void selectVertex(boolean select)
Selects all of the vertices in the graph to be in the tour if 'select' is true. Unselects all of the vertices if 'select' is false. All of the vertices are selected by default when the algorithm is constructed.
Specified by:
selectVertex in interface ConstructI

selectVertex

public void selectVertex(java.lang.Object key,
                         boolean select)
                  throws VertexNotFoundException
Selects the vertex to be in the tour if 'select' is true. Unselects the vertex if 'select' is false. All of the vertices are selected by default when the algorithm is constructed.
Specified by:
selectVertex in interface ConstructI

rotateClosedTour

public java.util.Vector rotateClosedTour(java.util.Vector tour,
                                         java.lang.Object key)
                                  throws VertexNotFoundException
Rotates the closed tour until the vertex that matches key is the vertex that is repeated on both ends.


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com