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
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructs a new, anonymous objective.protectedAbstractObjective(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, waitMethods 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, ornullif 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, ornullto create an anonymous objective
-
-
Method Details
-
getName
Description copied from interface:NamedReturns 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.
nullcan 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:ObjectiveSets the objective value. -
getValue
public double getValue()Description copied from interface:ObjectiveReturns the objective value. -
getDefinition
Description copied from interface:DefinedReturns the string representation, or definition, of this object.- Specified by:
getDefinitionin interfaceDefined- Returns:
- the definition
-
toString
-
hashCode
public int hashCode() -
equals
-