drasys.or.graph.vrp
Class Randomizer

java.lang.Object
  |
  +--drasys.or.graph.vrp.Randomizer
Direct Known Subclasses:
ClarkeWright, GillettMiller

public class Randomizer
extends java.lang.Object
implements ConstructI

A class to randomize VRP algorithms that implement 'Randomizable'.


Constructor Summary
Randomizer(RandomizableI randomizable)
          Constructs a Randomizer to operate on the algorithm 'randomizable'.
 
Method Summary
 void addIterations(int count, int strength)
          Adds a sequence of iterations at a given strength value.
 double constructClosedTours(java.lang.Object depotKey)
          Construct a solution with closed tours that begin and end at the depot vertex.
 double constructInboundTours(java.lang.Object depotKey)
          Construct a solution with open tours that begin at arbitrary vertices and end at the depot vertex.
 double constructOutboundTours(java.lang.Object depotKey)
          Construct a solution with open tours that begin at the depot vertex and end at arbitrary vertices.
 double getCost()
          Returns the total cost of the solution tours.
 double[] getCosts()
          Returns the cost of each tour in the solution.
 double[] getLoads()
          Returns the load for each tour in the solution.
 RandomI getRandom()
          Gets the random number generator.
 java.util.Vector[] getTours()
          Returns the improved tour from the construction algorithm.
 void selectVertex(boolean select)
          Selects all of the vertices in the graph to be in the solution 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 solution if 'select' is true.
 void setCapacityConstraint(double maxLoadPerVehicle)
          Sets the vehicle capacity constraint.
 void setCostConstraint(double maxCostPerVehicle)
          Sets the vehicle cost constraint.
 void setEdgeKey(java.lang.Object edgeKey)
          Sets the key used to select from parallel edges between vertices.
 void setGraph(GraphI graph)
          Sets the graph for the VRP algorithm.
 void setProperties(PropertiesI properties)
          Sets the properties object.
 void setRandom(RandomI random)
          Sets the random number generator.
 void setVehicleCost(double vehicleCost)
          Sets the vehicle cost constraint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Randomizer

public Randomizer(RandomizableI randomizable)
           throws VRPException
Constructs a Randomizer to operate on the algorithm 'randomizable'.
Throws:
VRPException - if 'randomizable' does not implement 'ConstructI' or 'ImproveI'.
Method Detail

addIterations

public void addIterations(int count,
                          int strength)
Adds a sequence of iterations at a given strength value.

setRandom

public void setRandom(RandomI random)
Sets the random number generator.

getRandom

public RandomI getRandom()
Gets the random number generator.

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 solution 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 solution 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

constructOutboundTours

public double constructOutboundTours(java.lang.Object depotKey)
                              throws SolutionNotFoundException,
                                     VertexNotFoundException
Construct a solution with open tours that begin at the depot vertex and end at arbitrary vertices.
Specified by:
constructOutboundTours in interface ConstructI
Throws:
SolutionNotFoundException - if a solution can not be constructed.

constructInboundTours

public double constructInboundTours(java.lang.Object depotKey)
                             throws SolutionNotFoundException,
                                    VertexNotFoundException
Construct a solution with open tours that begin at arbitrary vertices and end at the depot vertex.
Specified by:
constructInboundTours in interface ConstructI
Throws:
SolutionNotFoundException - if a solution can not be constructed.

constructClosedTours

public double constructClosedTours(java.lang.Object depotKey)
                            throws SolutionNotFoundException,
                                   VertexNotFoundException
Construct a solution with closed tours that begin and end at the depot vertex.
Specified by:
constructClosedTours in interface ConstructI
Throws:
SolutionNotFoundException - if a solution can not be constructed.

setGraph

public void setGraph(GraphI graph)
Sets the graph for the VRP algorithm.

setVehicleCost

public void setVehicleCost(double vehicleCost)
Sets the vehicle cost constraint. The units must be the same as the edge traversal costs.

setCostConstraint

public void setCostConstraint(double maxCostPerVehicle)
Sets the vehicle cost constraint.

setCapacityConstraint

public void setCapacityConstraint(double maxLoadPerVehicle)
Sets the vehicle capacity constraint.

setProperties

public void setProperties(PropertiesI properties)
Sets the properties object.

setEdgeKey

public void setEdgeKey(java.lang.Object edgeKey)
Sets the key used to select from parallel edges between vertices. The default value for 'edgeKey' is null.

getTours

public java.util.Vector[] getTours()
                            throws SolutionNotFoundException
Returns the improved tour from the construction algorithm. The vector contains all the edges and the vertices in alternating order starting and ending with a vertex. The elements will always be arranged in the order of forward tour traversal.
Throws:
SolutionNotFoundException - if no solution was created.

getCost

public double getCost()
               throws SolutionNotFoundException
Returns the total cost of the solution tours.
Throws:
SolutionNotFoundException - if no solution was created.

getCosts

public double[] getCosts()
                  throws SolutionNotFoundException
Returns the cost of each tour in the solution.
Throws:
SolutionNotFoundException - if no solution was created.

getLoads

public double[] getLoads()
                  throws SolutionNotFoundException
Returns the load for each tour in the solution.
Throws:
SolutionNotFoundException - if no solution was created.


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