/usr/include/vtk-6.2/vtkAmoebaMinimizer.h is in libvtk6-dev 6.2.0+dfsg1-10build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkAmoebaMinimizer.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkAmoebaMinimizer - nonlinear optimization with a simplex
// .SECTION Description
// vtkAmoebaMinimizer will modify a set of parameters in order to find
// the minimum of a specified function. The method used is commonly
// known as the amoeba method, it constructs an n-dimensional simplex
// in parameter space (i.e. a tetrahedron if the number or parameters
// is 3) and moves the vertices around parameter space until a local
// minimum is found. The amoeba method is robust, reasonably efficient,
// but is not guaranteed to find the global minimum if several local
// minima exist.
#ifndef vtkAmoebaMinimizer_h
#define vtkAmoebaMinimizer_h
#include "vtkCommonMathModule.h" // For export macro
#include "vtkObject.h"
class VTKCOMMONMATH_EXPORT vtkAmoebaMinimizer : public vtkObject
{
public:
static vtkAmoebaMinimizer *New();
vtkTypeMacro(vtkAmoebaMinimizer,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Specify the function to be minimized. When this function
// is called, it must get the parameter values by calling
// GetParameterValue() for each parameter, and then must
// call SetFunctionValue() to tell the minimizer what the result
// of the function evaluation was. The number of function
// evaluations used for the minimization can be retrieved
// using GetFunctionEvaluations().
void SetFunction(void (*f)(void *), void *arg);
// Description:
// Set a function to call when a void* argument is being discarded.
void SetFunctionArgDelete(void (*f)(void *));
// Description:
// Set the initial value for the specified parameter. Calling
// this function for any parameter will reset the Iterations
// and the FunctionEvaluations counts to zero. You must also
// use SetParameterScale() to specify the step size by which the
// parameter will be modified during the minimization. It is
// preferable to specify parameters by name, rather than by
// number.
void SetParameterValue(const char *name, double value);
void SetParameterValue(int i, double value);
// Description:
// Set the scale to use when modifying a parameter, i.e. the
// initial amount by which the parameter will be modified
// during the search for the minimum. It is preferable to
// identify scalars by name rather than by number.
void SetParameterScale(const char *name, double scale);
double GetParameterScale(const char *name);
void SetParameterScale(int i, double scale);
double GetParameterScale(int i) { return this->ParameterScales[i]; };
// Description:
// Get the value of a parameter at the current stage of the minimization.
// Call this method within the function that you are minimizing in order
// to get the current parameter values. It is preferable to specify
// parameters by name rather than by index.
double GetParameterValue(const char *name);
double GetParameterValue(int i) { return this->ParameterValues[i]; };
// Description:
// For completeness, an unchecked method to get the name for particular
// parameter (the result will be NULL if no name was set).
const char *GetParameterName(int i) { return this->ParameterNames[i]; };
// Description:
// Get the number of parameters that have been set.
int GetNumberOfParameters() { return this->NumberOfParameters; };
// Description:
// Initialize the minimizer. This will reset the number of parameters to
// zero so that the minimizer can be reused.
void Initialize();
// Description:
// Iterate until the minimum is found to within the specified tolerance,
// or until the MaxIterations has been reached.
virtual void Minimize();
// Description:
// Perform one iteration of minimization. Returns zero if the tolerance
// stopping criterion has been met.
virtual int Iterate();
// Description:
// Get the function value resulting from the minimization.
vtkSetMacro(FunctionValue,double);
double GetFunctionValue() { return this->FunctionValue; };
// Description:
// Set the amoeba contraction ratio. The default value of 0.5 gives
// fast convergence, but larger values such as 0.6 or 0.7 provide
// greater stability.
vtkSetClampMacro(ContractionRatio,double,0.5,1.0);
vtkGetMacro(ContractionRatio,double);
// Description:
// Set the amoeba expansion ratio. The default value is 2.0, which
// provides rapid expansion. Values between 1.1 and 2.0 are valid.
vtkSetClampMacro(ExpansionRatio,double,1.0,2.0);
vtkGetMacro(ExpansionRatio,double);
// Description:
// Specify the value tolerance to aim for during the minimization.
vtkSetMacro(Tolerance,double);
vtkGetMacro(Tolerance,double);
// Description:
// Specify the parameter tolerance to aim for during the minimization.
vtkSetMacro(ParameterTolerance,double);
vtkGetMacro(ParameterTolerance,double);
// Description:
// Specify the maximum number of iterations to try before giving up.
vtkSetMacro(MaxIterations,int);
vtkGetMacro(MaxIterations,int);
// Description:
// Return the number of interations that have been performed. This
// is not necessarily the same as the number of function evaluations.
vtkGetMacro(Iterations,int);
// Description:
// Return the number of times that the function has been evaluated.
vtkGetMacro(FunctionEvaluations,int);
// Description:
// Evaluate the function. This is usually called internally by the
// minimization code, but it is provided here as a public method.
void EvaluateFunction();
protected:
vtkAmoebaMinimizer();
~vtkAmoebaMinimizer();
//BTX
void (*Function)(void *);
void (*FunctionArgDelete)(void *);
void *FunctionArg;
//ETX
int NumberOfParameters;
char **ParameterNames;
double *ParameterValues;
double *ParameterScales;
double FunctionValue;
double ContractionRatio;
double ExpansionRatio;
double Tolerance;
double ParameterTolerance;
int MaxIterations;
int Iterations;
int FunctionEvaluations;
private:
// specific to amoeba simplex minimization
//BTX
double **AmoebaVertices;
double *AmoebaValues;
double *AmoebaSum;
double AmoebaSize;
double AmoebaHighValue;
int AmoebaNStepsNoImprovement;
void InitializeAmoeba();
void GetAmoebaParameterValues();
void TerminateAmoeba();
double TryAmoeba(double sum[], int high, double fac);
int PerformAmoeba();
int CheckParameterTolerance();
//ETX
vtkAmoebaMinimizer(const vtkAmoebaMinimizer&); // Not implemented.
void operator=(const vtkAmoebaMinimizer&); // Not implemented.
};
#endif
|