123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- ///
- ///
- /// @file: DownhillSimplexOptimizer.h: interface of the downhill Simplex Optimier
- /// @author: Matthias Wacker, Esther Plater
- ///
- ///
- #ifndef _DOWNHILL_SIMPLEX_OPTIMIZER_H_
- #define _DOWNHILL_SIMPLEX_OPTIMIZER_H_
- #include <cmath>
- #include "optimization/SimpleOptimizer.h"
- /// To enabable Rank check, define
- /// #define OPTIMIZATION_DOWNHILLSIMPLEX_ENABLE_RANK_CHECK
- ///
- /// @class DownhillSimplexOptimizer
- ///
- /// HowToUse:
- ///
- /// * use setWholeSimplex to initialize the whole simplex OR use
- /// * use setParameters() to specify one point of the simplex
- /// the init call will then generate random disturbations to
- /// generate a full rank simplex
- /// * use setDownhillParams() to use others than the default to "move"
- /// the simplex
- /// * call init()
- /// * call optimize()
- ///
- ///
- /// Implemented Abort criteria:
- ///
- /// * maximum number of iterations
- /// * time limit
- /// * parameter bounds
- /// * function value tolerance
- /// * parameter tolerance
- ///
- /// Additional return reason:
- ///
- ///
- class DownhillSimplexOptimizer : public SimpleOptimizer
- {
- public:
- typedef SimpleOptimizer SuperClass;
- typedef SuperClass::matrix_type matrix_type;
- ///
- /// Constructor
- /// @param loger : OptLogBase * to existing log class or NULL
- ///
- DownhillSimplexOptimizer(OptLogBase *loger=NULL);
- ///
- /// CopyConstructor
- /// @param opt : DownhillSimplexOptimizer to copy
- ///
- DownhillSimplexOptimizer(const DownhillSimplexOptimizer &opt);
- ///
- ///
- ///
- ~DownhillSimplexOptimizer();
-
- ///
- /// set downhill specific parameters
- /// @param alpha
- /// @param beta
- /// @param gamma
- ///
- ///
- void setDownhillParams(const double alpha, const double beta, const double gamma);
-
- ///
- /// Sets the rank deficiency threshold
- /// @param rankdeficiencythresh rank deficiency threshold (DEFAULT= 0.01)
- ///
- void setRankDeficiencyThresh(float rankdeficiencythresh);
-
- ///
- /// Enable or disable the rank check
- /// @param status give the status for a rank check
- ///
- void setRankCheckStatus(bool status);
-
- /**
- * @brief get the downhill simplex parameter alpha, needed for the reflection
- * @date 27-09-2012
- * @author Alexander Freytag
- */
- double getDownhillParameterAlpha() const;
-
- /**
- * @brief get the downhill simplex parameter alpha, needed for the contraction
- * @date 27-09-2012
- * @author Alexander Freytag
- */
- double getDownhillParameterBeta() const;
-
- /**
- * @brief get the downhill simplex parameter alpha, needed for the expansion
- * @date 27-09-2012
- * @author Alexander Freytag
- */
- double getDownhillParameterGamma() const;
-
- ///
- /// Returns the status of rankcheck
- /// @retval true, if rankcheck is enabled
- /// @retval false, if rankcheck is disabled
- ///
- bool getRankCheckStatus();
- ///
- /// Do internal initializations
- ///
- void init();
- protected:
- ///
- /// start optimization
- ///
- virtual int optimize();
-
- private:
- ///
- /// Initialize the whole simplex, for that, numOfParameters+1 points a needed.
- /// (You might want to detemine these points by a random search before)
- /// @param simplex : Matrix containing numOfParameters+1 points
- /// that are numOfParameters-dimensional
- /// @return bool : indicating if attempt was successfull
- /// (might not, if dimensions don't match)
- ///
- bool setWholeSimplex(const matrix_type &simplex);
-
- ///
- /// internal bool to store if simplex is initialized
- ///
- bool m_simplexInitialized;
-
-
- ///
- /// internal bool to offer a break in all internal functions
- ///
- bool m_abort;
- ///
- /// internal parameter to control the transformations of the simplex
- ///
- double m_alpha;
-
- ///
- /// internal parameter to control the transformations of the simplex
- ///
- double m_gamma;
-
- ///
- /// internal parameter to control the transformations of the simplex
- ///
- double m_beta;
- ///
- ///This method does the optimization itself.
- /// It is called by optimize and returns the index of the "final"
- /// vertice matrix that is the lowest / highest point found.
- ///
- int amoeba();
- ///
- /// This method does the extrapolation of highest vertice through the
- /// simplex by the factor fac. It is called by amoeba()
- ///
- double amotry(matrix_type& psum,int ihi, double fac);
- ///
- /// Matrix containing the vertices of the simplex
- ///
- matrix_type m_vertices;
-
- ///
- /// Matrix(1dim) containing the function values corresponding to
- /// vertices
- ///
- matrix_type m_y;
- ///
- /// Rang deficiency threshold
- ///
- float m_rankdeficiencythresh;
-
- ///
- /// Rank check status: if false, a rank check is disabled (default)
- ///
- bool m_rankcheckenabled;
-
- };
- ///
- /// Check Rank of a matrix_type where singular values lower than numZero
- /// are treated as zero. The computation is done by singular value
- /// decomposition. Returns the numerical rank
- /// of the matrix
- ///
- /// @param A matrix to compute rank of..
- /// @param numZero threshold to decide for numerical zero
- /// @return (numerical) rank of A
- ///
- unsigned int getRank(const optimization::matrix_type& A, double numZero);
-
-
- #endif
|