12template<
typename VariableType>
15 this->somewhereMonotonicity =
true;
16 this->allMonotonicity =
true;
19template<
typename VariableType>
24template<
typename VariableType>
29 if (monotonicityResult.find(var) == monotonicityResult.end()) {
32 monotonicityResult[var] = mon;
39 bool unknownMon =
false;
40 if (monotonicityResult.find(var) == monotonicityResult.end()) {
44 auto monRes = monotonicityResult[var];
49 monotonicityResult[var] = mon;
65template<
typename VariableType>
67 auto itr = monotonicityResult.find(var);
68 if (itr != monotonicityResult.end()) {
71 return Monotonicity::Unknown;
74template<
typename VariableType>
76 return monotonicityResult;
79template<
typename VariableType>
81 std::set<VariableType>
const& consideredVariables)
const {
82 std::set<VariableType> nonMonotoneVariables;
83 std::set<VariableType> monotoneVariables;
84 for (
auto var : consideredVariables) {
87 if (res == Monotonicity::Not || res == Monotonicity::Unknown) {
88 nonMonotoneVariables.insert(var);
90 monotoneVariables.insert(var);
93 nonMonotoneVariables.insert(var);
96 return std::make_pair(std::move(monotoneVariables), std::move(nonMonotoneVariables));
99template<
typename VariableType>
101 std::stringstream stream;
105 stream << res.first.name() <<
" " << res.second <<
"; ";
106 countIncr += (res.second == Monotonicity::Incr) ? 1 : 0;
107 countDecr += (res.second == Monotonicity::Decr) ? 1 : 0;
109 return "#Incr: " + std::to_string(countIncr) +
" #Decr: " + std::to_string(countDecr) +
"\n" + stream.str();
112template<
typename VariableType>
117template<
typename VariableType>
119 doneVariables.insert(variable);
122template<
typename VariableType>
127template<
typename VariableType>
129 return doneVariables.find(var) != doneVariables.end();
132template<
typename VariableType>
134 this->somewhereMonotonicity = somewhereMonotonicity;
137template<
typename VariableType>
139 if (!somewhereMonotonicity) {
140 for (
auto itr : monotonicityResult) {
148 return monotonicityResult.size() > 0 && somewhereMonotonicity;
151template<
typename VariableType>
153 this->allMonotonicity = allMonotonicity;
156template<
typename VariableType>
158 return allMonotonicity;
161template<
typename VariableType>
163 std::shared_ptr<MonotonicityResult<VariableType>>
copy = std::make_shared<MonotonicityResult<VariableType>>();
164 copy->monotonicityResult = std::map<VariableType, Monotonicity>(monotonicityResult);
165 copy->setAllMonotonicity(allMonotonicity);
166 copy->setSomewhereMonotonicity(somewhereMonotonicity);
168 copy->setDoneVariables(doneVariables);
172template<
typename VariableType>
174 this->doneVariables = doneVariables;
177template<
typename VariableType>
179 std::set<VariableType>& monotoneDecr, std::set<VariableType>& notMonotone)
const {
180 for (
auto& var : consideredVariables) {
182 notMonotone.insert(var);
185 if (mon == Monotonicity::Unknown || mon == Monotonicity::Not) {
186 notMonotone.insert(var);
187 }
else if (mon == Monotonicity::Incr) {
188 monotoneIncr.insert(var);
190 monotoneDecr.insert(var);
196template<
typename VariableType>
198 if (monotonicityResult.find(var) == monotonicityResult.end()) {
201 auto monRes = monotonicityResult.at(var);
202 return isDoneForVar(var) && (monRes == Monotonicity::Incr || monRes == Monotonicity::Decr || monRes == Monotonicity::Constant);
std::map< VariableType, Monotonicity > const & getMonotonicityResult() const
Returns the results so far.
void splitBasedOnMonotonicity(std::set< VariableType > const &consideredVariables, std::set< VariableType > &monotoneIncr, std::set< VariableType > &monotoneDecr, std::set< VariableType > ¬Montone) const
void setDone(bool done=true)
Sets the done bool to the given truth value.
MonotonicityResult()
Constructs a new MonotonicityResult object.
void addMonotonicityResult(VariableType var, Monotonicity mon)
Adds a new variable with a given Monotonicity to the map.
void setAllMonotonicity(bool done=true)
Sets the allMonotonicity bool to the given truth value.
Monotonicity getMonotonicity(VariableType var) const
Returns the current monotonicity of a given parameter.
void setSomewhereMonotonicity(bool done=true)
Sets the somewhereMonotonicity bool to the given truth value.
void updateMonotonicityResult(VariableType var, Monotonicity mon, bool force=false)
Updates the Monotonicity of a variable based on its value so far and a new value.
std::pair< std::set< VariableType >, std::set< VariableType > > splitVariables(std::set< VariableType > const &consideredVariables) const
bool isAllMonotonicity() const
Returns if all Variables are monotone.
std::string toString() const
Constructs a string output of all variables and their corresponding Monotonicity.
storm::analysis::MonotonicityKind Monotonicity
std::shared_ptr< MonotonicityResult< VariableType > > copy() const
Constructs a new MonotonicityResult object that is a copy of the current one.
void setDoneVariables(std::set< VariableType > doneVariables)
bool existsMonotonicity()
Checks if there is any variable that is monotone.
bool isDoneForVar(VariableType) const
bool isMonotone(VariableType var) const
bool isDone() const
Checks if the result is complete.
void setDoneForVar(VariableType)
#define STORM_LOG_ASSERT(cond, message)