Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

simplex.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006 
00007 /*
00008    This is the header file for simplex.c.
00009 
00010   File:     simplex.h
00011   Author:   B. Douglas Ward
00012   Date:     23 May 1997
00013 
00014 */
00015 
00016 /*---------------------------------------------------------------------------*/
00017 /*
00018   This software is Copyright 1997 by
00019 
00020             Medical College of Wisconsin
00021             8701 Watertown Plank Road
00022             Milwaukee, WI 53226
00023 
00024   License is granted to use this program for nonprofit research purposes only.
00025   It is specifically against the license to use this program for any clinical
00026   application. The Medical College of Wisconsin makes no warranty of usefulness
00027   of this program for any particular purpose.  The redistribution of this
00028   program for a fee, or the derivation of for-profit works from this program
00029   is not allowed.
00030 */
00031 
00032 
00033 /*---------------------------------------------------------------------------*/
00034 
00035 #include "NLfit_model.h"
00036 
00037 /*---------------------------------------------------------------------------*/
00038 /*
00039   Routine to generate a uniform U(0,1) random variate.
00040 */
00041 
00042 float uniform ();
00043 
00044 
00045 /*---------------------------------------------------------------------------*/
00046 /*
00047   Routine to generate a normal N(0,1) random variate.
00048 */
00049 
00050 void normal (float * n1, float * n2);
00051 
00052 
00053 /*---------------------------------------------------------------------------*/
00054 /*
00055   Routine to generate a U(a,b) random variate.
00056 */
00057 
00058 float get_random_value(float a, float b);
00059 
00060 
00061 /*---------------------------------------------------------------------------*/
00062 /*
00063   Allocate memory for simplex algorithm.
00064 */
00065 
00066 void allocate_arrays 
00067 (
00068   int dimension,              /* dimension of parameter space */
00069   float *** simplex,          /* the simplex itself */
00070   float ** centroid,          /* center of mass of the simplex */
00071   float ** response,          /* error sum of squares at each vertex */
00072   float ** step_size,         /* controls random placement of new vertex */
00073   float ** test1,             /* test vertex */
00074   float ** test2              /* test vertex */
00075 );
00076 
00077 
00078 /*---------------------------------------------------------------------------*/
00079 /*
00080   Set up initial values for the simplex vertices.
00081 */
00082 
00083 void initialize_simplex 
00084 (
00085   int dimension,          /* dimension of the full model */
00086   vfp nmodel,             /* pointer to noise model */
00087   vfp smodel,             /* pointer to signal model */
00088   int r,                  /* number of parameters in the noise model */
00089   int p,                  /* number of parameters in the signal model */
00090   int nabs,               /* use absolute constraints for noise parameters */
00091   float * min_nconstr,    /* minimum parameter constraints for noise model */
00092   float * max_nconstr,    /* maximum parameter constraints for noise model */
00093   float * min_sconstr,    /* minimum parameter constraints for signal model */
00094   float * max_sconstr,    /* maximum parameter constraints for signal model */
00095   float * par_rdcd,       /* estimated parameters for the reduced model */
00096   float * parameters,     /* starting point */
00097   float ** simplex,       /* the simplex itself */
00098   float * response,       /* sse at each vertex of the simplex */
00099   float * step_size,      /* amount of allowed variation at each parameter */
00100   int ts_length,          /* length of time series array */
00101   float ** x_array,       /* independent variable matrix */
00102   float * ts_array        /* observed time series */
00103 );
00104 
00105 
00106 /*---------------------------------------------------------------------------*/
00107 /*
00108   Evaluate the vertices of the simplex.  Find indices of the best, worst, and 
00109   next-to-worst vertices.
00110 */
00111 
00112 void eval_vertices 
00113 (
00114  int dimension,            /* dimension of parameter space */
00115  float * response,         /* error sum of squares at each vertex */
00116  int * worst,              /* index of worst vertex in simplex */
00117  int * next,               /* index of next-to-worst vertex in simplex */
00118  int * best                /* index of best vertex in simplex */
00119 );
00120 
00121 
00122 /*---------------------------------------------------------------------------*/
00123 /*
00124   Routine to restart the simplex algorithm by putting random vectors into
00125   the simplex (and keeping the best previous vertex).
00126 */
00127 
00128 void restart 
00129 (
00130   int dimension,          /* dimension of the full model */
00131   vfp nmodel,             /* pointer to noise model */
00132   vfp smodel,             /* pointer to signal model */
00133   int r,                  /* number of parameters in the noise model */
00134   int p,                  /* number of parameters in the signal model */
00135   int nabs,               /* use absolute constraints for noise parameters */
00136   float * min_nconstr,    /* minimum parameter constraints for noise model */
00137   float * max_nconstr,    /* maximum parameter constraints for noise model */
00138   float * min_sconstr,    /* minimum parameter constraints for signal model */
00139   float * max_sconstr,    /* maximum parameter constraints for signal model */
00140   float * par_rdcd,       /* estimated parameters for the reduced model */
00141   float ** simplex,       /* the simplex itself */
00142   float * response,       /* sse at each vertex of the simplex */
00143   float * step_size,      /* amount of allowed variation at each parameter */
00144   int ts_length,          /* length of time series array */
00145   float ** x_array,       /* independent variable matrix */
00146   float * ts_array        /* observed time series */
00147 );
00148 
00149 
00150 /*---------------------------------------------------------------------------*/
00151 /*
00152   Calculate the centroid of the simplex, ignoring the worst vertex.
00153 */
00154 
00155 void calc_centroid 
00156 (
00157   int dimension,         /* dimension of parameter space */
00158   float ** simplex,      /* the simplex itself */
00159   int worst,             /* index of worst vertex in simplex */
00160   float * centroid       /* center of mass of the simplex minus worst vertex */
00161 );
00162 
00163 
00164 /*---------------------------------------------------------------------------*/
00165 /*
00166   Calculate the reflection of the worst vertex about the centroid.
00167 */
00168 
00169 void calc_reflection 
00170 (
00171   int dimension,               /* dimension of parameter space */
00172   float ** simplex,            /* the simplex itself */
00173   float * centroid,            /* center of mass of the simplex */
00174   int worst,                   /* index of worst vertex in simplex */
00175   float coef,                  /* expansion or contraction factor */
00176   float * vertex               /* new vertex */
00177 );
00178 
00179 
00180 /*---------------------------------------------------------------------------*/
00181 /*
00182   Replace a vertex of the simplex.
00183 */
00184 
00185 void replace 
00186 (
00187   int dimension,              /* dimension of parameter space */
00188   float ** simplex,           /* the simplex itself */
00189   float * response,           /* error sum of squares at each vertex */
00190   int index,                  /* index of vertex to be replaced */
00191   float * vertex,             /* new vertex */
00192   float resp                  /* error sum of squares at new vertex */
00193 );
00194 
00195 
00196 /*---------------------------------------------------------------------------*/
00197 /*
00198   Calculate the goodness of fit.  This is measured by the variation in 
00199   responses at the different vertices relative to the average response.
00200 */
00201 
00202 float calc_good_fit 
00203 (
00204   int dimension,                   /* dimension of parameter space */
00205   float * response                 /* error sum of squares at each vertex */
00206 );
00207 
00208 
00209 /*---------------------------------------------------------------------------*/
00210 /*
00211   Release memory required for simplex optimization.
00212 */
00213 
00214 void deallocate_arrays 
00215 (
00216   int dimension,              /* dimension of parameter space */
00217   float *** simplex,          /* the simplex itself */
00218   float ** centroid,          /* center of mass of the simplex */
00219   float ** response,          /* error sum of squares at each vertex */
00220   float ** step_size,         /* controls random placement of new vertex */
00221   float ** test1,             /* test vertex */
00222   float ** test2              /* test vertex */
00223 );
00224 
00225 
00226 /*---------------------------------------------------------------------------*/
00227 /*
00228   Implementation of the (non-linear) simplex optimization algorithm.
00229 */
00230 
00231 void simplex_optimization
00232 ( 
00233   vfp nmodel,             /* pointer to noise model */
00234   vfp smodel,             /* pointer to signal model */
00235   int r,                  /* number of parameters in the noise model */
00236   int p,                  /* number of parameters in the signal model */
00237   float * min_nconstr,    /* minimum parameter constraints for noise model */
00238   float * max_nconstr,    /* maximum parameter constraints for noise model */
00239   float * min_sconstr,    /* minimum parameter constraints for signal model */
00240   float * max_sconstr,    /* maximum parameter constraints for signal model */
00241   int nabs,               /* use absolute constraints for noise parameters */
00242   int ts_length,          /* length of time series array */
00243   float ** x_array,       /* independent variable matrix */
00244   float * ts_array,       /* observed time series */
00245   float * par_rdcd,       /* estimated parameters for the reduced model */
00246   float * parameters,     /* estimated parameters */
00247   float * sse             /* error sum of squares */
00248 );
00249 
00250 
00251 /*---------------------------------------------------------------------------*/
00252 
00253 
00254 
00255 
00256 
00257 
00258 
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 
00267 
00268 
 

Powered by Plone

This site conforms to the following standards: