Class GreedyAcceptance

java.lang.Object
com.graphhopper.jsprit.core.algorithm.acceptor.GreedyAcceptance
All Implemented Interfaces:
SolutionAcceptor

public class GreedyAcceptance extends Object implements SolutionAcceptor
Acceptor that accepts solutions to be memorized only better solutions.

If there is enough memory, every solution will be accepted. If there is no memory anymore and the solution to be evaluated is better than the worst, the worst will be replaced by the new solution.

  • Constructor Details

    • GreedyAcceptance

      public GreedyAcceptance(int solutionMemory)
  • Method Details

    • acceptSolution

      public boolean acceptSolution(Collection<VehicleRoutingProblemSolution> solutions, VehicleRoutingProblemSolution newSolution)
      Accepts every solution if solution memory allows. If memory occupied, than accepts new solution only if better than the worst in memory. Consequently, the worst solution is removed from solutions, and the new solution added.

      Note that this modifies Collection solutions.

      Specified by:
      acceptSolution in interface SolutionAcceptor
      Parameters:
      solutions - collection of existing solutions
      newSolution - new solution to be evaluated
      Returns:
      true if solution accepted
    • toString

      public String toString()
      Overrides:
      toString in class Object