VTK  9.4.20241223
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
26VTK_ABI_NAMESPACE_BEGIN
27class VTKCOMMONMATH_EXPORT vtkAmoebaMinimizer : public vtkObject
28{
29public:
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
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
188
189protected:
192
193 void (*Function)(void*);
194 void (*FunctionArgDelete)(void*);
196
202
205
206 double Tolerance;
211
212private:
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
233VTK_ABI_NAMESPACE_END
234#endif
nonlinear optimization with a simplex
double GetParameterScale(const char *name)
Set the scale to use when modifying a parameter, i.e.
double GetParameterValue(int i)
Get the value of a parameter at the current stage of the minimization.
double GetParameterScale(int i)
Set the scale to use when modifying a parameter, i.e.
void SetFunctionArgDelete(void(*f)(void *))
Set a function to call when a void* argument is being discarded.
const char * GetParameterName(int i)
For completeness, an unchecked method to get the name for particular parameter (the result will be nu...
static vtkAmoebaMinimizer * New()
void SetParameterScale(const char *name, double scale)
Set the scale to use when modifying a parameter, i.e.
virtual void Minimize()
Iterate until the minimum is found to within the specified tolerance, or until the MaxIterations has ...
virtual int Iterate()
Perform one iteration of minimization.
void SetParameterValue(int i, double value)
Set the initial value for the specified parameter.
void SetParameterValue(const char *name, double value)
Set the initial value for the specified parameter.
int GetNumberOfParameters()
Get the number of parameters that have been set.
void EvaluateFunction()
Evaluate the function.
void Initialize()
Initialize the minimizer.
double GetParameterValue(const char *name)
Get the value of a parameter at the current stage of the minimization.
void SetFunction(void(*f)(void *), void *arg)
Specify the function to be minimized.
double GetFunctionValue()
Get the function value resulting from the minimization.
void SetParameterScale(int i, double scale)
Set the scale to use when modifying a parameter, i.e.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
~vtkAmoebaMinimizer() override
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162