public interface EvaluatedMoveCache
Problem.validate(Solution)
) and
evaluations (see Problem.evaluate(Solution)
) of neighbours obtained by applying moves
to the current solution in a neighbourhood search. Whenever a move is validated and evaluated, the
computed values may be presented to the cache. They can be retrieved later, when the same move is
validated or evaluated again for the same current solution, if these value are still contained
in the cache at that time.
In general, there is no guarantee that cached values will still be available at any later point in time. Every cache implementation may handle cache requests in a specific way, and may store a different number and/or specific selection of values. The only guarantee is that if a value is retrieved from the cache, it will be correct.
When the current solution of a neighbourhood search is modified, any move cache used by this
search should be cleared using clear()
as then the cache is no longer valid.
Note that when using a cache implementation that stores multiple values, it may be beneficial
to override Object.equals(Object)
and Object.hashCode()
in the moves generated
by the applied neighbourhood, to increase the probability of a cache hit.
Modifier and Type | Method and Description |
---|---|
void |
cacheMoveEvaluation(Move<?> move,
Evaluation evaluation)
Request to cache the evaluation (see
Problem.evaluate(Solution) ) of the neighbouring
solution which is obtained by applying the given move to the current solution. |
void |
cacheMoveValidation(Move<?> move,
Validation validation)
Request to cache the validation (see
Problem.validate(Solution) ) of the neighbouring
solution which is obtained by applying the given move to the current solution. |
void |
clear()
Clears all cached values.
|
Evaluation |
getCachedMoveEvaluation(Move<?> move)
Retrieve the cached evaluation (see
Problem.evaluate(Solution) ) of the neighbouring
solution which is obtained by applying the given move to the current solution, if available. |
Validation |
getCachedMoveValidation(Move<?> move)
Retrieve the cached validation (see
Problem.validate(Solution) ) of the neighbouring
solution which is obtained by applying the given move to the current solution, if available. |
void cacheMoveEvaluation(Move<?> move, Evaluation evaluation)
Problem.evaluate(Solution)
) of the neighbouring
solution which is obtained by applying the given move to the current solution. The specific cache
implementation may decide whether to store the given value and/or discard previously cached values.move
- move applied to the current solutionevaluation
- evaluation of the obtained neighbourEvaluation getCachedMoveEvaluation(Move<?> move)
Problem.evaluate(Solution)
) of the neighbouring
solution which is obtained by applying the given move to the current solution, if available.
If this evaluation is not (or no longer) available in the cache, null
is returned.move
- move applied to the current solutionnull
if not available in the cachevoid cacheMoveValidation(Move<?> move, Validation validation)
Problem.validate(Solution)
) of the neighbouring
solution which is obtained by applying the given move to the current solution. The specific cache
implementation may decide whether to store the given value and/or discard previously cached values.move
- move applied to the current solutionvalidation
- validation of the obtained neighbourValidation getCachedMoveValidation(Move<?> move)
Problem.validate(Solution)
) of the neighbouring
solution which is obtained by applying the given move to the current solution, if available.
If this validation is not (or no longer) available in the cache, null
is returned.move
- move applied to the current solutionnull
if not available in the cachevoid clear()
Copyright © 2016. All rights reserved.