Package mystic :: Module scipy_optimize

Module scipy_optimize

source code

Solvers

This module contains a collection of optimization routines adapted from scipy.optimize. The minimal scipy interface has been preserved, and functionality from the mystic solver API has been added with reasonable defaults.

Minimal function interface to optimization routines:

  fmin        -- Nelder-Mead Simplex algorithm
                   (uses only function calls)
  fmin_powell -- Powell's (modified) level set method (uses only
                   function calls)

The corresponding solvers built on mystic's AbstractSolver are:

  NelderMeadSimplexSolver -- Nelder-Mead Simplex algorithm
  PowellDirectionalSolver -- Powell's (modified) level set method

Mystic solver behavior activated in fmin:

  - EvaluationMonitor = Sow()
  - StepMonitor = Sow()
  - termination = CandidateRelativeTolerance(xtol,ftol)
  - enable_signal_handler()

Mystic solver behavior activated in fmin_powell:

  - EvaluationMonitor = Sow()
  - StepMonitor = Sow()
  - termination = NormalizedChangeOverGeneration(ftol)
  - enable_signal_handler()

Usage

See `mystic.examples.test_rosenbrock2` for an example of using NelderMeadSimplexSolver. See `mystic.examples.test_rosenbrock3` or an example of using PowellDirectionalSolver.

All solvers included in this module provide the standard signal handling. For more information, see `mystic.mystic.abstract_solver`.

Classes
  NelderMeadSimplexSolver
Nelder Mead Simplex optimization adapted from scipy.optimize.fmin.
  PowellDirectionalSolver
Powell Direction Search optimization, adapted from scipy.optimize.fmin_powell.
Functions
 
fmin(func, x0, args=(), xtol=1e-4, ftol=1e-4, maxiter=None, maxfun=None, full_output=0, disp=1, retall=0, callback=None)
Minimize a function using the downhill simplex algorithm.
source code
 
fmin_powell(func, x0, args=(), xtol=1e-4, ftol=1e-4, maxiter=None, maxfun=None, full_output=0, disp=1, retall=0, callback=None, direc=None)
Minimize a function using modified Powell's method.
source code
Function Details

fmin(func, x0, args=(), xtol=1e-4, ftol=1e-4, maxiter=None, maxfun=None, full_output=0, disp=1, retall=0, callback=None)

source code 
Minimize a function using the downhill simplex algorithm.
    
Description:

    Uses a Nelder-Mead simplex algorithm to find the minimum of
    a function of one or more variables. Mimics the scipy.optimize.fmin
    interface.

Inputs:

    func -- the Python function or method to be minimized.
    x0 -- ndarray - the initial guess.

Additional Inputs:

    args -- extra arguments for func.
    xtol -- number - acceptable relative error in xopt for convergence.
    ftol -- number - acceptable relative error in func(xopt) for
        convergence.
    maxiter -- number - the maximum number of iterations to perform.
    maxfun -- number - the maximum number of function evaluations.
    full_output -- number - non-zero if fval and warnflag outputs are
        desired.
    disp -- number - non-zero to print convergence messages.
    retall -- number - non-zero to return list of solutions at each
        iteration.
    callback -- an optional user-supplied function to call after each
        iteration.  It is called as callback(xk), where xk is the
        current parameter vector.

Returns: (xopt, {fopt, iter, funcalls, warnflag}, {allvecs})

    xopt -- ndarray - minimizer of function
    fopt -- number - value of function at minimum: fopt = func(xopt)
    iter -- number - number of iterations
    funcalls -- number - number of function calls
    warnflag -- number - Integer warning flag:
        1 : 'Maximum number of function evaluations.'
        2 : 'Maximum number of iterations.'
    allvecs -- list - a list of solutions at each iteration

    

fmin_powell(func, x0, args=(), xtol=1e-4, ftol=1e-4, maxiter=None, maxfun=None, full_output=0, disp=1, retall=0, callback=None, direc=None)

source code 
Minimize a function using modified Powell's method.
    
Description:

    Uses a modified Powell Directional Search algorithm to find
    the minimum of function of one or more variables.  Mimics the
    scipy.optimize.fmin_powell interface.

Inputs:

    func -- the Python function or method to be minimized.
    x0 -- ndarray - the initial guess.

Additional Inputs:

    args -- extra arguments for func.
    xtol -- number - acceptable relative error in xopt for
        convergence.
    ftol -- number - acceptable relative error in func(xopt) for
        convergence.
    maxiter -- number - the maximum number of iterations to perform.
    maxfun -- number - the maximum number of function evaluations.
    full_output -- number - non-zero if fval and warnflag outputs
        are desired.
    disp -- number - non-zero to print convergence messages.
    retall -- number - non-zero to return list of solutions at each
        iteration.
    callback -- an optional user-supplied function to call after each
        iteration.  It is called as callback(xk), where xk is the
        current parameter vector.
    direc -- initial direction set

Returns: (xopt, {fopt, direc, iter, funcalls, warnflag}, {allvecs})

    xopt -- ndarray - minimizer of function
    fopt -- number - value of function at minimum: fopt = func(xopt)
    direc -- current direction set
    iter -- number - number of iterations
    funcalls -- number - number of function calls
    warnflag -- number - Integer warning flag:
        1 : 'Maximum number of function evaluations.'
        2 : 'Maximum number of iterations.'
    allvecs -- list - a list of solutions at each iteration