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 =========================================================================*/
29 #ifndef vtkAmoebaMinimizer_h
30 #define vtkAmoebaMinimizer_h
31 
32 #include "vtkCommonMathModule.h" // For export macro
33 #include "vtkObject.h"
34 
35 class VTKCOMMONMATH_EXPORT vtkAmoebaMinimizer : public vtkObject
36 {
37 public:
38  static vtkAmoebaMinimizer *New();
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
51  void SetFunction(void (*f)(void *), void *arg);
52 
56  void SetFunctionArgDelete(void (*f)(void *));
57 
59 
68  void SetParameterValue(const char *name, double value);
69  void SetParameterValue(int i, double value);
71 
73 
79  void SetParameterScale(const char *name, double scale);
80  double GetParameterScale(const char *name);
81  void SetParameterScale(int i, double scale);
82  double GetParameterScale(int i) { return this->ParameterScales[i]; };
84 
86 
92  double GetParameterValue(const char *name);
93  double GetParameterValue(int i) { return this->ParameterValues[i]; };
95 
100  const char *GetParameterName(int i) { return this->ParameterNames[i]; };
101 
105  int GetNumberOfParameters() { return this->NumberOfParameters; };
106 
111  void Initialize();
112 
117  virtual void Minimize();
118 
123  virtual int Iterate();
124 
126 
129  vtkSetMacro(FunctionValue,double);
130  double GetFunctionValue() { return this->FunctionValue; };
132 
134 
139  vtkSetClampMacro(ContractionRatio,double,0.5,1.0);
140  vtkGetMacro(ContractionRatio,double);
142 
144 
148  vtkSetClampMacro(ExpansionRatio,double,1.0,2.0);
149  vtkGetMacro(ExpansionRatio,double);
151 
153 
156  vtkSetMacro(Tolerance,double);
157  vtkGetMacro(Tolerance,double);
159 
161 
164  vtkSetMacro(ParameterTolerance,double);
165  vtkGetMacro(ParameterTolerance,double);
167 
169 
172  vtkSetMacro(MaxIterations,int);
173  vtkGetMacro(MaxIterations,int);
175 
177 
181  vtkGetMacro(Iterations,int);
183 
185 
188  vtkGetMacro(FunctionEvaluations,int);
190 
195  void EvaluateFunction();
196 
197 protected:
199  ~vtkAmoebaMinimizer() override;
200 
201  void (*Function)(void *);
202  void (*FunctionArgDelete)(void *);
203  void *FunctionArg;
204 
210 
213 
214  double Tolerance;
219 
220 private:
221 // specific to amoeba simplex minimization
222 
223  double **AmoebaVertices;
224  double *AmoebaValues;
225  double *AmoebaSum;
226  double AmoebaSize;
227  double AmoebaHighValue;
228  int AmoebaNStepsNoImprovement;
229 
230  void InitializeAmoeba();
231  void GetAmoebaParameterValues();
232  void TerminateAmoeba();
233  double TryAmoeba(double sum[], int high, double fac);
234  int PerformAmoeba();
235  int CheckParameterTolerance();
236 
237  vtkAmoebaMinimizer(const vtkAmoebaMinimizer&) = delete;
238  void operator=(const vtkAmoebaMinimizer&) = delete;
239 };
240 
241 #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:53
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:33
int GetNumberOfParameters()
Get the number of parameters that have been set.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.