psMinimizeLMM.h

Go to the documentation of this file.
00001 /* @file  psMinimizeLMM.c
00002  * @brief basic minimization functions
00003  *
00004  * This file will contain function prototypes for various Levenberg-Marquadt
00005  * minimization routines.
00006  *
00007  * @author GLG, MHPCC
00008  *
00009  * @version $Revision: 1.8 $ $Name:  $
00010  * @date $Date: 2007/01/23 22:47:23 $
00011  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00012  */
00013 
00014 #ifndef PS_MINIMIZE_LMM_H
00015 #define PS_MINIMIZE_LMM_H
00016 
00017 /// @addtogroup MathOps Mathematical Operations
00018 /// @{
00019 
00020 #include "psVector.h"
00021 #include "psMemory.h"
00022 #include "psArray.h"
00023 #include "psImage.h"
00024 #include "psMatrix.h"
00025 #include "psPolynomial.h"
00026 #include "psSpline.h"
00027 #include "psStats.h"
00028 #include "psTrace.h"
00029 #include "psError.h"
00030 #include "psConstants.h"
00031 
00032 #define PS_DETERMINE_BRACKET_STEP_SIZE 0.10
00033 #define PS_MAX_LMM_ITERATIONS 100
00034 #define PS_MAX_MINIMIZE_ITERATIONS 100
00035 #define P_PSMINIMIZATION_SET_MAXITER(m,val) *(int*)&m->maxIter = val
00036         #define P_PSMINIMIZATION_SET_TOL(m,val) *(float*)&m->tol = val
00037 
00038                 typedef enum {
00039                     PS_MINIMIZE_BETA_LIMIT,
00040                     PS_MINIMIZE_PARAM_MIN,
00041                     PS_MINIMIZE_PARAM_MAX
00042                 } psMinConstraintMode;
00043 
00044 /** Specifies the format of a user-defined function that the general Levenberg-
00045  *  Marquardt minimizer routine will accept.
00046  *
00047  *  @return float:   the single float value of the function given the parameters,
00048  *       positions, and derivatives.
00049  */
00050 typedef
00051 float (*psMinimizeLMChi2Func)(
00052     psVector *deriv,                   ///< derivatives of the function
00053     const psVector *params,            ///< the parameters used to evaluate the function
00054     const psVector *x                  ///< positions for evaluation
00055 );
00056 
00057 /** Specifies the format of a user-defined function which check the parameters
00058  *  against the allowed limits.  used by the general Levenberg-Marquardt minimizer.
00059  *
00060  *  @return float:   the single float value of the function given the parameters,
00061  *       positions, and derivatives.
00062  */
00063 typedef
00064 bool (*psMinimizeLMLimitFunc)(
00065     psMinConstraintMode mode,   ///< which limit to check
00066     int nParam,    ///< which param to check
00067     float *params,   ///< current param value set
00068     float *beta       ///< current beta value, if needed
00069 );
00070 
00071 /** A data structure for minimization routines.
00072  *
00073  *  Contains numerical analysis parameters/values
00074  */
00075 typedef struct
00076 {
00077     const int maxIter;                 ///< Convergence limit
00078     const float tol;                   ///< Error Tolerance
00079     float value;                       ///< Value of function at minimum
00080     int iter;                          ///< Number of iterations to date
00081     float lastDelta;                   ///< The last difference for the fit
00082 }
00083 psMinimization;
00084 
00085 /** A data structure for minimization routines.
00086  *
00087  *
00088  */
00089 typedef struct
00090 {
00091     psVector *paramMask;                ///< valid / invalid parameters
00092     psMinimizeLMLimitFunc checkLimits; ///< user-supplied function to test the parameter limits
00093 }
00094 psMinConstraint;
00095 
00096 psMinConstraint *psMinConstraintAlloc();
00097 
00098 /** Allocates a psMinimization structure.
00099  *
00100  *  @return psMinimization* :   a new psMinimization struct
00101  */
00102 psMinimization *psMinimizationAlloc(
00103     int maxIter,                       ///< Number of minimization iterations to perform.
00104     float tol                          ///< Requested error tolerance
00105 );
00106 
00107 /*  Checks the type of a particular pointer.
00108  *
00109  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00110  *
00111  *  @return bool:       True if the pointer matches a psMinimization structure, false otherwise.
00112  */
00113 bool psMemCheckMinimization(
00114     psPtr ptr                          ///< the pointer whose type to check
00115 );
00116 
00117 /** Minimizes a specified function based on the Levenberg-Marquardt method.
00118  *
00119  *  @return bool:   True if successful.
00120  */
00121 bool psMinimizeLMChi2(
00122     psMinimization *min,               ///< Minimization specification
00123     psImage *covar,                    ///< Covariance matrix
00124     psVector *params,                  ///< "Best Guess" for the parameters that minimize func
00125     psMinConstraint *constraint, ///< Constraints on the parameters
00126     const psArray *x,                  ///< Measurement ordinates of multiple vectors
00127     const psVector *y,                 ///< Measurement coordinates
00128     const psVector *yWt,               ///< Errors in the measurement coordinates
00129     psMinimizeLMChi2Func func          ///< Specified function
00130 );
00131 
00132 bool psMinimizeGaussNewtonDelta (
00133     psVector *delta,
00134     const psVector *params,
00135     const psVector *paramMask,
00136     const psArray  *x,
00137     const psVector *y,
00138     const psVector *yErr,
00139     psMinimizeLMChi2Func func
00140 );
00141 
00142 /** Function used to set parameters for generating "best guess" in minimizing Chi-Squared value.
00143  *
00144  *  @return psF32:    Chi-squared value for new guess
00145  */
00146 psF32 p_psMinLM_SetABX (
00147     psImage  *alpha,                   ///< alpha guess
00148     psVector *beta,                    ///< beta guess
00149     const psVector *params,            ///< params guess
00150     const psVector *paramMask,         ///< param mask
00151     const psArray  *x,                 ///< Measurement ordinates
00152     const psVector *y,                 ///< Measurement coordinates
00153     const psVector *dy,                ///< Weights calculated from y-errors
00154     psMinimizeLMChi2Func func          ///< Specified function
00155 );
00156 
00157 
00158 psBool p_psMinLM_GuessABP(
00159     psImage  *Alpha,
00160     psVector *Beta,
00161     psVector *Params,
00162     const psImage  *alpha,
00163     const psVector *beta,
00164     const psVector *params,
00165     const psVector *paramMask,
00166     psMinimizeLMLimitFunc checkLimits,
00167     psF32 lambda
00168 );
00169 
00170 /// @}
00171 #endif // #ifndef PS_MINIMIZE_LMM_H

Generated on Fri Feb 2 22:24:35 2007 for pslib by  doxygen 1.5.1