diff options
-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
|