VTK  9.3.1
vtkAmoebaMinimizer.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
20 #ifndef vtkAmoebaMinimizer_h
21 #define vtkAmoebaMinimizer_h
22 
23 #include "vtkCommonMathModule.h" // For export macro
24 #include "vtkObject.h"
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class VTKCOMMONMATH_EXPORT vtkAmoebaMinimizer : public vtkObject
28 {
29 public:
30  static vtkAmoebaMinimizer* New();
31  vtkTypeMacro(vtkAmoebaMinimizer, vtkObject);
32  void PrintSelf(ostream& os, vtkIndent indent) override;
33 
43  void SetFunction(void (*f)(void*), void* arg);
44 
48  void SetFunctionArgDelete(void (*f)(void*));
49 
51 
60  void SetParameterValue(const char* name, double value);
61  void SetParameterValue(int i, double value);
63 
65 
71  void SetParameterScale(const char* name, double scale);
72  double GetParameterScale(const char* name);
73  void SetParameterScale(int i, double scale);
74  double GetParameterScale(int i) { return this->ParameterScales[i]; }
76 
78 
84  double GetParameterValue(const char* name);
85  double GetParameterValue(int i) { return this->ParameterValues[i]; }
87 
92  const char* GetParameterName(int i) { return this->ParameterNames[i]; }
93 
97  int GetNumberOfParameters() { return this->NumberOfParameters; }
98 
103  void Initialize();
104 
109  virtual void Minimize();
110 
115  virtual int Iterate();
116 
118 
121  vtkSetMacro(FunctionValue, double);
122  double GetFunctionValue() { return this->FunctionValue; }
124 
126 
131  vtkSetClampMacro(ContractionRatio, double, 0.5, 1.0);
132  vtkGetMacro(ContractionRatio, double);
134 
136 
140  vtkSetClampMacro(ExpansionRatio, double, 1.0, 2.0);
141  vtkGetMacro(ExpansionRatio, double);
143 
145 
148  vtkSetMacro(Tolerance, double);
149  vtkGetMacro(Tolerance, double);
151 
153 
156  vtkSetMacro(ParameterTolerance, double);
157  vtkGetMacro(ParameterTolerance, double);
159 
161 
164  vtkSetMacro(MaxIterations, int);
165  vtkGetMacro(MaxIterations, int);
167 
169 
173  vtkGetMacro(Iterations, int);
175 
177 
180  vtkGetMacro(FunctionEvaluations, int);
182 
187  void EvaluateFunction();
188 
189 protected:
191  ~vtkAmoebaMinimizer() override;
192 
193  void (*Function)(void*);
194  void (*FunctionArgDelete)(void*);
195  void* FunctionArg;
196 
202 
205 
206  double Tolerance;
211 
212 private:
213  // specific to amoeba simplex minimization
214 
215  double** AmoebaVertices;
216  double* AmoebaValues;
217  double* AmoebaSum;
218  double AmoebaSize;
219  double AmoebaHighValue;
220  int AmoebaNStepsNoImprovement;
221 
222  void InitializeAmoeba();
223  void GetAmoebaParameterValues();
224  void TerminateAmoeba();
225  double TryAmoeba(double sum[], int high, double fac);
226  int PerformAmoeba();
227  int CheckParameterTolerance();
228 
229  vtkAmoebaMinimizer(const vtkAmoebaMinimizer&) = delete;
230  void operator=(const vtkAmoebaMinimizer&) = delete;
231 };
232 
233 VTK_ABI_NAMESPACE_END
234 #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:51
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:28
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...