drasys.or.graph.vrp
Class BestOf

java.lang.Object
  |
  +--drasys.or.graph.vrp.VRPBase
        |
        +--drasys.or.graph.vrp.ConstructBase
              |
              +--drasys.or.graph.vrp.BestOf
Direct Known Subclasses:
BestOfAll

public class BestOf
extends ConstructBase
implements ConstructI

This class implements a composite VRP algorithm by combining a set of construction algorithms with a set of improvement algorithms. A composite VRP algorithm is one that has a construction phase followed by an improvement phase. In the VRP package all basic algorithms are implemented as either a pure construction or improvement class with the associated interface. This class implements the construction phase by constructing a solution using each of the construction algorithms and retaining the best. Then in the improvement phase each of the improvement algorithms are applied in turn to improve the retained solution. If the new solution is an improvement then it becomes the retained solution.


Fields inherited from class drasys.or.graph.vrp.ConstructBase
_selected
 
Fields inherited from class drasys.or.graph.vrp.VRPBase
_closed, _depotKey, _edgeKey, _graph, _maxCost, _maxLoad, _out, _properties, _vehicleCost
 
Constructor Summary
BestOf()
           
BestOf(GraphI graph)
           
 
Method Summary
 void addConstruct(ConstructI construct)
          Adds a construction algorithm.
 void addConstruct(ConstructI construct, int minSize, int maxSize)
          Adds a construction algorithm.
 void addImprove(ImproveI improve)
          Adds an improvement algorithm.
 void addImprove(ImproveI improve, int minSize, int maxSize)
          Adds an improvement algorithm.
 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.
 java.util.Vector[] getTours()
          Returns the improved tour from the construction algorithm.
 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 edge key for all of the contained VRP algorithms.
 void setGraph(GraphI graph)
          Sets the graph for all of the contained VRP algorithms.
 void setProperties(PropertiesI properties)
          Sets the properties object for all of the contained VRP algorithms.
 void setVehicleCost(double vehicleCost)
          Sets the vehicle cost.
 
Methods inherited from class drasys.or.graph.vrp.ConstructBase
isSelected, selectVertex, selectVertex, selectVertex, sizeOfSelected
 
Methods inherited from class drasys.or.graph.vrp.VRPBase
copyTours, getCost, getGraph, getLoad, getLoads
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BestOf

public BestOf()

BestOf

public BestOf(GraphI graph)
Method Detail

addConstruct

public void addConstruct(ConstructI construct)
Adds a construction algorithm. The default minimum problem size is zero. The default maximum problem size is Integer.MAX_VALUE. If the graph has been set, then it is set in the added algorithm.

addConstruct

public void addConstruct(ConstructI construct,
                         int minSize,
                         int maxSize)
Adds a construction algorithm. The algorithm will not be exectued on problems with a dimension less than 'minSize' or greater than 'maxSize'. If the graph has been set, then it is set in the added algorithm.

addImprove

public void addImprove(ImproveI improve)
Adds an improvement algorithm. The default minimum problem size is zero. The default maximum problem size is Integer.MAX_VALUE. If the graph has been set, then it is set in the added algorithm.

addImprove

public void addImprove(ImproveI improve,
                       int minSize,
                       int maxSize)
Adds an improvement algorithm. The algorithm will not be exectued on problems with a dimension less than 'minSize' or greater than 'maxSize'. If the graph has been set, then it is set in the added algorithm.

setGraph

public void setGraph(GraphI graph)
Sets the graph for all of the contained VRP algorithms.
Overrides:
setGraph in class ConstructBase

setProperties

public void setProperties(PropertiesI properties)
Sets the properties object for all of the contained VRP algorithms.
Overrides:
setProperties in class ConstructBase

setEdgeKey

public void setEdgeKey(java.lang.Object edgeKey)
Sets the edge key for all of the contained VRP algorithms. The default value for 'edgeKey' is null.
Overrides:
setEdgeKey in class ConstructBase

setVehicleCost

public void setVehicleCost(double vehicleCost)
Sets the vehicle cost. The cost must be the same units as the edge traversal costs.
Overrides:
setVehicleCost in class VRPBase

setCostConstraint

public void setCostConstraint(double maxCostPerVehicle)
Sets the vehicle cost constraint.
Overrides:
setCostConstraint in class VRPBase

setCapacityConstraint

public void setCapacityConstraint(double maxLoadPerVehicle)
Sets the vehicle capacity constraint.
Overrides:
setCapacityConstraint in class VRPBase

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.

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:
VRPError - if no solution was created.

getCost

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

getLoads

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

getCosts

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


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