Interface Attribute

All Known Implementing Classes:
CrowdingDistance, Fitness, Niche, NicheDistance, NormalizedObjectives, OperatorIndex, Penalty, Rank

public interface Attribute
Marker interface for accessing attributes. Attributes are metadata associated with a specific solution. While one can call the Solution methods for working with attributes directly, such as Solution.getAttribute(String), these attribute classes provide a standardized and type-safe way to access the attributes.

These classes are implemented with static methods. This design decision was made for performance and simplicity, as an actual class would require extra overhead from calling the constructor and methods. Static (and final) methods can be resolved at compile-time and often in-lined. Additionally, these static methods can be used with Java's functional interfaces (see java.util.function) if more flexibility is required.

While this interface does not mandate any particular implementation, for standardization we recommend the following:

  1. The class should be final
  2. Define public static final String ATTRIBUTE_NAME that identifies the key / name of the attribute
  3. Define the following static final methods:
    1. boolean hasAttribute(Solution)
    2. void setAttribute(Solution, T)
    3. T getAttribute(Solution)
    4. void removeAttribute(Solution) (optional)
Where T is the type of the attribute. Prefer using primitive types and implement any boxing / un-boxing within the getter and setter.