VTK: Common/Math/vtkAmoebaMinimizer.h Source File

| 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:
190 vtkAmoebaMinimizer();
191 ~vtkAmoebaMinimizer() override;
192
193 void (*Function)(void*);
194 void (*FunctionArgDelete)(void*);
195 void* FunctionArg;
196
197 int NumberOfParameters;
198 char** ParameterNames;
199 double* ParameterValues;
200 double* ParameterScales;
201 double FunctionValue;
202
203 double ContractionRatio;
204 double ExpansionRatio;
205
206 double Tolerance;
207 double ParameterTolerance;
208 int MaxIterations;
209 int Iterations;
210 int FunctionEvaluations;
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
vtkAmoebaMinimizer
nonlinear optimization with a simplex
Definition: vtkAmoebaMinimizer.h:28
vtkAmoebaMinimizer::vtkAmoebaMinimizer
vtkAmoebaMinimizer()
vtkAmoebaMinimizer::GetParameterScale
double GetParameterScale(const char *name)
Set the scale to use when modifying a parameter, i.e.
vtkAmoebaMinimizer::Iterations
int Iterations
Definition: vtkAmoebaMinimizer.h:209
vtkAmoebaMinimizer::ParameterValues
double * ParameterValues
Definition: vtkAmoebaMinimizer.h:199
vtkAmoebaMinimizer::GetParameterValue
double GetParameterValue(int i)
Get the value of a parameter at the current stage of the minimization.
Definition: vtkAmoebaMinimizer.h:85
vtkAmoebaMinimizer::GetParameterScale
double GetParameterScale(int i)
Set the scale to use when modifying a parameter, i.e.
Definition: vtkAmoebaMinimizer.h:74
vtkAmoebaMinimizer::SetFunctionArgDelete
void SetFunctionArgDelete(void(*f)(void *))
Set a function to call when a void* argument is being discarded.
vtkAmoebaMinimizer::ExpansionRatio
double ExpansionRatio
Definition: vtkAmoebaMinimizer.h:204
vtkAmoebaMinimizer::MaxIterations
int MaxIterations
Definition: vtkAmoebaMinimizer.h:208
vtkAmoebaMinimizer::ContractionRatio
double ContractionRatio
Definition: vtkAmoebaMinimizer.h:203
vtkAmoebaMinimizer::ParameterNames
char ** ParameterNames
Definition: vtkAmoebaMinimizer.h:198
vtkAmoebaMinimizer::SetParameterScale
void SetParameterScale(const char *name, double scale)
Set the scale to use when modifying a parameter, i.e.
vtkAmoebaMinimizer::FunctionValue
double FunctionValue
Definition: vtkAmoebaMinimizer.h:201
vtkAmoebaMinimizer::Minimize
virtual void Minimize()
Iterate until the minimum is found to within the specified tolerance, or until the MaxIterations has ...
vtkAmoebaMinimizer::Iterate
virtual int Iterate()
Perform one iteration of minimization.
vtkAmoebaMinimizer::SetParameterValue
void SetParameterValue(int i, double value)
Set the initial value for the specified parameter.
vtkAmoebaMinimizer::SetParameterValue
void SetParameterValue(const char *name, double value)
Set the initial value for the specified parameter.
vtkAmoebaMinimizer::ParameterScales
double * ParameterScales
Definition: vtkAmoebaMinimizer.h:200
vtkAmoebaMinimizer::GetNumberOfParameters
int GetNumberOfParameters()
Get the number of parameters that have been set.
Definition: vtkAmoebaMinimizer.h:97
vtkAmoebaMinimizer::EvaluateFunction
void EvaluateFunction()
Evaluate the function.
vtkAmoebaMinimizer::Initialize
void Initialize()
Initialize the minimizer.
vtkAmoebaMinimizer::GetParameterValue
double GetParameterValue(const char *name)
Get the value of a parameter at the current stage of the minimization.
vtkAmoebaMinimizer::NumberOfParameters
int NumberOfParameters
Definition: vtkAmoebaMinimizer.h:197
vtkAmoebaMinimizer::SetFunction
void SetFunction(void(*f)(void *), void *arg)
Specify the function to be minimized.
vtkAmoebaMinimizer::GetFunctionValue
double GetFunctionValue()
Get the function value resulting from the minimization.
Definition: vtkAmoebaMinimizer.h:122
vtkAmoebaMinimizer::FunctionArg
void * FunctionArg
Definition: vtkAmoebaMinimizer.h:195
vtkAmoebaMinimizer::GetParameterName
const char * GetParameterName(int i)
For completeness, an unchecked method to get the name for particular parameter (the result will be nu...
Definition: vtkAmoebaMinimizer.h:92
vtkAmoebaMinimizer::SetParameterScale
void SetParameterScale(int i, double scale)
Set the scale to use when modifying a parameter, i.e.
vtkAmoebaMinimizer::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAmoebaMinimizer::Tolerance
double Tolerance
Definition: vtkAmoebaMinimizer.h:206
vtkAmoebaMinimizer::~vtkAmoebaMinimizer
~vtkAmoebaMinimizer() override
vtkAmoebaMinimizer::ParameterTolerance
double ParameterTolerance
Definition: vtkAmoebaMinimizer.h:207
vtkAmoebaMinimizer::New
static vtkAmoebaMinimizer * New()
vtkAmoebaMinimizer::FunctionEvaluations
int FunctionEvaluations
Definition: vtkAmoebaMinimizer.h:210
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkX3D::scale
@ scale
Definition: vtkX3D.h:229
vtkX3D::name
@ name
Definition: vtkX3D.h:219
vtkObject.h