123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- #ifndef _OPTIMIZER_H_
- #define _OPTIMIZER_H_
- #include <time.h>
- #include "core/optimization/blackbox/CostFunction.h"
- #include "core/optimization/blackbox/OptLogBase.h"
- #include "core/optimization/blackbox/Definitions_core_opt.h"
- namespace OPTIMIZATION {
-
- class Optimizer
- {
- public:
- typedef OPTIMIZATION::matrix_type matrix_type;
-
-
-
-
-
- Optimizer(OptLogBase *loger=NULL);
-
-
-
-
- Optimizer( const Optimizer &opt);
-
-
-
-
-
- Optimizer & operator=(const Optimizer &opt);
-
-
-
- virtual ~Optimizer();
-
-
-
-
- enum {
- SUCCESS_FUNCTOL,
- SUCCESS_PARAMTOL,
- SUCCESS_MAXITER,
- SUCCESS_TIMELIMIT,
- ERROR_XOUTOFBOUNDS,
- ERROR_COMPUTATION_UNSTABLE,
- _to_continue_
- };
-
-
-
-
-
-
-
-
-
-
-
-
- void setScales(const OPTIMIZATION::matrix_type & scales);
-
-
-
-
-
- inline const OPTIMIZATION::matrix_type & getScales(){return m_scales;};
-
-
-
-
-
-
- void setUpperParameterBound(bool active, const OPTIMIZATION::matrix_type & upperBound);
-
-
-
-
-
-
- void setLowerParameterBound(bool active, const OPTIMIZATION::matrix_type & lowerBound);
-
-
-
-
- inline const OPTIMIZATION::matrix_type & getUpperParameterBound(){ return m_upperParameterBound;};
-
-
-
-
- inline const OPTIMIZATION::matrix_type & getLowerParameterBound(){return m_lowerParameterBound;};
-
-
-
-
-
-
-
-
-
-
- void setFuncTol(bool active, double difference);
-
-
-
-
-
- inline double getFuncTol(){return m_funcTol;};
-
-
-
-
-
-
-
-
-
-
- void setParamTol(bool active, double difference);
-
-
-
-
-
- inline double getParamTol(){return m_paramTol;};
-
-
-
-
-
-
- void setMaxNumIter(bool active, unsigned int num);
-
-
-
-
- inline unsigned int getMaxNumIter(){return m_maxNumIter;};
-
-
-
-
- inline unsigned int getNumIter(){return m_numIter;};
-
-
-
-
-
- void setTimeLimit(bool active, double seconds);
-
-
-
-
- inline double getTimeLimit(){return m_maxSeconds;};
-
-
-
-
- inline int getReturnReason(){return m_returnReason;};
-
-
-
-
- void setMaximize(bool maximize);
-
-
-
-
-
- void setLoger(OptLogBase *loger);
-
-
-
- inline void setVerbose(bool verbose){m_verbose = verbose;};
-
- protected:
-
-
-
-
-
-
- virtual int optimize() = 0;
-
-
-
- void init();
-
-
-
-
-
-
- bool checkParameters(const OPTIMIZATION::matrix_type & parameters);
-
-
-
-
-
- inline OPTIMIZATION::matrix_type getLastParameters(){return m_parameters;}
-
-
-
- inline unsigned int getNumberOfParameters(){return m_numberOfParameters;}
-
-
-
-
-
- void setParameters(const OPTIMIZATION::matrix_type & startParameters);
-
-
-
-
-
-
- inline OptLogBase * getLoger(){return m_loger;};
-
-
-
- void changeCostFunction(CostFunction* costFunction);
-
-
-
-
-
-
-
-
- CostFunction* m_costFunction;
-
-
-
- unsigned int m_numberOfParameters;
-
-
-
-
- OPTIMIZATION::matrix_type m_parameters;
-
-
-
- double m_currentCostFunctionValue;
-
-
-
- OPTIMIZATION::matrix_type m_scales;
-
-
-
- double m_paramTol;
-
-
-
- bool m_paramTolActive;
-
-
-
- double m_funcTol;
-
-
-
- bool m_funcTolActive;
-
-
-
-
- unsigned int m_maxNumIter;
-
-
-
- bool m_maxNumIterActive;
-
-
-
- unsigned int m_numIter;
-
-
-
- double m_maxSeconds;
-
-
-
- bool m_maxSecondsActive;
-
-
-
- clock_t m_startTime;
-
-
-
- clock_t m_currentTime;
-
-
-
- int m_returnReason ;
-
-
-
-
- OPTIMIZATION::matrix_type m_upperParameterBound;
-
-
-
- bool m_upperParameterBoundActive;
-
-
-
-
- OPTIMIZATION::matrix_type m_lowerParameterBound;
-
-
-
- bool m_lowerParameterBoundActive;
-
-
-
- bool m_maximize;
-
-
-
- OptLogBase *m_loger;
-
-
-
-
- bool m_verbose;
-
-
-
- double evaluateCostFunction(const OPTIMIZATION::matrix_type & x);
-
-
-
- OPTIMIZATION::matrix_type evaluateSetCostFunction(const OPTIMIZATION::matrix_type & xSet);
- };
-
- }
- #endif
|