Class Simplex
- java.lang.Object
-
- org.apache.commons.math4.legacy.optim.nonlinear.scalar.noderiv.Simplex
-
- All Implemented Interfaces:
OptimizationData
public final class Simplex extends Object implements OptimizationData
Represents a simplex.- See Also:
SimplexOptimizer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Simplex.TransformFactory
Generator of simplex transform.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Simplex
alongAxes(double[] steps)
The start configuration for simplex is built from a box parallel to the canonical axes of the space.List<PointValuePair>
asList()
Creates a (deep) copy of the simplex points.static Simplex
equalSidesAlongAxes(int dim, double sideLength)
Builds simplex with the given side length.Simplex
evaluate(MultivariateFunction function, Comparator<PointValuePair> comparator)
Evaluates the (non-evaluated) simplex points and returns a new instance with vertices sorted from best to worst.PointValuePair
get(int index)
Retrieves a copy of the simplex point stored atindex
.int
getDimension()
Returns the space dimension.int
getSize()
Returns the number of vertices.static Simplex
of(double[][] simplex)
Builds from a given set of coordinates.
-
-
-
Method Detail
-
of
public static Simplex of(double[][] simplex)
Builds from a given set of coordinates.- Parameters:
simplex
- Simplex coordinates.- Returns:
- a new instance.
- Throws:
NotStrictlyPositiveException
- if the reference simplex does not contain at least one point.DimensionMismatchException
- if there is a dimension mismatch in the reference simplex.IllegalArgumentException
- if one of its vertices is duplicated.
-
equalSidesAlongAxes
public static Simplex equalSidesAlongAxes(int dim, double sideLength)
Builds simplex with the given side length.- Parameters:
dim
- Space dimensions.sideLength
- Length of the sides of the hypercube.- Returns:
- a new instance.
-
alongAxes
public static Simplex alongAxes(double[] steps)
The start configuration for simplex is built from a box parallel to the canonical axes of the space. The simplex is the subset of vertices of a box parallel to the canonical axes. It is built as the path followed while traveling from one vertex of the box to the diagonally opposite vertex moving only along the box edges. The first vertex of the box will be located at the origin of the coordinate system. To be used for simplex-based optimization, the simplex must betranslated
so that its first vertex will be theinitial guess
. For example, in dimension 3 a simplex has 4 vertices. Setting the steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the initial simplex would be:- (1, 1, 1),
- (2, 1, 1),
- (2, 11, 1),
- (2, 11, 3).
- Parameters:
steps
- Steps along the canonical axes representing box edges. They may be negative but not zero.- Returns:
- a new instance.
- Throws:
ZeroException
- if one of the steps is zero.
-
getDimension
public int getDimension()
Returns the space dimension.- Returns:
- the dimension of the simplex.
-
getSize
public int getSize()
Returns the number of vertices.- Returns:
- the size of the simplex.
-
evaluate
public Simplex evaluate(MultivariateFunction function, Comparator<PointValuePair> comparator)
Evaluates the (non-evaluated) simplex points and returns a new instance with vertices sorted from best to worst.- Parameters:
function
- Evaluation function.comparator
- Comparator for sorting vertices, from best to worst.- Returns:
- a new instance in which the vertices are sorted according to
the given
comparator
.
-
get
public PointValuePair get(int index)
Retrieves a copy of the simplex point stored atindex
.- Parameters:
index
- Location.- Returns:
- the point at location
index
.
-
asList
public List<PointValuePair> asList()
Creates a (deep) copy of the simplex points.- Returns:
- the points.
-
-