ImageD11.simplex | index /sware/exp/fable/standalone/redhate4-a64/lib/python2.5/site-packages/ImageD11/simplex.py

`Simplex - a regression method for arbitrary nonlinear function minimization
Simplex minimizes an arbitrary nonlinear function of N variables by the
Nelder-Mead Simplex method as described in:
Nelder, J.A. and Mead, R., "A Simplex Method for Function Minimization",
Computer Journal, Vol. 7, 1965, pp. 308-313.
It makes no assumptions about the smoothness of the function being minimized.
It converges to a local minimum which may or may not be the global minimum
depending on the initial guess used as a starting point.
# Copyright (c) 2001 Vivake Gupta (v@omniscia.org). All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# This software is maintained by Vivake (v@omniscia.org) and is available at:
# http://www.omniscia.org/~vivake/python/Simplex.py
# Modified (debugged?) 7/16/2004 Michele Vallisneri (vallis@vallis.org)
# Copied into ImageD11 by Jon Wright - This works really really well!!!`

Modules
`` |  |
copy | math | sys |

Classes
`` |  | Simplex
class Simplex
`` |  | Methods defined here: __init__(self, testfunc, guess, increments, kR=-1, kE=2, kC=0.5) `Initializes the simplex. INPUTS ------ testfunc the function to minimize guess[] an list containing initial guesses increments[] an list containing increments, perturbation size kR reflection constant (alpha =-1.0) kE expansion constant (gamma = 2.0) kC contraction constant (beta = 0.5)` accept_contracted_point(self) accept_expanded_point(self) accept_reflected_point(self) calculate_errors_at_vertices(self) contract_simplex(self) expand_simplex(self) `# expand: if P is vertex and Q is centroid, alpha-expansion is Q + alpha*(P-Q), # or (1 - alpha)*Q + alpha*P; default alpha is 2.0; agrees with NR` minimize(self, epsilon=0.0001, maxiters=250, monitor=1) `Walks to the simplex down to a local minima. INPUTS ------ epsilon convergence requirement maxiters maximum number of iterations monitor if non-zero, progress info is output to stdout OUTPUTS ------- an array containing the final values lowest value of the error function number of iterations taken to get here` multiple_contract_simplex(self) reflect_simplex(self) `# reflect: if P is vertex and Q is centroid, reflection is Q + (Q-P) = 2Q - P, # which is achieved for kR = -1 (default value); agrees with NR`

Functions
`` |  | main() myfunc(args)