Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
LocalMonotonicityResult.cpp
Go to the documentation of this file.
2
3namespace storm {
4namespace analysis {
5
6template<typename VariableType>
8 stateMonRes = std::vector<std::shared_ptr<MonotonicityResult<VariableType>>>(numberOfStates, nullptr);
9 globalMonotonicityResult = std::make_shared<MonotonicityResult<VariableType>>();
10 statesMonotone = storm::storage::BitVector(numberOfStates, false);
11 dummyPointer = std::make_shared<MonotonicityResult<VariableType>>();
12 done = false;
13}
14
15template<typename VariableType>
17 stateMonRes = std::vector<std::shared_ptr<MonotonicityResult<VariableType>>>(numberOfStates);
18 globalMonotonicityResult = globalResult;
19 statesMonotone = storm::storage::BitVector(numberOfStates, false);
20 dummyPointer = std::make_shared<MonotonicityResult<VariableType>>();
21 done = globalResult->isDone();
22}
23
24template<typename VariableType>
26 VariableType var) const {
27 if (stateMonRes[state] == dummyPointer) {
28 return Monotonicity::Constant;
29 } else if (stateMonRes[state] != nullptr) {
30 auto res = stateMonRes[state]->getMonotonicity(var);
31 if (res == Monotonicity::Unknown && globalMonotonicityResult->isDoneForVar(var)) {
32 return globalMonotonicityResult->getMonotonicity(var);
33 }
34 return res;
35 } else {
36 return globalMonotonicityResult->isDoneForVar(var) ? globalMonotonicityResult->getMonotonicity(var) : Monotonicity::Unknown;
37 }
38}
39
40template<typename VariableType>
41std::shared_ptr<MonotonicityResult<VariableType>> LocalMonotonicityResult<VariableType>::getGlobalMonotonicityResult() const {
42 return globalMonotonicityResult;
43}
44
45template<typename VariableType>
46void LocalMonotonicityResult<VariableType>::setMonotonicity(uint_fast64_t state, VariableType var,
48 assert(stateMonRes[state] != dummyPointer);
49 if (stateMonRes[state] == nullptr) {
50 stateMonRes[state] = std::make_shared<MonotonicityResult<VariableType>>();
51 }
52 stateMonRes[state]->addMonotonicityResult(var, mon);
53 globalMonotonicityResult->updateMonotonicityResult(var, mon);
54 if (mon == Monotonicity::Unknown || mon == Monotonicity::Not) {
55 statesMonotone.set(state, false);
56 } else {
57 bool stateMonotone = stateMonRes[state]->isAllMonotonicity();
58 if (stateMonotone) {
59 statesMonotone.set(state);
60 done |= statesMonotone.full();
61 }
62 if (isDone()) {
63 globalMonotonicityResult->setDone();
64 }
65 }
66}
67
68template<typename VariableType>
69std::shared_ptr<LocalMonotonicityResult<VariableType>> LocalMonotonicityResult<VariableType>::copy() {
70 std::shared_ptr<LocalMonotonicityResult<VariableType>> copy = std::make_shared<LocalMonotonicityResult<VariableType>>(stateMonRes.size());
71 for (uint_fast64_t state = 0; state < stateMonRes.size(); state++) {
72 if (stateMonRes[state] != nullptr) {
73 copy->setMonotonicityResult(state, stateMonRes[state]->copy());
74 }
75 }
76 copy->setGlobalMonotonicityResult(this->getGlobalMonotonicityResult()->copy());
77 copy->setStatesMonotone(statesMonotone);
78 return copy;
79}
80
81template<typename VariableType>
83 return done;
84}
85
86template<typename VariableType>
88 assert(indexMinimize == -1);
89 this->indexMinimize = i;
90}
91
92template<typename VariableType>
94 this->indexMaximize = i;
95}
96
97template<typename VariableType>
99 return indexMinimize;
100}
101
102template<typename VariableType>
104 return indexMaximize;
105}
106
107template<typename VariableType>
109 return statesMonotone.empty();
110}
111
112template<typename VariableType>
114 this->stateMonRes[state] = monRes;
115}
116
117template<typename VariableType>
118void LocalMonotonicityResult<VariableType>::setGlobalMonotonicityResult(std::shared_ptr<MonotonicityResult<VariableType>> monRes) {
119 this->globalMonotonicityResult = monRes;
120}
121
122template<typename VariableType>
123void LocalMonotonicityResult<VariableType>::setStatesMonotone(storm::storage::BitVector statesMonotone) {
124 this->statesMonotone = statesMonotone;
125}
126
127template<typename VariableType>
129 if (stateMonRes[state] == nullptr) {
130 stateMonRes[state] = dummyPointer;
131 }
132 this->statesMonotone.set(state);
133}
134
135template<typename VariableType>
137 globalMonotonicityResult->updateMonotonicityResult(var, Monotonicity::Incr);
138 globalMonotonicityResult->setDoneForVar(var);
139 setFixedParameters = true;
140}
141
142template<typename VariableType>
144 globalMonotonicityResult->updateMonotonicityResult(var, Monotonicity::Decr);
145 globalMonotonicityResult->setDoneForVar(var);
146 setFixedParameters = true;
147}
148
149template<typename VariableType>
151 std::string result = "Local Monotonicity Result: \n";
152 for (uint_fast64_t i = 0; i < stateMonRes.size(); ++i) {
153 result += "state ";
154 result += std::to_string(i);
155 if (stateMonRes[i] != nullptr) {
156 result += stateMonRes[i]->toString();
157 } else if (statesMonotone[i]) {
158 result += "constant";
159 } else {
160 result += "not analyzed";
161 }
162 result += "\n";
163 }
164 return result;
165}
166
167template<typename VariableType>
169 return setFixedParameters;
170}
171
172template<typename VariableType>
174 this->done = done;
175 globalMonotonicityResult->setDone(done);
176}
177
178template<typename VariableType>
179std::shared_ptr<MonotonicityResult<VariableType>> LocalMonotonicityResult<VariableType>::getMonotonicity(uint_fast64_t state) const {
180 return stateMonRes[state];
181}
182
184} // namespace analysis
185} // namespace storm
void setMonotonicity(uint_fast64_t state, VariableType var, Monotonicity mon)
Sets the local Monotonicity of a parameter at a given state.
LocalMonotonicityResult(uint_fast64_t numberOfStates)
Constructs a new LocalMonotonicityResult object.
std::shared_ptr< LocalMonotonicityResult< VariableType > > copy()
Constructs a new LocalMonotonicityResult object that is a copy of the current one.
bool isDone() const
Checks if the LocalMonotonicity is done yet.
std::shared_ptr< MonotonicityResult< VariableType > > getGlobalMonotonicityResult() const
Returns the Global MonotonicityResult object that corresponds to this object.
std::string toString() const
Constructs a string output of all variables and their corresponding Monotonicity.
Monotonicity getMonotonicity(uint_fast64_t state, VariableType var) const
Returns the local Monotonicity of a parameter at a given state.
Monotonicity
The results of monotonicity checking for a single Parameter Region.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
void set(uint_fast64_t index, bool value=true)
Sets the given truth value at the given index.
LabParser.cpp.
Definition cli.cpp:18