Class ClusterableSolution

java.lang.Object
org.moeaframework.util.clustering.ClusterableSolution
All Implemented Interfaces:
org.apache.commons.math3.ml.clustering.Clusterable

public class ClusterableSolution extends Object implements org.apache.commons.math3.ml.clustering.Clusterable
Clusterable wrapper for a Solution that associates the point used for clustering with each solution. The primary purpose of this wrapper is to allow defining different points depending on the context, such as clustering based on decision variables or objective values. Storing the point also avoids any unnecessary copying or cloning of the underlying data.
  • Constructor Details

    • ClusterableSolution

      public ClusterableSolution(Solution solution, double[] point)
      Constructs a new clusterable solution.
      Parameters:
      solution - the solution
      point - the point used for clustering
  • Method Details

    • getSolution

      public Solution getSolution()
      Returns the solution.
      Returns:
      the solution
    • getPoint

      public double[] getPoint()
      Returns the point used for clustering. This method is intended for internal use by the clustering algorithms. Do not modify the contents of the array, as it can result in undefined behavior!
      Specified by:
      getPoint in interface org.apache.commons.math3.ml.clustering.Clusterable
      Returns:
      the point
    • withObjectives

      public static ClusterableSolution withObjectives(Solution solution)
      Constructs a clusterable solution based on the objective values of the solution.
      Parameters:
      solution - the solution
      Returns:
      the clusterable solution based on the objective values
    • withVariables

      public static ClusterableSolution withVariables(Solution solution)
      Constructs a clusterable solution based on the decision variables of the solution. This only supports numeric decision variables, such as RealVariable and BinaryIntegerVariable, and will throw if any supported type is given.
      Parameters:
      solution - the solution
      Returns:
      the clusterable solution based on the decision variables
      Throws:
      IllegalArgumentException - if any decision variables are not numeric