Package ComboCode :: Package cc :: Package ivs :: Package sigproc :: Package lmfit :: Module minimizer :: Class Minimizer
[hide private]
[frames] | no frames]

Class Minimizer

source code


general minimizer

Instance Methods [hide private]
 
__init__(self, userfcn, params, fcn_args=None, fcn_kws=None, iter_cb=None, scale_covar=True, **kws)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__update_paramval(self, name)
update parameter value, including setting bounds.
source code
 
update_constraints(self)
update all constrained parameters, checking that dependencies are evaluated as needed.
source code
 
__residual(self, fvars)
residual function used for least-squares fit.
source code
 
__jacobian(self, fvars)
analytical jacobian to be used with the Levenberg-Marquardt
source code
 
__set_params(self, params)
set internal self.params from a Parameters object or a list/tuple of Parameters
source code
 
penalty(self, params)
penalty function for scalar minimizers: evaluates user-supplied objective function, if result is an array, return array sum-of-squares.
source code
 
prepare_fit(self, params=None)
prepare parameters for fit
source code
 
anneal(self, schedule='cauchy', **kws)
use simulated annealing
source code
 
lbfgsb(self, **kws)
use l-bfgs-b minimization
source code
 
fmin(self, **kws)
use nelder-mead (simplex) minimization
source code
 
scalar_minimize(self, method='Nelder-Mead', hess=None, tol=None, **kws)
use one of the scaler minimization methods from scipy.
source code
 
leastsq(self, **kws)
use Levenberg-Marquardt minimization to perform fit.
source code
 
start_minimize(self, engine, **kwargs)
Start the actual fitting
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  err_nonparam = 'params must be a minimizer.Parameters() instan...
  err_maxfev = 'Too many function calls (max set to %i)! Use:\...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, userfcn, params, fcn_args=None, fcn_kws=None, iter_cb=None, scale_covar=True, **kws)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

__update_paramval(self, name)

source code 

update parameter value, including setting bounds. For a constrained parameter (one with an expr defined), this first updates (recursively) all parameters on which the parameter depends (using the 'deps' field).

__residual(self, fvars)

source code 

residual function used for least-squares fit. With the new, candidate values of fvars (the fitting variables), this evaluates all parameters, including setting bounds and evaluating constraints, and then passes those to the user-supplied function to calculate the residual.

__jacobian(self, fvars)

source code 

analytical jacobian to be used with the Levenberg-Marquardt

modified 02-01-2012 by Glenn Jones, Aberystwyth University

scalar_minimize(self, method='Nelder-Mead', hess=None, tol=None, **kws)

source code 
use one of the scaler minimization methods from scipy.
Available methods include:
  Nelder-Mead
  Powell
  CG  (conjugate gradient)
  BFGS
  Newton-CG
  Anneal
  L-BFGS-B
  TNC
  COBYLA
  SLSQP

If the objective function returns a numpy array instead
of the expected scalar, the sum of squares of the array
will be used.

Note that bounds and constraints can be set on Parameters
for any of these methods, so are not supported separately
for those designed to use bounds.

leastsq(self, **kws)

source code 

use Levenberg-Marquardt minimization to perform fit. This assumes that ModelParameters have been stored, and a function to minimize has been properly set up.

This wraps scipy.optimize.leastsq, and keyword arguments are passed directly as options to scipy.optimize.leastsq

When possible, this calculates the estimated uncertainties and variable correlations from the covariance matrix.

writes outputs to many internal attributes, and returns True if fit was successful, False if not.


Class Variable Details [hide private]

err_nonparam

Value:
'params must be a minimizer.Parameters() instance or list of Parameter\
s()'

err_maxfev

Value:
'''Too many function calls (max set to  %i)!  Use:
    minimize(func, params, ...., maxfev=NNN)
or set  leastsq_kws[\'maxfev\']  to increase this maximum.'''