org.jamesframework.core.problems.objectives

## Interface Objective<SolutionType extends Solution,DataType>

• Type Parameters:
SolutionType - solution type to be evaluated, required to extend Solution
DataType - underlying data type

public 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.

Author:
Herman De Beukelaer
• ### Method Summary

All Methods
Modifier and Type Method and Description
default <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).
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.
• ### Method Detail

• #### evaluate

Evaluation evaluate(SolutionType solution,
DataType data)
Evaluates a given solution using the given data. Returns an object of type Evaluation. The corresponding double value can be obtained by calling Evaluation.getValue() on this evaluation object.
Parameters:
solution - solution to evaluate
data - underlying data used for evaluation
Returns:
evaluation of the given solution
• #### evaluate

default <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.

Type Parameters:
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 move
Parameters:
move - move to evaluate
curSolution - current solution
curEvaluation - evaluation of current solution
data - underlying data used for evaluation
Returns:
evaluation of modified solution obtained when applying the move to the current solution
Throws:
IncompatibleDeltaEvaluationException - if the provided delta evaluation is not compatible with the received move type
• #### isMinimizing

boolean isMinimizing()
Check whether the produced evaluations are to be minimized.
Returns:
true if evaluations are to be minimized, false if they are to be maximized