org.jamesframework.ext.problems.objectives

## Class WeightedIndex<SolutionType extends Solution,DataType>

• java.lang.Object
• org.jamesframework.ext.problems.objectives.WeightedIndex<SolutionType,DataType>
• Type Parameters:
SolutionType - solution type to be evaluated, required to extend Solution
DataType - underlying data type
All Implemented Interfaces:
Objective<SolutionType,DataType>

public class WeightedIndex<SolutionType extends Solution,DataType>
extends Object
implements Objective<SolutionType,DataType>
An index that is composed as a weighted sum of several objectives. A weighted index is always maximizing, scores for contained minimizing objectives are negated so that maximization of the weighted sum still corresponds to minimization of these objectives.
Author:
Herman De Beukelaer
• ### Constructor Summary

Constructors
Constructor and Description
WeightedIndex()
Create an empty weighted index.
• ### Method Summary

All Methods
Modifier and Type Method and Description
void addObjective(Objective<? super SolutionType,? super DataType> objective, double weight)
Add an objective with corresponding weight.
<ActualSolutionType extends SolutionType>WeightedIndexEvaluation evaluate(Move<? super ActualSolutionType> move, ActualSolutionType curSolution, Evaluation curEvaluation, DataType data)
Delta evaluation.
WeightedIndexEvaluation evaluate(SolutionType solution, DataType data)
Produces an evaluation object that reflects the weighted sum of evaluations of all underlying objectives.
boolean isMinimizing()
Weighted index is always maximizing, so this method always returns false.
boolean removeObjective(Objective<? super SolutionType,? super DataType> objective)
Remove an objective, if present.
String toString()
Create string representation that points out the included objectives and corresponding weights.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
• ### Constructor Detail

• #### WeightedIndex

public WeightedIndex()
Create an empty weighted index.
• ### Method Detail

public void addObjective(Objective<? super SolutionType,? super DataType> objective,
double weight)
Add an objective with corresponding weight. Any objective designed for the solution type and data type of this multi-objective (or for more general solution or data types) can be added. The specified weight should be strictly positive, if not, an exception will be thrown.
Parameters:
objective - objective to be added
weight - corresponding weight (strictly positive)
Throws:
IllegalArgumentException - if the specified weight is not strictly positive
• #### removeObjective

public boolean removeObjective(Objective<? super SolutionType,? super DataType> objective)
Remove an objective, if present. Returns true if the objective has been successfully removed, false if it was not contained in the index.
Parameters:
objective - objective to remove
Returns:
true if the objective has been successfully removed
• #### isMinimizing

public boolean isMinimizing()
Weighted index is always maximizing, so this method always returns false. Scores for contained minimizing objectives are negated, i.e. their sign is flipped.
Specified by:
isMinimizing in interface Objective<SolutionType extends Solution,DataType>
Returns:
false
• #### evaluate

public WeightedIndexEvaluation evaluate(SolutionType solution,
DataType data)
Produces an evaluation object that reflects the weighted sum of evaluations of all underlying objectives.
Specified by:
evaluate in interface Objective<SolutionType extends Solution,DataType>
Parameters:
solution - solution to evaluate
data - data to be used for evaluation
Returns:
weighted index evaluation
• #### evaluate

public <ActualSolutionType extends SolutionType> WeightedIndexEvaluation evaluate(Move<? super ActualSolutionType> move,
ActualSolutionType curSolution,
Evaluation curEvaluation,
DataType data)
Delta evaluation. Computes a delta evaluation for each contained objective and wraps the obtained modified evaluations in a new weighted index evaluation.
Specified by:
evaluate in interface Objective<SolutionType extends Solution,DataType>
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 be evaluated
curSolution - current solution of a local search
curEvaluation - evaluation of current solution
data - data to be used for evaluation
Returns:
weighted index evaluation of obtained neighbour when applying the move
• #### toString

public String toString()
Create string representation that points out the included objectives and corresponding weights.
Overrides:
toString in class Object
Returns:
string representation