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 if (monotonicityResult.find(var) == monotonicityResult.end()) {
42 auto monRes = monotonicityResult[var];
47 monotonicityResult[var] = mon;
61template<
typename VariableType>
63 auto itr = monotonicityResult.find(var);
64 if (itr != monotonicityResult.end()) {
67 return Monotonicity::Unknown;
70template<
typename VariableType>
72 return monotonicityResult;
75template<
typename VariableType>
77 std::set<VariableType>
const& consideredVariables)
const {
78 std::set<VariableType> nonMonotoneVariables;
79 std::set<VariableType> monotoneVariables;
80 for (
auto var : consideredVariables) {
83 if (res == Monotonicity::Not || res == Monotonicity::Unknown) {
84 nonMonotoneVariables.insert(var);
86 monotoneVariables.insert(var);
89 nonMonotoneVariables.insert(var);
92 return std::make_pair(std::move(monotoneVariables), std::move(nonMonotoneVariables));
95template<
typename VariableType>
97 std::stringstream stream;
101 stream << res.first.name() <<
" " << res.second <<
"; ";
102 countIncr += (res.second == Monotonicity::Incr) ? 1 : 0;
103 countDecr += (res.second == Monotonicity::Decr) ? 1 : 0;
105 return "#Incr: " + std::to_string(countIncr) +
" #Decr: " + std::to_string(countDecr) +
"\n" + stream.str();
108template<
typename VariableType>
113template<
typename VariableType>
115 doneVariables.insert(variable);
118template<
typename VariableType>
123template<
typename VariableType>
125 return doneVariables.find(var) != doneVariables.end();
128template<
typename VariableType>
130 this->somewhereMonotonicity = somewhereMonotonicity;
133template<
typename VariableType>
135 if (!somewhereMonotonicity) {
136 for (
auto itr : monotonicityResult) {
144 return monotonicityResult.size() > 0 && somewhereMonotonicity;
147template<
typename VariableType>
149 this->allMonotonicity = allMonotonicity;
152template<
typename VariableType>
154 return allMonotonicity;
157template<
typename VariableType>
159 std::shared_ptr<MonotonicityResult<VariableType>>
copy = std::make_shared<MonotonicityResult<VariableType>>();
160 copy->monotonicityResult = std::map<VariableType, Monotonicity>(monotonicityResult);
161 copy->setAllMonotonicity(allMonotonicity);
162 copy->setSomewhereMonotonicity(somewhereMonotonicity);
164 copy->setDoneVariables(doneVariables);
168template<
typename VariableType>
170 this->doneVariables = doneVariables;
173template<
typename VariableType>
175 std::set<VariableType>& monotoneDecr, std::set<VariableType>& notMonotone)
const {
176 for (
auto& var : consideredVariables) {
178 notMonotone.insert(var);
181 if (mon == Monotonicity::Unknown || mon == Monotonicity::Not) {
182 notMonotone.insert(var);
183 }
else if (mon == Monotonicity::Incr) {
184 monotoneIncr.insert(var);
186 monotoneDecr.insert(var);
192template<
typename VariableType>
194 if (monotonicityResult.find(var) == monotonicityResult.end()) {
197 auto monRes = monotonicityResult.at(var);
198 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)