Package org.moeaframework.core.objective
Class AbstractObjective
java.lang.Object
org.moeaframework.core.objective.AbstractObjective
- All Implemented Interfaces:
Serializable
,Comparable<Objective>
,Copyable<Objective>
,Defined
,Named
,Objective
Abstract class for implementing objectives. The objective value is initialized to 0d/0d, which
serves as an indicator that the objective has not been assigned.
Objectives can be assigned a name, but if unset will derive its name from its current index by calling
Objective.getNameOrDefault(Objective, int)
. Such objectives are also called "anonymous".
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.moeaframework.core.Defined
Defined.ConstructorComparator
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionConstructs a new, anonymous objective.protected
AbstractObjective
(String name) Constructs a new objective with the given name. -
Method Summary
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.moeaframework.core.objective.Objective
applyWeight, compareTo, compareTo, distanceTo, distanceTo, getCanonicalValue, getEpsilonDistance, getEpsilonIndex, getIdealValue, normalize, withValue
-
Field Details
-
name
The objective name, ornull
if anonymous. -
value
protected double valueThe objective value.
-
-
Constructor Details
-
AbstractObjective
public AbstractObjective()Constructs a new, anonymous objective. -
AbstractObjective
Constructs a new objective with the given name.- Parameters:
name
- the objective name, ornull
to create an anonymous objective
-
-
Method Details
-
getName
Description copied from interface:Named
Returns the name of this object. The format for the name depends on the specific implementation, but in general we recommend:- Prefer using alphanumeric characters including
'_'
and'-'
. - Avoid whitespace and other control characters.
null
can be returned, if allowed by the implementation, to indicate the object is anonymous or has no assigned name.
- Prefer using alphanumeric characters including
-
setValue
public void setValue(double value) Description copied from interface:Objective
Sets the objective value. -
getValue
public double getValue()Description copied from interface:Objective
Returns the objective value. -
getDefinition
Description copied from interface:Defined
Returns the string representation, or definition, of this object.- Specified by:
getDefinition
in interfaceDefined
- Returns:
- the definition
-
toString
-
hashCode
public int hashCode() -
equals
-