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 =========================================================================*/
31 #ifndef __vtkAmoebaMinimizer_h
32 #define __vtkAmoebaMinimizer_h
33 
34 #include "vtkObject.h"
35 
37 {
38 public:
39  static vtkAmoebaMinimizer *New();
41  void PrintSelf(ostream& os, vtkIndent indent);
42 
49  void SetFunction(void (*f)(void *), void *arg);
50 
52  void SetFunctionArgDelete(void (*f)(void *));
53 
55 
61  void SetParameterValue(const char *name, double value);
62  void SetParameterValue(int i, double value);
64 
66 
70  void SetParameterScale(const char *name, double scale);
71  double GetParameterScale(const char *name);
72  void SetParameterScale(int i, double scale);
73  double GetParameterScale(int i) { return this->ParameterScales[i]; };
75 
77 
81  double GetParameterValue(const char *name);
82  double GetParameterValue(int i) { return this->ParameterValues[i]; };
84 
87  const char *GetParameterName(int i) { return this->ParameterNames[i]; };
88 
90  int GetNumberOfParameters() { return this->NumberOfParameters; };
91 
94  void Initialize();
95 
98  virtual void Minimize();
99 
102  virtual int Iterate();
103 
105 
106  vtkSetMacro(FunctionValue,double);
107  double GetFunctionValue() { return this->FunctionValue; };
109 
111 
114  vtkSetClampMacro(ContractionRatio,double,0.5,1.0);
115  vtkGetMacro(ContractionRatio,double);
117 
119 
121  vtkSetClampMacro(ExpansionRatio,double,1.0,2.0);
122  vtkGetMacro(ExpansionRatio,double);
124 
126 
127  vtkSetMacro(Tolerance,double);
128  vtkGetMacro(Tolerance,double);
130 
132 
133  vtkSetMacro(ParameterTolerance,double);
134  vtkGetMacro(ParameterTolerance,double);
136 
138 
139  vtkSetMacro(MaxIterations,int);
140  vtkGetMacro(MaxIterations,int);
142 
144 
146  vtkGetMacro(Iterations,int);
148 
150 
151  vtkGetMacro(FunctionEvaluations,int);
153 
156  void EvaluateFunction();
157 
158 protected:
161 
162 //BTX
163  void (*Function)(void *);
164  void (*FunctionArgDelete)(void *);
165  void *FunctionArg;
166 //ETX
167 
173 
176 
177  double Tolerance;
182 
183 private:
184 // specific to amoeba simplex minimization
185 //BTX
186  double **AmoebaVertices;
187  double *AmoebaValues;
188  double *AmoebaSum;
189  double AmoebaSize;
190  double AmoebaHighValue;
191  int AmoebaNStepsNoImprovement;
192 
193  void InitializeAmoeba();
194  void GetAmoebaParameterValues();
195  void TerminateAmoeba();
196  double TryAmoeba(double sum[], int high, double fac);
197  int PerformAmoeba();
198  int CheckParameterTolerance();
199 //ETX
200 
201  vtkAmoebaMinimizer(const vtkAmoebaMinimizer&); // Not implemented.
202  void operator=(const vtkAmoebaMinimizer&); // Not implemented.
203 };
204 
205 #endif