Class AbstractConstraint
java.lang.Object
org.moeaframework.core.constraint.AbstractConstraint
- All Implemented Interfaces:
Serializable,Comparable<Constraint>,Constraint,Copyable<Constraint>,Defined,Named
- Direct Known Subclasses:
BoundedConstraint,ThresholdConstraint
Abstract class for implementing constraints. The constraint value is initialized to 0d/0d, which
serves as an indicator the constraint has not been assigned. By convention, implementations should consider this
default value to be feasible.
Constraints can be assigned a name, but if unset will derive its name from its current index by calling
Constraint.getNameOrDefault(Constraint, int). Such constraints 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
ConstructorsConstructorDescriptionConstructs a new, anonymous constraint.AbstractConstraint(String name) Constructs a new constraint 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.constraint.Constraint
compareTo, getMagnitudeOfViolation, isViolation, withValueMethods inherited from interface org.moeaframework.core.Defined
getDefinition
-
Field Details
-
name
The constraint name, ornullif anonymous. -
value
protected double valueThe constraint value.
-
-
Constructor Details
-
AbstractConstraint
public AbstractConstraint()Constructs a new, anonymous constraint. -
AbstractConstraint
Constructs a new constraint with the given name.- Parameters:
name- the constraint name, ornullto create an anonymous constraint
-
-
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:ConstraintSets the value of this constraint.- Specified by:
setValuein interfaceConstraint- Parameters:
value- the value of this constraint
-
getValue
public double getValue()Description copied from interface:ConstraintReturns the value of this constraint.- Specified by:
getValuein interfaceConstraint- Returns:
- the value of this constraint
-
toString
-
hashCode
public int hashCode() -
equals
-