basics
Class VehicleRoutingAlgorithm

java.lang.Object
  extended by basics.VehicleRoutingAlgorithm

public class VehicleRoutingAlgorithm
extends java.lang.Object

Algorithm that solves a VehicleRoutingProblem.

Author:
stefan schroeder

Field Summary
static int NOBREAK
           
 
Constructor Summary
VehicleRoutingAlgorithm(VehicleRoutingProblem problem, java.util.Collection<VehicleRoutingProblemSolution> initialSolutions, SearchStrategyManager searchStrategyManager)
           
VehicleRoutingAlgorithm(VehicleRoutingProblem problem, SearchStrategyManager searchStrategyManager)
           
 
Method Summary
 void addInitialSolution(VehicleRoutingProblemSolution solution)
          Adds solution to the collection of initial solutions.
 VehicleRoutingAlgorithmListeners getAlgorithmListeners()
           
 int getNuOfIterations()
          Returns the number of iterations.
 SearchStrategyManager getSearchStrategyManager()
          Gets the SearchStrategyManager.
 java.util.Collection<VehicleRoutingProblemSolution> searchSolutions()
          Runs the vehicle routing algorithm and returns a number of generated solutions.
 void setNuOfIterations(int nOfIterations)
           
 void setPrematureAlgorithmBreaker(PrematureAlgorithmBreaker prematureAlgorithmBreaker)
           
 void setPrematureBreak(int nuIterationsWithoutImprovement)
          Sets premature break.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOBREAK

public static final int NOBREAK
See Also:
Constant Field Values
Constructor Detail

VehicleRoutingAlgorithm

public VehicleRoutingAlgorithm(VehicleRoutingProblem problem,
                               SearchStrategyManager searchStrategyManager)

VehicleRoutingAlgorithm

public VehicleRoutingAlgorithm(VehicleRoutingProblem problem,
                               java.util.Collection<VehicleRoutingProblemSolution> initialSolutions,
                               SearchStrategyManager searchStrategyManager)
Method Detail

addInitialSolution

public void addInitialSolution(VehicleRoutingProblemSolution solution)
Adds solution to the collection of initial solutions.

Parameters:
solution -

setPrematureBreak

public void setPrematureBreak(int nuIterationsWithoutImprovement)
Sets premature break.

This breaks the algorithm prematurely after the assigned number of iterations without improvement (see input parameter). Improvement is what SolutionAcceptor understands about improvement. Or to put it in other words, the algo breaks prematurely after the assigned number of iterations without solution-acceptance.

Parameters:
nuIterationsWithoutImprovement -

setPrematureAlgorithmBreaker

public void setPrematureAlgorithmBreaker(PrematureAlgorithmBreaker prematureAlgorithmBreaker)

getSearchStrategyManager

public SearchStrategyManager getSearchStrategyManager()
Gets the SearchStrategyManager.

Returns:
SearchStrategyManager

searchSolutions

public java.util.Collection<VehicleRoutingProblemSolution> searchSolutions()
Runs the vehicle routing algorithm and returns a number of generated solutions.

The algorithm runs as long as it is specified in nuOfIterations and prematureBreak. In each iteration it selects a searchStrategy according to searchStrategyManager and runs the strategy to improve solutions.

Note that clients are allowed to observe/listen the algorithm. See VehicleRoutingAlgorithmListener and its according listeners.

Returns:
Collection the solutions
See Also:
SearchStrategyManager}, {@link VehicleRoutingAlgorithmListener}, {@link AlgorithmStartsListener}, {@link AlgorithmEndsListener}, {@link IterationStartsListener}, {@link IterationEndsListener}

getNuOfIterations

public int getNuOfIterations()
Returns the number of iterations.

Returns:
iterations

getAlgorithmListeners

public VehicleRoutingAlgorithmListeners getAlgorithmListeners()

setNuOfIterations

public void setNuOfIterations(int nOfIterations)