diff --git a/include/barry/models/defm/counters.hpp b/include/barry/models/defm/counters.hpp index 4d0774557..a4f34456c 100644 --- a/include/barry/models/defm/counters.hpp +++ b/include/barry/models/defm/counters.hpp @@ -795,6 +795,56 @@ inline void rules_dont_become_zero( return; } +/** + * @brief Overall functional gains + * @param support Support of a model. + * @param pos Position of the focal statistic. + * @param lb Lower bound + * @param ub Upper bound + * @details + * @return (void) adds a rule limiting the support of the model. + */ +inline void rule_constrain_support( + DEFMSupport * support, + size_t pos, + double lb, + double ub +) +{ + + DEFM_RULEDYN_LAMBDA(tmp_rule) + { + + if (data() < data.lb) + return false; + else if (data() > data.ub) + return false; + else + return true; + + }; + + + support->get_rules_dyn()->add_rule( + tmp_rule, + DEFMRuleDynData( + support->get_current_stats(), + pos, lb, ub + ), + support->get_counters()->get_names()[pos] + + "' within [" + std::to_string(lb) + ", " + + std::to_string(ub) + std::string("]"), + std::string("When the support is ennumerated, only states where the statistic '") + + support->get_counters()->get_names()[pos] + + std::to_string(pos) + "' falls within [" + std::to_string(lb) + ", " + + std::to_string(ub) + "] are included." + ); + + return; + +} + + ///@} ///@} diff --git a/include/barry/models/defm/defm-types.hpp b/include/barry/models/defm/defm-types.hpp index 797251e25..9139d801b 100644 --- a/include/barry/models/defm/defm-types.hpp +++ b/include/barry/models/defm/defm-types.hpp @@ -149,18 +149,26 @@ inline void DEFMData::print() const { */ ///@{ -class DEFMRuleDynData : public DEFMRuleData { +class DEFMRuleDynData { public: const std::vector< double > * counts; + size_t pos; + size_t lb; + size_t ub; DEFMRuleDynData( const std::vector< double > * counts_, - std::vector< double > numbers_ = {}, - std::vector< size_t > indices_ = {}, - std::vector< bool > logical_ = {} - ) : DEFMRuleData(numbers_, indices_, logical_), counts(counts_) {}; + size_t pos_, + size_t lb_, + size_t ub_ + ) : counts(counts_), pos(pos_), lb(lb_), ub(ub_) {}; ~DEFMRuleDynData() {}; + + const double operator()() const + { + return (*counts)[pos]; + } };