This Page

mmf.solve.test_problems

TwoDimensional These are problems of two variables x and y.
Mine
MediumScale Medium scale root-finding problems.
DennisSchnabel Test problems from Dennis and Schnabel.

Test problems for testing non-linear solvers.

This module contains test problems with known solutions for testing non-linear solvers.

class mmf.solve.test_problems.TwoDimensional[source]

Bases: object

These are problems of two variables x and y.

Methods

Himmelblau
MexicanHat
SensitiveParameter
test() Test the functions.
__init__()

x.__init__(...) initializes x; see help(type(x)) for signature

class Himmelblau[source]

Bases: object

Himmelblau’s problem 2. Find the minimum of

f(x, y) = 100(y-x^2)^2 + (1-x)^2

starting from x=-1.2, y=1. Solution x=y=1.

Methods

F
G
J
Jinv
f
f_x
f_y
F(x, y)[source]
G(x_)[source]
J(x, y)[source]
Jinv(x, y)[source]
f(x, y)[source]
f_x(x, y)[source]
f_y(x, y)[source]
class TwoDimensional.MexicanHat(a=0.5, b=0.5)[source]

Bases: object

Classical Mexican hat potential with global minimum at (0,0), saddle point at (0, y_{+}) and local maximum at (0, y_{-}) where 2y_{\pm} = 3 \pm \sqrt{1 - b}:

f(x,y) = (x^2 + y^2 - 2y)^2 + \frac{bx^2 + by^2}{2}

The latter two features disappear for b\geq 1 while for a=b=0 the hat is completely degenerate. If a is sufficiently large, then there are additional saddle points off the x=0 axis.

This becomes a very difficult problem for efficient solution when a=0 because the Jacobin becomes singular at the minimum, spoiling the quadratic convergence. This is due to the fact that function is quartic along the valley at this point as can be seen by looking at the second derivative:

f_{,xx} = 12x^2 + 4(y^2 - 2y) + a

Methods

F
G
J
Jinv
f
f_x
f_y
F(x, y)[source]
G(x_)[source]
J(x, y)[source]
Jinv(x, y)[source]
f(x, y)[source]
f_x(x, y)[source]
f_y(x, y)[source]
class TwoDimensional.SensitiveParameter(a=1.1, b=100, c=0.1, d=0.01)[source]

Bases: object

In this potential, x is a “sensitive parameter” in the sense that a good strategy is to define g(x) =
\min_{y}f(x,y) and minimize this. Trying to minimize both x and y simultaneously will fail unless close to the solution.

The solution is x=y=0.

f(x,y) = (a +\cos(bx))(y - cx^2)^2 + dx^2

with default parameters a=1.1, b=200, c=0.1, d=0.01.

Methods

F
G
J
Jinv
f
f_x
f_y
F(x, y)[source]
G(x_)[source]
J(x, y)[source]
Jinv(x, y)[source]
f(x, y)[source]
f_x(x, y)[source]
f_y(x, y)[source]
TwoDimensional.test()[source]

Test the functions.

class mmf.solve.test_problems.Mine[source]

Bases: object

Methods

Sqrt
test_ans() Test the classes that the exact answer is a solution.
__init__()

x.__init__(...) initializes x; see help(type(x)) for signature

class Sqrt(*varargin, **kwargs)[source]

Bases: mmf.solve.solver_interface.Problem

Computes the square root of two numbers with very different magnitudes. This is a simple diagonal problem, but sometimes solvers mix the two solutions causing problems. A straigh-forward application of Broyden, for example, performs very badly.

Sqrt(globals={},
     x_scale=1,
     G_scale_parameters={},
     active_parameters=set([]),
     inactive_parameters=set([]),
     n=[  1.00000000e-02   1.00000000e+02],
     start_factor=1)

Examples

>>> from mmf.solve.broyden import JinvBroyden
>>> B = JinvBroyden()
>>> p = Mine.Sqrt()
>>> x0 = p.get_initial_state().x_
>>> for n in xrange(100):
...     incompatibility = B.update(x=x0, g=p.G(x0)[0])
...     x0 = B.get_x()
>>> abs(x0 - p.ans).max() < 10
False

Attributes

class mmf.solve.test_problems.MediumScale[source]

Bases: object

Medium scale root-finding problems.

Methods

GomexRuggiero
__init__()

x.__init__(...) initializes x; see help(type(x)) for signature

class GomexRuggiero(*varargin, **kwargs)[source]

Bases: mmf.solve.solver_interface.Problem

These are the problems defined in Computers & Mathematics with Applications Volume 32, Issue 3, August 1996, Pages 1-13 “A numerical study on large-scale nonlinear solvers”, M. A. Gomes-Ruggiero, D. N. Kozakevich and J. M. Martinez. doi:10.1016/0898-1221(96)00109-5.

GomexRuggiero(globals={},
              x_scale=1,
              G_scale_parameters={},
              active_parameters=set([]),
              inactive_parameters=set([]),
              problem=0,
              c=0,
              n=6,
              n_0=2)

These represent a discretization of a function u:
[0,1]\times[0,1] \mapsto \field{R} at N^2 equally spaced points.

The equations are the discretized form of

G_c(u) = f(x,y)

where G_c is one of the following:

(0)\qquad G_{c}(u) &= -\nabla^2 u
    + c\frac{u^3}{1 + x^2 + y^2}\\
(1)\qquad G_{c}(u) &= -\nabla^2 u
    + c e^{u}\\
(2)\qquad G_{c}(u) &= -\nabla^2 u
    + c u(u_{,x} + u_{,y})

We generate the right-hand side f(x,y) dynamically so that the solution is exact.

Attributes

class mmf.solve.test_problems.DennisSchnabel[source]

Bases: object

Test problems from Dennis and Schnabel.

Examples

Check that the exact answers ans are solutions:

>>> DennisSchnabel.test_ans()       
{'ExtendedPowell': True,
 'ExtendedRosenbrock': True,
 'HelicalValley': True}

Methods

ExtendedPowell
ExtendedRosenbrock
HelicalValley
Trigonometric
Wood
__init__()

x.__init__(...) initializes x; see help(type(x)) for signature

class ExtendedPowell(*varargin, **kwargs)[source]

Bases: mmf.solve.solver_interface.Problem

The Extended Powell Singular Function.

ExtendedPowell(globals={},
               x_scale=1,
               G_scale_parameters={},
               active_parameters=set([]),
               inactive_parameters=set([]),
               m=1,
               start_factor=1)

     Note that both :math:`G` and $

abla^2 orm{G}^2` are singular at

the solution.

Attributes