9template<
typename VariableType>
11 stateMonRes = std::vector<std::shared_ptr<MonotonicityResult<VariableType>>>(numberOfStates,
nullptr);
12 globalMonotonicityResult = std::make_shared<MonotonicityResult<VariableType>>();
14 dummyPointer = std::make_shared<MonotonicityResult<VariableType>>();
18template<
typename VariableType>
20 stateMonRes = std::vector<std::shared_ptr<MonotonicityResult<VariableType>>>(numberOfStates);
21 globalMonotonicityResult = globalResult;
23 dummyPointer = std::make_shared<MonotonicityResult<VariableType>>();
24 done = globalResult->isDone();
27template<
typename VariableType>
29 VariableType var)
const {
30 if (stateMonRes[state] == dummyPointer) {
31 return Monotonicity::Constant;
32 }
else if (stateMonRes[state] !=
nullptr) {
33 auto res = stateMonRes[state]->getMonotonicity(var);
34 if (res == Monotonicity::Unknown && globalMonotonicityResult->isDoneForVar(var)) {
35 return globalMonotonicityResult->getMonotonicity(var);
39 return globalMonotonicityResult->isDoneForVar(var) ? globalMonotonicityResult->getMonotonicity(var) : Monotonicity::Unknown;
43template<
typename VariableType>
45 return globalMonotonicityResult;
48template<
typename VariableType>
51 STORM_LOG_ASSERT(stateMonRes[state] != dummyPointer,
"State monotonicity result is dummy pointer.");
52 if (stateMonRes[state] ==
nullptr) {
53 stateMonRes[state] = std::make_shared<MonotonicityResult<VariableType>>();
55 stateMonRes[state]->addMonotonicityResult(var, mon);
56 globalMonotonicityResult->updateMonotonicityResult(var, mon);
57 if (mon == Monotonicity::Unknown || mon == Monotonicity::Not) {
58 statesMonotone.set(state,
false);
60 bool stateMonotone = stateMonRes[state]->isAllMonotonicity();
62 statesMonotone.set(state);
63 done |= statesMonotone.full();
66 globalMonotonicityResult->setDone();
71template<
typename VariableType>
73 std::shared_ptr<LocalMonotonicityResult<VariableType>>
copy = std::make_shared<LocalMonotonicityResult<VariableType>>(stateMonRes.size());
74 for (uint_fast64_t state = 0; state < stateMonRes.size(); state++) {
75 if (stateMonRes[state] !=
nullptr) {
76 copy->setMonotonicityResult(state, stateMonRes[state]->
copy());
80 copy->setStatesMonotone(statesMonotone);
84template<
typename VariableType>
89template<
typename VariableType>
92 this->indexMinimize = i;
95template<
typename VariableType>
97 this->indexMaximize = i;
100template<
typename VariableType>
102 return indexMinimize;
105template<
typename VariableType>
107 return indexMaximize;
110template<
typename VariableType>
112 return statesMonotone.empty();
115template<
typename VariableType>
117 this->stateMonRes[state] = monRes;
120template<
typename VariableType>
121void LocalMonotonicityResult<VariableType>::setGlobalMonotonicityResult(std::shared_ptr<MonotonicityResult<VariableType>> monRes) {
122 this->globalMonotonicityResult = monRes;
125template<
typename VariableType>
127 this->statesMonotone = statesMonotone;
130template<
typename VariableType>
132 if (stateMonRes[state] ==
nullptr) {
133 stateMonRes[state] = dummyPointer;
135 this->statesMonotone.
set(state);
138template<
typename VariableType>
140 globalMonotonicityResult->updateMonotonicityResult(var, Monotonicity::Incr);
141 globalMonotonicityResult->setDoneForVar(var);
142 setFixedParameters =
true;
145template<
typename VariableType>
147 globalMonotonicityResult->updateMonotonicityResult(var, Monotonicity::Decr);
148 globalMonotonicityResult->setDoneForVar(var);
149 setFixedParameters =
true;
152template<
typename VariableType>
154 std::string result =
"Local Monotonicity Result: \n";
155 for (uint_fast64_t i = 0; i < stateMonRes.size(); ++i) {
157 result += std::to_string(i);
158 if (stateMonRes[i] !=
nullptr) {
159 result += stateMonRes[i]->toString();
160 }
else if (statesMonotone[i]) {
161 result +=
"constant";
163 result +=
"not analyzed";
170template<
typename VariableType>
172 return setFixedParameters;
175template<
typename VariableType>
178 globalMonotonicityResult->setDone(done);
181template<
typename VariableType>
183 return stateMonRes[state];
int getIndexMinimize() const
void setDone(bool done=true)
void setIndexMinimize(int index)
void setIndexMaximize(int index)
void setMonotonicity(uint_fast64_t state, VariableType var, Monotonicity mon)
Sets the local Monotonicity of a parameter at a given state.
bool isNoMonotonicity() const
void setMonotoneDecreasing(VariableType var)
void setMonotoneIncreasing(VariableType var)
void setConstant(uint_fast64_t state)
LocalMonotonicityResult(uint_fast64_t numberOfStates)
Constructs a new LocalMonotonicityResult object.
MonotonicityResult< VariableType >::Monotonicity Monotonicity
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.
int getIndexMaximize() const
std::shared_ptr< MonotonicityResult< VariableType > > getGlobalMonotonicityResult() const
Returns the Global MonotonicityResult object that corresponds to this object.
bool isFixedParametersSet() const
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.
A bit vector that is internally represented as a vector of 64-bit values.
void set(uint64_t index, bool value=true)
Sets the given truth value at the given index.
#define STORM_LOG_ASSERT(cond, message)