6template<
typename VariableType>
8 stateMonRes = std::vector<std::shared_ptr<MonotonicityResult<VariableType>>>(numberOfStates,
nullptr);
9 globalMonotonicityResult = std::make_shared<MonotonicityResult<VariableType>>();
11 dummyPointer = std::make_shared<MonotonicityResult<VariableType>>();
15template<
typename VariableType>
17 stateMonRes = std::vector<std::shared_ptr<MonotonicityResult<VariableType>>>(numberOfStates);
18 globalMonotonicityResult = globalResult;
20 dummyPointer = std::make_shared<MonotonicityResult<VariableType>>();
21 done = globalResult->isDone();
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);
36 return globalMonotonicityResult->isDoneForVar(var) ? globalMonotonicityResult->getMonotonicity(var) : Monotonicity::Unknown;
40template<
typename VariableType>
42 return globalMonotonicityResult;
45template<
typename VariableType>
48 assert(stateMonRes[state] != dummyPointer);
49 if (stateMonRes[state] ==
nullptr) {
50 stateMonRes[state] = std::make_shared<MonotonicityResult<VariableType>>();
52 stateMonRes[state]->addMonotonicityResult(var, mon);
53 globalMonotonicityResult->updateMonotonicityResult(var, mon);
54 if (mon == Monotonicity::Unknown || mon == Monotonicity::Not) {
55 statesMonotone.set(state,
false);
57 bool stateMonotone = stateMonRes[state]->isAllMonotonicity();
59 statesMonotone.set(state);
60 done |= statesMonotone.full();
63 globalMonotonicityResult->setDone();
68template<
typename VariableType>
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());
76 copy->setGlobalMonotonicityResult(this->getGlobalMonotonicityResult()->copy());
77 copy->setStatesMonotone(statesMonotone);
81template<
typename VariableType>
86template<
typename VariableType>
88 assert(indexMinimize == -1);
89 this->indexMinimize = i;
92template<
typename VariableType>
94 this->indexMaximize = i;
97template<
typename VariableType>
102template<
typename VariableType>
104 return indexMaximize;
107template<
typename VariableType>
109 return statesMonotone.empty();
112template<
typename VariableType>
114 this->stateMonRes[state] = monRes;
117template<
typename VariableType>
118void LocalMonotonicityResult<VariableType>::setGlobalMonotonicityResult(std::shared_ptr<MonotonicityResult<VariableType>> monRes) {
119 this->globalMonotonicityResult = monRes;
122template<
typename VariableType>
124 this->statesMonotone = statesMonotone;
127template<
typename VariableType>
129 if (stateMonRes[state] ==
nullptr) {
130 stateMonRes[state] = dummyPointer;
132 this->statesMonotone.
set(state);
135template<
typename VariableType>
137 globalMonotonicityResult->updateMonotonicityResult(var, Monotonicity::Incr);
138 globalMonotonicityResult->setDoneForVar(var);
139 setFixedParameters =
true;
142template<
typename VariableType>
144 globalMonotonicityResult->updateMonotonicityResult(var, Monotonicity::Decr);
145 globalMonotonicityResult->setDoneForVar(var);
146 setFixedParameters =
true;
149template<
typename VariableType>
151 std::string result =
"Local Monotonicity Result: \n";
152 for (uint_fast64_t i = 0; i < stateMonRes.size(); ++i) {
154 result += std::to_string(i);
155 if (stateMonRes[i] !=
nullptr) {
156 result += stateMonRes[i]->toString();
157 }
else if (statesMonotone[i]) {
158 result +=
"constant";
160 result +=
"not analyzed";
167template<
typename VariableType>
169 return setFixedParameters;
172template<
typename VariableType>
175 globalMonotonicityResult->setDone(done);
178template<
typename VariableType>
180 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.
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.
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.
void set(uint_fast64_t index, bool value=true)
Sets the given truth value at the given index.