SolutionType
- solution type to be evaluated, required to extend Solution
DataType
- underlying data typepublic interface Objective<SolutionType extends Solution,DataType>
Interface of an objective function that evaluates solutions using underlying data. An objective can be either maximizing or minimizing; in the former case increasing scores indicate improvement, while in the latter case decreasing scores indicate improvement.
It is required to provide a full evaluation by implementing evaluate(Solution, Object)
.
If desired, an efficient delta evaluation can also be provided by overriding the default behaviour
of evaluate(Move, Solution, Evaluation, Object)
which (1) applies the move, (2) performs
a full evaluation and (3) undoes the move.
Modifier and Type | Method and Description |
---|---|
default <ActualSolutionType extends SolutionType> |
evaluate(Move<? super ActualSolutionType> move,
ActualSolutionType curSolution,
Evaluation curEvaluation,
DataType data)
Evaluates a move that will be applied to the current solution of a local search (delta evaluation).
|
Evaluation |
evaluate(SolutionType solution,
DataType data)
Evaluates a given solution using the given data.
|
boolean |
isMinimizing()
Check whether the produced evaluations are to be minimized.
|
Evaluation evaluate(SolutionType solution, DataType data)
Evaluation
.
The corresponding double value can be obtained by calling Evaluation.getValue()
on this
evaluation object.solution
- solution to evaluatedata
- underlying data used for evaluationdefault <ActualSolutionType extends SolutionType> Evaluation evaluate(Move<? super ActualSolutionType> move, ActualSolutionType curSolution, Evaluation curEvaluation, DataType data)
Evaluates a move that will be applied to the current solution of a local search (delta evaluation).
The result corresponds to the evaluation of the modified solution that would be obtained by applying
the given move to the current solution. A default implementation is provided that (1) applies the move,
(2) computes a full evaluation by calling evaluate(Solution, Object)
and (3) undoes the applied move.
It is often possible to provide a custom, much more efficient delta evaluation that computes
the modified evaluation based on the current evaluation and the changes that will be made
when applying the move to the current solution. This can be done by overriding this method.
It is usually required to cast the received move to a specific type so that this objective
can only be used in combination with neighbourhoods that generate moves of this type (or a
subtype). If an incompatible move type is received, an IncompatibleDeltaEvaluationException
may be thrown.
Given that both this method and the full evaluation (evaluate(Solution, Object)
) return
evaluations of the same type, it is guaranteed that curEvaluation
will also be of
this specific type and it is safe to perform a cast, if required.
ActualSolutionType
- the actual solution type of the problem that is being solved;
a subtype of the solution types of both the objective and the applied movemove
- move to evaluatecurSolution
- current solutioncurEvaluation
- evaluation of current solutiondata
- underlying data used for evaluationIncompatibleDeltaEvaluationException
- if the provided delta evaluation is not compatible
with the received move typeboolean isMinimizing()
true
if evaluations are to be minimized,
false
if they are to be maximizedCopyright © 2016. All rights reserved.