VTK
vtkAmoebaMinimizer.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAmoebaMinimizer.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
32 #ifndef vtkAmoebaMinimizer_h
33 #define vtkAmoebaMinimizer_h
34 
35 #include "vtkCommonMathModule.h" // For export macro
36 #include "vtkObject.h"
37 
38 class VTKCOMMONMATH_EXPORT vtkAmoebaMinimizer : public vtkObject
39 {
40 public:
41  static vtkAmoebaMinimizer *New();
43  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
44 
54  void SetFunction(void (*f)(void *), void *arg);
55 
59  void SetFunctionArgDelete(void (*f)(void *));
60 
62 
71  void SetParameterValue(const char *name, double value);
72  void SetParameterValue(int i, double value);
74 
76 
82  void SetParameterScale(const char *name, double scale);
83  double GetParameterScale(const char *name);
84  void SetParameterScale(int i, double scale);
85  double GetParameterScale(int i) { return this->ParameterScales[i]; };
87 
89 
95  double GetParameterValue(const char *name);
96  double GetParameterValue(int i) { return this->ParameterValues[i]; };
98 
103  const char *GetParameterName(int i) { return this->ParameterNames[i]; };
104 
108  int GetNumberOfParameters() { return this->NumberOfParameters; };
109 
114  void Initialize();
115 
120  virtual void Minimize();
121 
126  virtual int Iterate();
127 
129 
132  vtkSetMacro(FunctionValue,double);
133  double GetFunctionValue() { return this->FunctionValue; };
135 
137 
142  vtkSetClampMacro(ContractionRatio,double,0.5,1.0);
143  vtkGetMacro(ContractionRatio,double);
145 
147 
151  vtkSetClampMacro(ExpansionRatio,double,1.0,2.0);
152  vtkGetMacro(ExpansionRatio,double);
154 
156 
159  vtkSetMacro(Tolerance,double);
160  vtkGetMacro(Tolerance,double);
162 
164 
167  vtkSetMacro(ParameterTolerance,double);
168  vtkGetMacro(ParameterTolerance,double);
170 
172 
175  vtkSetMacro(MaxIterations,int);
176  vtkGetMacro(MaxIterations,int);
178 
180 
184  vtkGetMacro(Iterations,int);
186 
188 
191  vtkGetMacro(FunctionEvaluations,int);
193 
198  void EvaluateFunction();
199 
200 protected:
202  ~vtkAmoebaMinimizer() VTK_OVERRIDE;
203 
204  void (*Function)(void *);
205  void (*FunctionArgDelete)(void *);
206  void *FunctionArg;
207 
208  int NumberOfParameters;
209  char **ParameterNames;
210  double *ParameterValues;
211  double *ParameterScales;
212  double FunctionValue;
213 
214  double ContractionRatio;
215  double ExpansionRatio;
216 
217  double Tolerance;
218  double ParameterTolerance;
219  int MaxIterations;
220  int Iterations;
221  int FunctionEvaluations;
222 
223 private:
224 // specific to amoeba simplex minimization
225 
226  double **AmoebaVertices;
227  double *AmoebaValues;
228  double *AmoebaSum;
229  double AmoebaSize;
230  double AmoebaHighValue;
231  int AmoebaNStepsNoImprovement;
232 
233  void InitializeAmoeba();
234  void GetAmoebaParameterValues();
235  void TerminateAmoeba();
236  double TryAmoeba(double sum[], int high, double fac);
237  int PerformAmoeba();
238  int CheckParameterTolerance();
239 
240  vtkAmoebaMinimizer(const vtkAmoebaMinimizer&) VTK_DELETE_FUNCTION;
241  void operator=(const vtkAmoebaMinimizer&) VTK_DELETE_FUNCTION;
242 };
243 
244 #endif
const char * GetParameterName(int i)
For completeness, an unchecked method to get the name for particular parameter (the result will be NU...
nonlinear optimization with a simplex
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
double GetParameterValue(int i)
Get the value of a parameter at the current stage of the minimization.
double GetFunctionValue()
Get the function value resulting from the minimization.
double GetParameterScale(int i)
Set the scale to use when modifying a parameter, i.e.
a simple class to control print indentation
Definition: vtkIndent.h:39
int GetNumberOfParameters()
Get the number of parameters that have been set.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...