Class GreedyAcceptance
java.lang.Object
com.graphhopper.jsprit.core.algorithm.acceptor.GreedyAcceptance
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptSolution(Collection<VehicleRoutingProblemSolution> solutions, VehicleRoutingProblemSolution newSolution) Accepts every solution if solution memory allows.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.graphhopper.jsprit.core.algorithm.acceptor.SolutionAcceptor
getCurrentThreshold
-
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:
acceptSolutionin interfaceSolutionAcceptor- Parameters:
solutions- collection of existing solutionsnewSolution- new solution to be evaluated- Returns:
- true if solution accepted
-
toString
-