Package org.moeaframework.core.objective
Interface Objective
- All Superinterfaces:
Comparable<Objective>
,Copyable<Objective>
,Defined
,Named
,Serializable
- All Known Implementing Classes:
AbstractObjective
,Maximize
,Minimize
,NormalizedObjective
public interface Objective
extends Comparable<Objective>, Copyable<Objective>, Serializable, Defined, Named
Defines an objective for optimization, including the value and the direction.
Always prefer using one of the methods, such as compareTo(Objective)
, for performing operations on
objectives rather than using the value directly, as the methods accounts for the direction.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.moeaframework.core.Defined
Defined.ConstructorComparator
-
Method Summary
Modifier and TypeMethodDescriptiondefault double
applyWeight
(double weight) Applies a weight to this objective.int
compareTo
(double value) Similar toComparable.compareTo(Object)
, compares this objective to a given value.default int
static Objective
Returns a new instance of the default optimization objective.default double
distanceTo
(double value) Computes the distance between two objectives.default double
distanceTo
(Objective other) Computes the distance between two objectives.double
Returns the canonical value of this objective.default double
getEpsilonDistance
(double epsilon) The distance this objective must change, in the direction of the ideal value, to fall within the next epsilon box.default int
getEpsilonIndex
(double epsilon) Returns the index used by epsilon-dominance.double
Returns the ideal or best possible value for this objective.static String
getNameOrDefault
(Objective objective, int index) Returns the name of the objective, using either the name assigned to the objective or deriving the name from its index.double
getValue()
Returns the objective value.static double
Returns the objective value considered better or more ideal.static double
Returns the objective value considered better or more ideal.static Objective
Returns the objective considered better or more ideal.normalize
(double minimum, double maximum) Returns a normalized objective that is: scaled between the minimum and maximum bounds, typically producing a value falling between[0, 1]
, and has an ideal or target value ofDouble#NEGATIVE_INFINITY
.void
setValue
(double value) Sets the objective value.default Objective
withValue
(double value) Updates this objective with the given objective value and returns itself.Methods inherited from interface org.moeaframework.core.Defined
getDefinition
-
Method Details
-
getValue
double getValue()Returns the objective value.- Returns:
- the objective value
-
setValue
void setValue(double value) Sets the objective value.- Parameters:
value
- the objective value
-
getCanonicalValue
double getCanonicalValue()Returns the canonical value of this objective.The canonical value is the objective converted into a minimized form, with the target or ideal towards -1d/0d. This allows an implementation to use the numeric value of the objective directly, without needing to be aware of the optimization direction. This works since minimizing
-f(x)
is equivalent to maximizingf(x)
.- Returns:
- the canonical value
-
compareTo
int compareTo(double value) Similar toComparable.compareTo(Object)
, compares this objective to a given value.- Parameters:
value
- the value- Returns:
-1
,0
, or1
depending if this objective is less than, equal to, or greater than the given value
-
normalize
Returns a normalized objective that is:- scaled between the minimum and maximum bounds, typically producing a value falling between
[0, 1]
, and - has an ideal or target value of
Double#NEGATIVE_INFINITY
.
- Parameters:
minimum
- the minimum boundmaximum
- the maximum bound- Returns:
- the normalized objective
- scaled between the minimum and maximum bounds, typically producing a value falling between
-
withValue
Updates this objective with the given objective value and returns itself.- Parameters:
value
- the objective value- Returns:
- a reference to this objective
-
getEpsilonIndex
default int getEpsilonIndex(double epsilon) Returns the index used by epsilon-dominance. This is used byEpsilonBoxDominanceArchive
in its dominance calculations.This calculation is based on the canonical value of the objective, and as such the returned value is minimized.
- Parameters:
epsilon
- the epsilon value- Returns:
- the index
-
getEpsilonDistance
default double getEpsilonDistance(double epsilon) The distance this objective must change, in the direction of the ideal value, to fall within the next epsilon box. This is used byEpsilonBoxDominanceArchive
when comparing solutions within the same epsilon box.- Parameters:
epsilon
- the epsilon value- Returns:
- the distance
-
applyWeight
default double applyWeight(double weight) Applies a weight to this objective.This calculation is based on the canonical value of the objective, and as such the returned value is minimized.
- Parameters:
weight
- the weight- Returns:
- the weighted objective value
-
getIdealValue
double getIdealValue()Returns the ideal or best possible value for this objective.- Returns:
- the ideal objective value
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Objective>
-
distanceTo
Computes the distance between two objectives.- Parameters:
other
- the other objective- Returns:
- the distance, a non-negative number
-
distanceTo
default double distanceTo(double value) Computes the distance between two objectives.- Parameters:
value
- the other objective value- Returns:
- the distance, a non-negative number
-
ideal
Returns the objective considered better or more ideal. If the objectives are equivalent, either objective will be returned.- Parameters:
first
- the first objectivesecond
- the second objective- Returns:
- the more ideal objective
- See Also:
-
ideal
Returns the objective value considered better or more ideal.- Parameters:
first
- the first objective valuesecond
- the second objective- Returns:
- the ideal objective value
- See Also:
-
ideal
Returns the objective value considered better or more ideal.- Parameters:
first
- the first objective valuesecond
- the second objective- Returns:
- the ideal objective value
- See Also:
-
createDefault
Returns a new instance of the default optimization objective. This is the objective used if not explicitly configured by the problem or user.- Returns:
- the default optimization objective
-
getNameOrDefault
Returns the name of the objective, using either the name assigned to the objective or deriving the name from its index.- Parameters:
objective
- the objectiveindex
- the index of the objective- Returns:
- the name of the objective
-