11template<
typename VariableType>
14 this->somewhereMonotonicity =
true;
15 this->allMonotonicity =
true;
18template<
typename VariableType>
23template<
typename VariableType>
25 assert(!isDoneForVar(var));
28 if (monotonicityResult.find(var) == monotonicityResult.end()) {
29 addMonotonicityResult(std::move(var), std::move(mon));
31 monotonicityResult[var] = mon;
38 if (monotonicityResult.find(var) == monotonicityResult.end()) {
39 addMonotonicityResult(std::move(var), std::move(mon));
41 auto monRes = monotonicityResult[var];
46 monotonicityResult[var] = mon;
52 setAllMonotonicity(
false);
53 setSomewhereMonotonicity(
false);
55 setSomewhereMonotonicity(
true);
60template<
typename VariableType>
62 auto itr = monotonicityResult.find(var);
63 if (itr != monotonicityResult.end()) {
66 return Monotonicity::Unknown;
69template<
typename VariableType>
71 return monotonicityResult;
74template<
typename VariableType>
76 std::set<VariableType>
const& consideredVariables)
const {
77 std::set<VariableType> nonMonotoneVariables;
78 std::set<VariableType> monotoneVariables;
79 for (
auto var : consideredVariables) {
80 if (isDoneForVar(var)) {
81 auto res = getMonotonicity(var);
82 if (res == Monotonicity::Not || res == Monotonicity::Unknown) {
83 nonMonotoneVariables.insert(var);
85 monotoneVariables.insert(var);
88 nonMonotoneVariables.insert(var);
91 return std::make_pair(std::move(monotoneVariables), std::move(nonMonotoneVariables));
94template<
typename VariableType>
99 for (
auto res : getMonotonicityResult()) {
100 result += res.first.name();
101 switch (res.second) {
104 result +=
" MonIncr; ";
108 result +=
" MonDecr; ";
111 result +=
" Constant; ";
114 result +=
" NotMon; ";
117 result +=
" Unknown; ";
121 "Could not get a string from the region monotonicity check result. The case has not been implemented");
124 result =
"#Incr: " + std::to_string(countIncr) +
" #Decr: " + std::to_string(countDecr) +
"\n" + result;
128template<
typename VariableType>
133template<
typename VariableType>
135 doneVariables.insert(variable);
138template<
typename VariableType>
143template<
typename VariableType>
145 return doneVariables.find(var) != doneVariables.end();
148template<
typename VariableType>
150 this->somewhereMonotonicity = somewhereMonotonicity;
153template<
typename VariableType>
155 if (!somewhereMonotonicity) {
156 for (
auto itr : monotonicityResult) {
159 setSomewhereMonotonicity(
true);
164 return monotonicityResult.size() > 0 && somewhereMonotonicity;
167template<
typename VariableType>
169 this->allMonotonicity = allMonotonicity;
172template<
typename VariableType>
174 return allMonotonicity;
177template<
typename VariableType>
179 std::shared_ptr<MonotonicityResult<VariableType>> copy = std::make_shared<MonotonicityResult<VariableType>>();
180 copy->monotonicityResult = std::map<VariableType, Monotonicity>(monotonicityResult);
181 copy->setAllMonotonicity(allMonotonicity);
182 copy->setSomewhereMonotonicity(somewhereMonotonicity);
184 copy->setDoneVariables(doneVariables);
188template<
typename VariableType>
190 this->doneVariables = doneVariables;
193template<
typename VariableType>
195 std::set<VariableType>& monotoneDecr, std::set<VariableType>& notMonotone)
const {
196 for (
auto& var : consideredVariables) {
197 if (!isDoneForVar(var)) {
198 notMonotone.insert(var);
200 auto mon = getMonotonicity(var);
201 if (mon == Monotonicity::Unknown || mon == Monotonicity::Not) {
202 notMonotone.insert(var);
203 }
else if (mon == Monotonicity::Incr) {
204 monotoneIncr.insert(var);
206 monotoneDecr.insert(var);
212template<
typename VariableType>
214 if (monotonicityResult.find(var) == monotonicityResult.end()) {
217 auto monRes = monotonicityResult.at(var);
218 return isDoneForVar(var) && (monRes == Monotonicity::Incr || monRes == Monotonicity::Decr || monRes == Monotonicity::Constant);
std::map< VariableType, Monotonicity > 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
Monotonicity
The results of monotonicity checking for a single Parameter Region.
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.
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_THROW(cond, exception, message)