RosenbrockFunctional
- class odl.functionals.example_funcs.RosenbrockFunctional(*args, **kwargs)[source]
Bases:
FunctionalThe well-known Rosenbrock function on
R^n.The Rosenbrock function is often used as a test problem in smooth optimization.
Notes
The functional is defined for
,
, as
where
is a constant, usually set to 100, which determines how
“ill-behaved” the function should be.
The global minimum lies at
, independent
of
.There are two definitions of the n-dimensional Rosenbrock function found in the literature. One is the product of 2-dimensional Rosenbrock functions, which is not the one used here. This one extends the pattern of the 2d Rosenbrock function so all dimensions depend on each other in sequence.
References
- __init__(space, scale=100.0)[source]
Initialize a new instance.
Parameters
- space
TensorSpace Domain of the functional.
- scalepositive float, optional
The scale
cin the functional determining how “ill-behaved” the functional should be. Larger value means worse behavior.
Examples
Initialize and call the functional:
>>> r2 = odl.rn(2) >>> functional = RosenbrockFunctional(r2) >>> functional([1, 1]) # optimum is 0 at [1, 1] 0.0 >>> functional([0, 1]) 101.0
The functional can also be used in higher dimensions:
>>> r5 = odl.rn(5) >>> functional = RosenbrockFunctional(r5) >>> functional([1, 1, 1, 1, 1]) 0.0
We can change how much the function is ill-behaved via
scale:>>> r2 = odl.rn(2) >>> functional = RosenbrockFunctional(r2, scale=2) >>> functional([1, 1]) # optimum is still 0 at [1, 1] 0.0 >>> functional([0, 1]) # much lower variation 3.0
- space