Adapter for mapping bounded MultivariateFunction to unbounded ones.
This adapter can be used to wrap functions subject to simple bounds on parameters so they can be used by optimizers that do not directly support simple bounds.
The principle is that the user function that will be wrapped will see its
parameters bounded as required, i.e when its value method is called
with argument array point, the elements array will fulfill requirement
lower[i] <= point[i] <= upper[i] for all i. Some of the components
may be unbounded or bounded only on one side if the corresponding bound is
set to an infinite value. The optimizer will not manage the user function by
itself, but it will handle this adapter and it is this adapter that will take
care the bounds are fulfilled. The adapter value(double[]) method will
be called by the optimizer with unbound parameters, and the adapter will map
the unbounded value to the bounded range using appropriate functions like
Sigmoid for double bounded elements for example.
As the optimizer sees only unbounded parameters, it should be noted that the
start point or simplex expected by the optimizer should be unbounded, so the
user is responsible for converting his bounded point to unbounded by calling
boundedToUnbounded(double[]) before providing them to the optimizer.
For the same reason, the point returned by the org.
method is unbounded. So to convert this point to bounded, users must call
unboundedToBounded(double[]) by themselves!
This adapter is only a poor man solution to simple bounds optimization constraints
that can be used with simple optimizers like
SimplexOptimizer.
A better solution is to use an optimizer that directly supports simple bounds like
CMAESOptimizer or
BOBYQAOptimizer.
One caveat of this poor-man's solution is that behavior near the bounds may be
numerically unstable as bounds are mapped from infinite values.
Another caveat is that convergence values are evaluated by the optimizer with
respect to unbounded variables, so there will be scales differences when
converted to bounded variables.
MultivariateFunctionPenaltyAdapter
| Modifier and Type | Class and Description |
|---|---|
| private static class | MultivariateFunctionMappingAdapter.
Local class for lower bounds mapping. |
| private static class | MultivariateFunctionMappingAdapter.
Local class for lower and bounds mapping. |
| private static interface | MultivariateFunctionMappingAdapter.
Mapping interface. |
| private static class | MultivariateFunctionMappingAdapter.
Local class for no bounds mapping. |
| private static class | MultivariateFunctionMappingAdapter.
Local class for upper bounds mapping. |
| Modifier and Type | Field and Description |
|---|---|
| private final MultivariateFunction | bounded
Underlying bounded function. |
| private final MultivariateFunctionMappingAdapter. | mappers
Mapping functions. |
| Access | Constructor and Description |
|---|---|
| public | MultivariateFunctionMappingAdapter(final MultivariateFunction
bounded function bounded, final double[] lower bounds for each element of the input parameters array
(some elements may be set to lower, final double[] Double.NEGATIVE_INFINITY for
unbounded values)upper bounds for each element of the input parameters array
(some elements may be set to upper)Double.POSITIVE_INFINITY for
unbounded values)Simple constructor. |
| Modifier and Type | Method and Description |
|---|---|
| public double[] | Returns: the unbounded values.Bounded values. point)Maps an array from bounded to unbounded. |
| public double[] | Returns: the bounded values.Unbounded values. point)Maps an array from unbounded to bounded. |
| public double | Returns: underlying function valueunbounded value point)Implements org. Compute the underlying function value from an unbounded point. |
| bounded | back to summary |
|---|---|
| private final MultivariateFunction bounded Underlying bounded function. | |
| mappers | back to summary |
|---|---|
| private final MultivariateFunctionMappingAdapter. Mapping functions. | |
| MultivariateFunctionMappingAdapter | back to summary |
|---|---|
| public MultivariateFunctionMappingAdapter(final MultivariateFunction bounded, final double[] lower, final double[] upper) Simple constructor.
| |
| boundedToUnbounded | back to summary |
|---|---|
| public double[] boundedToUnbounded(double[] point) Maps an array from bounded to unbounded.
| |
| unboundedToBounded | back to summary |
|---|---|
| public double[] unboundedToBounded(double[] point) Maps an array from unbounded to bounded.
| |
| value | back to summary |
|---|---|
| public double value(double[] point) Implements org. Compute the underlying function value from an unbounded point. This method simply bounds the unbounded point using the mappings set up at construction and calls the underlying function using the bounded point.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final double | lower
Low bound. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public double | boundedToUnbounded(final double
Bounded value. x)Implements org. Maps a value from bounded to unbounded. |
| public double | unboundedToBounded(final double
Unbounded value. y)Implements org. Maps a value from unbounded to bounded. |
| lower | back to summary |
|---|---|
| private final double lower Low bound. | |
| LowerBoundMapper | back to summary |
|---|---|
| pack-priv LowerBoundMapper(final double lower) Simple constructor.
| |
| boundedToUnbounded | back to summary |
|---|---|
| public double boundedToUnbounded(final double x) Implements org. Maps a value from bounded to unbounded.
| |
| unboundedToBounded | back to summary |
|---|---|
| public double unboundedToBounded(final double y) Implements org. Maps a value from unbounded to bounded.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final UnivariateFunction | boundingFunction
Function from unbounded to bounded. |
| private final UnivariateFunction | unboundingFunction
Function from bounded to unbounded. |
| Access | Constructor and Description |
|---|---|
| pack-priv | LowerUpperBoundMapper(final double
lower bound lower, final double upper bound upper)Simple constructor. |
| Modifier and Type | Method and Description |
|---|---|
| public double | boundedToUnbounded(final double
Bounded value. x)Implements org. Maps a value from bounded to unbounded. |
| public double | unboundedToBounded(final double
Unbounded value. y)Implements org. Maps a value from unbounded to bounded. |
| boundingFunction | back to summary |
|---|---|
| private final UnivariateFunction boundingFunction Function from unbounded to bounded. | |
| unboundingFunction | back to summary |
|---|---|
| private final UnivariateFunction unboundingFunction Function from bounded to unbounded. | |
| LowerUpperBoundMapper | back to summary |
|---|---|
| pack-priv LowerUpperBoundMapper(final double lower, final double upper) Simple constructor.
| |
| boundedToUnbounded | back to summary |
|---|---|
| public double boundedToUnbounded(final double x) Implements org. Maps a value from bounded to unbounded.
| |
| unboundedToBounded | back to summary |
|---|---|
| public double unboundedToBounded(final double y) Implements org. Maps a value from unbounded to bounded.
| |
| Modifier and Type | Method and Description |
|---|---|
| public double | Returns: the unbounded value.Bounded value. x)Maps a value from bounded to unbounded. |
| public double | Returns: the bounded value.Unbounded value. y)Maps a value from unbounded to bounded. |
| boundedToUnbounded | back to summary |
|---|---|
| public double boundedToUnbounded(double x) Maps a value from bounded to unbounded.
| |
| unboundedToBounded | back to summary |
|---|---|
| public double unboundedToBounded(double y) Maps a value from unbounded to bounded.
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public double | boundedToUnbounded(final double
Bounded value. x)Implements org. Maps a value from bounded to unbounded. |
| public double | unboundedToBounded(final double
Unbounded value. y)Implements org. Maps a value from unbounded to bounded. |
| NoBoundsMapper | back to summary |
|---|---|
| private NoBoundsMapper() | |
| boundedToUnbounded | back to summary |
|---|---|
| public double boundedToUnbounded(final double x) Implements org. Maps a value from bounded to unbounded.
| |
| unboundedToBounded | back to summary |
|---|---|
| public double unboundedToBounded(final double y) Implements org. Maps a value from unbounded to bounded.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final double | upper
Upper bound. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public double | boundedToUnbounded(final double
Bounded value. x)Implements org. Maps a value from bounded to unbounded. |
| public double | unboundedToBounded(final double
Unbounded value. y)Implements org. Maps a value from unbounded to bounded. |
| upper | back to summary |
|---|---|
| private final double upper Upper bound. | |
| UpperBoundMapper | back to summary |
|---|---|
| pack-priv UpperBoundMapper(final double upper) Simple constructor.
| |
| boundedToUnbounded | back to summary |
|---|---|
| public double boundedToUnbounded(final double x) Implements org. Maps a value from bounded to unbounded.
| |
| unboundedToBounded | back to summary |
|---|---|
| public double unboundedToBounded(final double y) Implements org. Maps a value from unbounded to bounded.
| |