Top Description Inners Fields Constructors Methods
org.apache.commons.math3.optimization.direct

public Class MultivariateFunctionMappingAdapter

extends Object
implements MultivariateFunction
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.analysis.MultivariateFunction
Annotations
@Deprecated
Imports
org.apache.commons.math3.analysis.MultivariateFunction, .UnivariateFunction, org.apache.commons.math3.analysis.function.Logit, .Sigmoid, org.apache.commons.math3.exception.DimensionMismatchException, .NumberIsTooSmallException, org.apache.commons.math3.util.FastMath, .MathUtils

Deprecated

As of 3.1 (to be removed in 4.0).

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.apache.commons.math3.optimization.BaseMultivariateOptimizer#optimize(int, MultivariateFunction, org.apache.commons.math3.optimization.GoalType, double[]) 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 with NelderMeadSimplex or MultiDirectionalSimplex. A better solution is to use an optimizer that directly supports simple bounds like CMAESOptimizer or BOBYQAOptimizer. One caveat of this poor man 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.

Since
3.0
See Also
MultivariateFunctionPenaltyAdapter

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
MultivariateFunctionMappingAdapter.LowerBoundMapper

Local class for lower bounds mapping.

private static class
MultivariateFunctionMappingAdapter.LowerUpperBoundMapper

Local class for lower and bounds mapping.

private static interface
private static class
MultivariateFunctionMappingAdapter.NoBoundsMapper

Local class for no bounds mapping.

private static class
MultivariateFunctionMappingAdapter.UpperBoundMapper

Local class for upper bounds mapping.

Field Summary

Modifier and TypeField and Description
private final MultivariateFunction
bounded

Underlying bounded function.

private final MultivariateFunctionMappingAdapter.Mapper[]
mappers

Mapping functions.

Constructor Summary

AccessConstructor 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 Double.NEGATIVE_INFINITY for unbounded values)
lower
,
final double[]
upper bounds for each element of the input parameters array (some elements may be set to Double.POSITIVE_INFINITY for unbounded values)
upper
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public double[]

Returns:

unbounded value
boundedToUnbounded
(double[]
bounded value
point
)

Map an array from bounded to unbounded.

public double[]

Returns:

bounded value
unboundedToBounded
(double[]
unbounded value
point
)

Map an array from unbounded to bounded.

public double

Returns:

underlying function value
value
(double[]
unbounded value
point
)

Implements org.apache.commons.math3.analysis.MultivariateFunction.value.

Compute the underlying function value from an unbounded point.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

boundedback to summary
private final MultivariateFunction bounded

Underlying bounded function.

mappersback to summary
private final MultivariateFunctionMappingAdapter.Mapper[] mappers

Mapping functions.

Constructor Detail

MultivariateFunctionMappingAdapterback to summary
public MultivariateFunctionMappingAdapter(final MultivariateFunction bounded, final double[] lower, final double[] upper)

Simple constructor.

Parameters
bounded:MultivariateFunction

bounded function

lower:double[]

lower bounds for each element of the input parameters array (some elements may be set to Double.NEGATIVE_INFINITY for unbounded values)

upper:double[]

upper bounds for each element of the input parameters array (some elements may be set to Double.POSITIVE_INFINITY for unbounded values)

Exceptions
DimensionMismatchException:
if lower and upper bounds are not consistent, either according to dimension or to values

Method Detail

boundedToUnboundedback to summary
public double[] boundedToUnbounded(double[] point)

Map an array from bounded to unbounded.

Parameters
point:double[]

bounded value

Returns:double[]

unbounded value

unboundedToBoundedback to summary
public double[] unboundedToBounded(double[] point)

Map an array from unbounded to bounded.

Parameters
point:double[]

unbounded value

Returns:double[]

bounded value

valueback to summary
public double value(double[] point)

Implements org.apache.commons.math3.analysis.MultivariateFunction.value.

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.

Parameters
point:double[]

unbounded value

Returns:double

underlying function value

See Also
unboundedToBounded(double[])
org.apache.commons.math3.optimization.direct back to summary

private Class MultivariateFunctionMappingAdapter.LowerBoundMapper

extends Object
implements Mapper
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.LowerBoundMapper
All Implemented Interfaces
org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper

Local class for lower bounds mapping.

Field Summary

Modifier and TypeField and Description
private final double
lower

Low bound.

Constructor Summary

AccessConstructor and Description
pack-priv
LowerBoundMapper(final double
lower bound
lower
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public double
public double
unboundedToBounded(final double
unbounded value
y
)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Map a value from unbounded to bounded.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lowerback to summary
private final double lower

Low bound.

Constructor Detail

LowerBoundMapperback to summary
pack-priv LowerBoundMapper(final double lower)

Simple constructor.

Parameters
lower:double

lower bound

Method Detail

boundedToUnboundedback to summary
public double boundedToUnbounded(final double x)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.boundedToUnbounded.

Doc from org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.boundedToUnbounded.

Map a value from bounded to unbounded.

Parameters
x:double

bounded value

Returns:double

unbounded value

unboundedToBoundedback to summary
public double unboundedToBounded(final double y)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Doc from org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Map a value from unbounded to bounded.

Parameters
y:double

unbounded value

Returns:double

bounded value

org.apache.commons.math3.optimization.direct back to summary

private Class MultivariateFunctionMappingAdapter.LowerUpperBoundMapper

extends Object
implements Mapper
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.LowerUpperBoundMapper
All Implemented Interfaces
org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper

Local class for lower and bounds mapping.

Field Summary

Modifier and TypeField and Description
private final UnivariateFunction
boundingFunction

Function from unbounded to bounded.

private final UnivariateFunction
unboundingFunction

Function from bounded to unbounded.

Constructor Summary

AccessConstructor and Description
pack-priv
LowerUpperBoundMapper(final double
lower bound
lower
,
final double
upper bound
upper
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public double
public double
unboundedToBounded(final double
unbounded value
y
)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Map a value from unbounded to bounded.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

boundingFunctionback to summary
private final UnivariateFunction boundingFunction

Function from unbounded to bounded.

unboundingFunctionback to summary
private final UnivariateFunction unboundingFunction

Function from bounded to unbounded.

Constructor Detail

LowerUpperBoundMapperback to summary
pack-priv LowerUpperBoundMapper(final double lower, final double upper)

Simple constructor.

Parameters
lower:double

lower bound

upper:double

upper bound

Method Detail

boundedToUnboundedback to summary
public double boundedToUnbounded(final double x)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.boundedToUnbounded.

Doc from org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.boundedToUnbounded.

Map a value from bounded to unbounded.

Parameters
x:double

bounded value

Returns:double

unbounded value

unboundedToBoundedback to summary
public double unboundedToBounded(final double y)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Doc from org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Map a value from unbounded to bounded.

Parameters
y:double

unbounded value

Returns:double

bounded value

org.apache.commons.math3.optimization.direct back to summary

private Interface MultivariateFunctionMappingAdapter.Mapper

Known Direct Implementers
org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.NoBoundsMapper, org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.LowerBoundMapper, org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.UpperBoundMapper, org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.LowerUpperBoundMapper

Mapping interface.

Method Summary

Modifier and TypeMethod and Description
public double

Returns:

unbounded value
boundedToUnbounded
(double
bounded value
x
)

Map a value from bounded to unbounded.

public double

Returns:

bounded value
unboundedToBounded
(double
unbounded value
y
)

Map a value from unbounded to bounded.

Method Detail

boundedToUnboundedback to summary
public double boundedToUnbounded(double x)

Map a value from bounded to unbounded.

Parameters
x:double

bounded value

Returns:double

unbounded value

unboundedToBoundedback to summary
public double unboundedToBounded(double y)

Map a value from unbounded to bounded.

Parameters
y:double

unbounded value

Returns:double

bounded value

org.apache.commons.math3.optimization.direct back to summary

private Class MultivariateFunctionMappingAdapter.NoBoundsMapper

extends Object
implements Mapper
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.NoBoundsMapper
All Implemented Interfaces
org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper

Local class for no bounds mapping.

Constructor Summary

AccessConstructor and Description
pack-priv
NoBoundsMapper()

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public double
public double
unboundedToBounded(final double
unbounded value
y
)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Map a value from unbounded to bounded.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NoBoundsMapperback to summary
pack-priv NoBoundsMapper()

Simple constructor.

Method Detail

boundedToUnboundedback to summary
public double boundedToUnbounded(final double x)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.boundedToUnbounded.

Doc from org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.boundedToUnbounded.

Map a value from bounded to unbounded.

Parameters
x:double

bounded value

Returns:double

unbounded value

unboundedToBoundedback to summary
public double unboundedToBounded(final double y)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Doc from org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Map a value from unbounded to bounded.

Parameters
y:double

unbounded value

Returns:double

bounded value

org.apache.commons.math3.optimization.direct back to summary

private Class MultivariateFunctionMappingAdapter.UpperBoundMapper

extends Object
implements Mapper
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.UpperBoundMapper
All Implemented Interfaces
org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper

Local class for upper bounds mapping.

Field Summary

Modifier and TypeField and Description
private final double
upper

Upper bound.

Constructor Summary

AccessConstructor and Description
pack-priv
UpperBoundMapper(final double
upper bound
upper
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public double
public double
unboundedToBounded(final double
unbounded value
y
)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Map a value from unbounded to bounded.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

upperback to summary
private final double upper

Upper bound.

Constructor Detail

UpperBoundMapperback to summary
pack-priv UpperBoundMapper(final double upper)

Simple constructor.

Parameters
upper:double

upper bound

Method Detail

boundedToUnboundedback to summary
public double boundedToUnbounded(final double x)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.boundedToUnbounded.

Doc from org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.boundedToUnbounded.

Map a value from bounded to unbounded.

Parameters
x:double

bounded value

Returns:double

unbounded value

unboundedToBoundedback to summary
public double unboundedToBounded(final double y)

Implements org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Doc from org.apache.commons.math3.optimization.direct.MultivariateFunctionMappingAdapter.Mapper.unboundedToBounded.

Map a value from unbounded to bounded.

Parameters
y:double

unbounded value

Returns:double

bounded value