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 Summary
ConstructorDescriptionClusterableSolution
(Solution solution, double[] point) Constructs a new clusterable solution. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
getPoint()
Returns the point used for clustering.Returns the solution.static ClusterableSolution
withObjectives
(Solution solution) Constructs a clusterable solution based on the objective values of the solution.static ClusterableSolution
withVariables
(Solution solution) Constructs a clusterable solution based on the decision variables of the solution.
-
Constructor Details
-
ClusterableSolution
Constructs a new clusterable solution.- Parameters:
solution
- the solutionpoint
- the point used for clustering
-
-
Method Details
-
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 interfaceorg.apache.commons.math3.ml.clustering.Clusterable
- Returns:
- the point
-
withObjectives
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
Constructs a clusterable solution based on the decision variables of the solution. This only supports numeric decision variables, such asRealVariable
andBinaryIntegerVariable
, 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
-