diff options
author | astrojhgu <astrojhgu@gmail.com> | 2012-12-28 03:43:48 +0800 |
---|---|---|
committer | astrojhgu <astrojhgu@gmail.com> | 2012-12-28 03:43:48 +0800 |
commit | 7ff0aab5e0dbda497014c6249c27f27a08351988 (patch) | |
tree | 247373e2faeaafe13bf8e5b2debfc0fe20bd5da6 | |
parent | 6ebca9ba6d897ca39d98f6fc104fc1e72470942b (diff) | |
download | opt-utilities-7ff0aab5e0dbda497014c6249c27f27a08351988.tar.bz2 |
Add the meet_constraint and do_meet_constraint member to class model.
deleted: core/constrained_model.hpp
modified: core/fitter.hpp
-rw-r--r-- | core/constrained_model.hpp | 22 | ||||
-rw-r--r-- | core/fitter.hpp | 22 |
2 files changed, 22 insertions, 22 deletions
diff --git a/core/constrained_model.hpp b/core/constrained_model.hpp deleted file mode 100644 index 378cabd..0000000 --- a/core/constrained_model.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CONSTRAINED_MODEL_HPP -#define CONSTRAINED_MODEL_HPP -#include "fitter.hpp" - -namespace opt_utilities -{ - template <typename Ty,typename Tx,typename Tp,typename Tstr=std::string> - class constrained_model - :public model<Ty,Tx,Tp,Tstr> - { - public: - bool meet_constraint(const Tp& p)const - { - return do_meet_constraint(p); - } - private: - virtual bool do_meet_constraint(const Tp& p)const=0; - }; - -} - -#endif diff --git a/core/fitter.hpp b/core/fitter.hpp index cc4da3b..7b5af4b 100644 --- a/core/fitter.hpp +++ b/core/fitter.hpp @@ -559,6 +559,19 @@ namespace opt_utilities return Tstr();
}
+ virtual bool do_meet_constraint(const Tp& p)const
+ {
+ Tp p1=this->reform_param(p);
+ for(size_t i=0;i!=p1.size();++i)
+ {
+ if(get_element(p,i)>get_param_info(i).get_upper_limit()||
+ get_element(p,i)<get_param_info(i).get_lower_limit())
+ {
+ return false;
+ }
+ }
+ return true;
+ }
/**
\return the type name of self
@@ -825,6 +838,15 @@ namespace opt_utilities return do_get_information();
}
+ /**
+ \param p input deformed parameter
+ \return if the given param meets the constraint of the model
+ */
+ bool meet_constraint(const Tp& p)const
+ {
+ return do_meet_constraint(p);
+ }
+
public:
/**
set the param modifier
|