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 "vtkCommonMathModule.h" // For export macro 00035 #include "vtkObject.h" 00036 00037 class VTKCOMMONMATH_EXPORT vtkAmoebaMinimizer : public vtkObject 00038 { 00039 public: 00040 static vtkAmoebaMinimizer *New(); 00041 vtkTypeMacro(vtkAmoebaMinimizer,vtkObject); 00042 void PrintSelf(ostream& os, vtkIndent indent); 00043 00050 void SetFunction(void (*f)(void *), void *arg); 00051 00053 void SetFunctionArgDelete(void (*f)(void *)); 00054 00056 00062 void SetParameterValue(const char *name, double value); 00063 void SetParameterValue(int i, double value); 00065 00067 00071 void SetParameterScale(const char *name, double scale); 00072 double GetParameterScale(const char *name); 00073 void SetParameterScale(int i, double scale); 00074 double GetParameterScale(int i) { return this->ParameterScales[i]; }; 00076 00078 00082 double GetParameterValue(const char *name); 00083 double GetParameterValue(int i) { return this->ParameterValues[i]; }; 00085 00088 const char *GetParameterName(int i) { return this->ParameterNames[i]; }; 00089 00091 int GetNumberOfParameters() { return this->NumberOfParameters; }; 00092 00095 void Initialize(); 00096 00099 virtual void Minimize(); 00100 00103 virtual int Iterate(); 00104 00106 00107 vtkSetMacro(FunctionValue,double); 00108 double GetFunctionValue() { return this->FunctionValue; }; 00110 00112 00115 vtkSetClampMacro(ContractionRatio,double,0.5,1.0); 00116 vtkGetMacro(ContractionRatio,double); 00118 00120 00122 vtkSetClampMacro(ExpansionRatio,double,1.0,2.0); 00123 vtkGetMacro(ExpansionRatio,double); 00125 00127 00128 vtkSetMacro(Tolerance,double); 00129 vtkGetMacro(Tolerance,double); 00131 00133 00134 vtkSetMacro(ParameterTolerance,double); 00135 vtkGetMacro(ParameterTolerance,double); 00137 00139 00140 vtkSetMacro(MaxIterations,int); 00141 vtkGetMacro(MaxIterations,int); 00143 00145 00147 vtkGetMacro(Iterations,int); 00149 00151 00152 vtkGetMacro(FunctionEvaluations,int); 00154 00157 void EvaluateFunction(); 00158 00159 protected: 00160 vtkAmoebaMinimizer(); 00161 ~vtkAmoebaMinimizer(); 00162 00163 //BTX 00164 void (*Function)(void *); 00165 void (*FunctionArgDelete)(void *); 00166 void *FunctionArg; 00167 //ETX 00168 00169 int NumberOfParameters; 00170 char **ParameterNames; 00171 double *ParameterValues; 00172 double *ParameterScales; 00173 double FunctionValue; 00174 00175 double ContractionRatio; 00176 double ExpansionRatio; 00177 00178 double Tolerance; 00179 double ParameterTolerance; 00180 int MaxIterations; 00181 int Iterations; 00182 int FunctionEvaluations; 00183 00184 private: 00185 // specific to amoeba simplex minimization 00186 //BTX 00187 double **AmoebaVertices; 00188 double *AmoebaValues; 00189 double *AmoebaSum; 00190 double AmoebaSize; 00191 double AmoebaHighValue; 00192 int AmoebaNStepsNoImprovement; 00193 00194 void InitializeAmoeba(); 00195 void GetAmoebaParameterValues(); 00196 void TerminateAmoeba(); 00197 double TryAmoeba(double sum[], int high, double fac); 00198 int PerformAmoeba(); 00199 int CheckParameterTolerance(); 00200 //ETX 00201 00202 vtkAmoebaMinimizer(const vtkAmoebaMinimizer&); // Not implemented. 00203 void operator=(const vtkAmoebaMinimizer&); // Not implemented. 00204 }; 00205 00206 #endif