VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkAmoebaMinimizer.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00031 #ifndef __vtkAmoebaMinimizer_h 00032 #define __vtkAmoebaMinimizer_h 00033 00034 #include "vtkObject.h" 00035 00036 class VTK_COMMON_EXPORT vtkAmoebaMinimizer : public vtkObject 00037 { 00038 public: 00039 static vtkAmoebaMinimizer *New(); 00040 vtkTypeMacro(vtkAmoebaMinimizer,vtkObject); 00041 void PrintSelf(ostream& os, vtkIndent indent); 00042 00049 void SetFunction(void (*f)(void *), void *arg); 00050 00052 void SetFunctionArgDelete(void (*f)(void *)); 00053 00055 00061 void SetParameterValue(const char *name, double value); 00062 void SetParameterValue(int i, double value); 00064 00066 00070 void SetParameterScale(const char *name, double scale); 00071 double GetParameterScale(const char *name); 00072 void SetParameterScale(int i, double scale); 00073 double GetParameterScale(int i) { return this->ParameterScales[i]; }; 00075 00077 00081 double GetParameterValue(const char *name); 00082 double GetParameterValue(int i) { return this->ParameterValues[i]; }; 00084 00087 const char *GetParameterName(int i) { return this->ParameterNames[i]; }; 00088 00090 int GetNumberOfParameters() { return this->NumberOfParameters; }; 00091 00094 void Initialize(); 00095 00098 virtual void Minimize(); 00099 00102 virtual int Iterate(); 00103 00105 00106 vtkSetMacro(FunctionValue,double); 00107 double GetFunctionValue() { return this->FunctionValue; }; 00109 00111 00114 vtkSetClampMacro(ContractionRatio,double,0.5,1.0); 00115 vtkGetMacro(ContractionRatio,double); 00117 00119 00121 vtkSetClampMacro(ExpansionRatio,double,1.0,2.0); 00122 vtkGetMacro(ExpansionRatio,double); 00124 00126 00127 vtkSetMacro(Tolerance,double); 00128 vtkGetMacro(Tolerance,double); 00130 00132 00133 vtkSetMacro(ParameterTolerance,double); 00134 vtkGetMacro(ParameterTolerance,double); 00136 00138 00139 vtkSetMacro(MaxIterations,int); 00140 vtkGetMacro(MaxIterations,int); 00142 00144 00146 vtkGetMacro(Iterations,int); 00148 00150 00151 vtkGetMacro(FunctionEvaluations,int); 00153 00156 void EvaluateFunction(); 00157 00158 protected: 00159 vtkAmoebaMinimizer(); 00160 ~vtkAmoebaMinimizer(); 00161 00162 //BTX 00163 void (*Function)(void *); 00164 void (*FunctionArgDelete)(void *); 00165 void *FunctionArg; 00166 //ETX 00167 00168 int NumberOfParameters; 00169 char **ParameterNames; 00170 double *ParameterValues; 00171 double *ParameterScales; 00172 double FunctionValue; 00173 00174 double ContractionRatio; 00175 double ExpansionRatio; 00176 00177 double Tolerance; 00178 double ParameterTolerance; 00179 int MaxIterations; 00180 int Iterations; 00181 int FunctionEvaluations; 00182 00183 private: 00184 // specific to amoeba simplex minimization 00185 //BTX 00186 double **AmoebaVertices; 00187 double *AmoebaValues; 00188 double *AmoebaSum; 00189 double AmoebaSize; 00190 double AmoebaHighValue; 00191 int AmoebaNStepsNoImprovement; 00192 00193 void InitializeAmoeba(); 00194 void GetAmoebaParameterValues(); 00195 void TerminateAmoeba(); 00196 double TryAmoeba(double sum[], int high, double fac); 00197 int PerformAmoeba(); 00198 int CheckParameterTolerance(); 00199 //ETX 00200 00201 vtkAmoebaMinimizer(const vtkAmoebaMinimizer&); // Not implemented. 00202 void operator=(const vtkAmoebaMinimizer&); // Not implemented. 00203 }; 00204 00205 #endif