Image Component Library (ICL)
SimplexOptimizer.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLMath/src/ICLMath/SimplexOptimizer.h **
10 ** Module : ICLMath **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/Function.h>
35 #include <ICLUtils/Uncopyable.h>
36 #include <ICLMath/DynVector.h>
37 #include <ICLMath/FixedVector.h>
38 
39 namespace icl{
40  namespace math{
41 
43  template<class T, class Vector=DynColVector<T> >
45  const Vector &x;
46  const T fx;
47  const int iterations;
48  const std::vector<Vector> &vertices;
49  };
50 
51 
53 
144  template<class T, class Vector=DynColVector<T> >
146  struct Data;
147  Data *m_data;
148 
149  public:
155 
157 
168  SimplexOptimizer(error_function f, int dim,
169  int iterations=1E5, T minError=1.0E-10,
170  T minDelta=1.0E-10,
171  T a=1.0, T b=1.0, T g=0.5, T h=0.5);
172 
174  void setDim(int dim);
175 
177  void setA(T a);
178 
180  void setB(T b);
181 
183  void setG(T g);
184 
186  void setH(T h);
187 
189  void setIterations(int iterations);
190 
192  void setMinError(T minError);
193 
195  void setMinDelta(T minDelta);
196 
198  void setErrorFunction(error_function f);
199 
201  int getDim() const;
202 
204  T getA() const;
205 
207  T getB() const;
208 
210  T getG() const;
211 
213  T getH() const;
214 
216  int getIterations() const;
217 
219  T getMinError() const;
220 
222  T getMinDelta() const;
223 
225  error_function getErrorFunction() const;
226 
228  void setIterationCallback(const iteration_callback &cb);
229 
231 
234  Result optimize(const Vector &init);
235 
237 
238  Result optimize(const std::vector<Vector> &init);
239 
241  Result optimize(init_gen gen, int nInitCycles);
242 
244 
246  static std::vector<Vector> createDefaultSimplex(const Vector &init);
247  };
248  } // namespace math
249 }
250 
251 
The General Function Template.
Definition: Function.h:284
undocument this line if you encounter any issues!
Definition: Any.h:37
Class interface for un-copyable classes.
Definition: Uncopyable.h:64
utils::Function< Vector > init_gen
Definition: SimplexOptimizer.h:154
Data * m_data
internal data structure
Definition: SimplexOptimizer.h:146
utils::Function< T, const Vector & > error_function
error function type that is used
Definition: SimplexOptimizer.h:151
const std::vector< Vector > & vertices
end simplex vertices (usually only used for debugging purpose)
Definition: SimplexOptimizer.h:48
Utility structure, that is used as accumulator for results of the SimplexOptimizer class.
Definition: SimplexOptimizer.h:44
utils::Function< void, const Result & > iteration_callback
Definition: SimplexOptimizer.h:153
SimplexOptimizationResult< T, Vector > Result
Definition: SimplexOptimizer.h:152
const Vector & x
result vector
Definition: SimplexOptimizer.h:45
const int iterations
actual count of iterations that were used for optimization
Definition: SimplexOptimizer.h:47
Template based implementation for the Downhill Simplex Optimiztation method.
Definition: SimplexOptimizer.h:145
#define ICLMath_IMP
Definition: CompatMacros.h:172
const T fx
error function value at result vector position
Definition: SimplexOptimizer.h:46