Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SimplexOptimizer.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLMath/src/ICLMath/SimplexOptimizer.h                 **
00010 ** Module : ICLMath                                                **
00011 ** Authors: Christof Elbrechter                                    **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.GPL  **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #include <ICLMath/DynVector.h>
00034 #include <ICLMath/FixedVector.h>
00035 #include <ICLUtils/Function.h>
00036 #include <ICLUtils/Uncopyable.h>
00037 
00038 namespace icl{
00039   namespace math{
00040     
00042     template<class T, class Vector=DynColVector<T> >
00043     struct SimplexOptimizationResult{
00044       const Vector &x;                      
00045       const T fx;                           
00046       const int iterations;                 
00047       const std::vector<Vector> &vertices;  
00048     };
00049     
00050     
00052 
00143     template<class T, class Vector=DynColVector<T> >
00144     class SimplexOptimizer : public utils::Uncopyable{
00145       struct Data; 
00146       Data *m_data;  
00147   
00148       public:
00150       typedef utils::Function<T, const Vector&> error_function;
00151       typedef SimplexOptimizationResult<T,Vector> Result;
00152       typedef utils::Function<void,const Result &> iteration_callback;
00153       
00154   
00156 
00167       SimplexOptimizer(error_function f, int dim,
00168                        int iterations=1E5, T minError=1.0E-10, 
00169                        T minDelta=1.0E-10,
00170                        T a=1.0, T b=1.0, T g=0.5, T h=0.5);
00171   
00173       void setDim(int dim);
00174       
00176       void setA(T a);
00177   
00179       void setB(T b);
00180   
00182       void setG(T g);
00183       
00185       void setH(T h);
00186       
00188       void setIterations(int iterations);
00189       
00191       void setMinError(T minError);
00192       
00194       void setMinDelta(T minDelta);
00195       
00197       void setErrorFunction(error_function f);
00198       
00200       int getDim() const;
00201       
00203       T getA() const;
00204       
00206       T getB() const;
00207   
00209       T getG() const;
00210       
00212       T getH() const;
00213       
00215       int getIterations() const;
00216       
00218       T getMinError() const;
00219       
00221       T getMinDelta() const;
00222   
00224       error_function getErrorFunction() const;
00225   
00227       void setIterationCallback(const iteration_callback &cb);
00228       
00230 
00233       Result optimize(const Vector &init);
00234       
00236 
00237       Result optimize(const std::vector<Vector> &init);
00238       
00240 
00242       static std::vector<Vector> createDefaultSimplex(const Vector &init);
00243     };
00244   } // namespace math
00245 } 
00246 
00247 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines