14template<
typename ParametricType,
typename ConstantType>
17 auto [orderPtr, unknState1, unknState2] = orderExtender.
extendOrder(order, region);
19 if (unknState1 != order->getNumberOfStates()) {
25template<
typename ParametricType,
typename ConstantType>
31 auto state = order->getNextDoneState(-1);
33 while (state != order->getNumberOfStates()) {
34 if (localMonotonicityResult.getMonotonicity(state) ==
nullptr) {
35 auto variables = variablesAtState[state];
36 if (variables.size() == 0 || order->isBottomState(state) || order->isTopState(state)) {
37 localMonotonicityResult.setConstant(state);
39 for (
auto const& var : variables) {
40 auto monotonicity = localMonotonicityResult.getMonotonicity(state, var);
44 localMonotonicityResult.setMonotonicity(state, var, monotonicity);
52 state = order->getNextDoneState(state);
56 for (
auto const& entry : statesAtVariable) {
57 auto states = entry.second;
58 auto var = entry.first;
60 for (
auto const& state : states) {
69 localMonotonicityResult.getGlobalMonotonicityResult()->setDoneForVar(var);
73 localMonotonicityResult.setDone();
74 while (order->existsNextState()) {
76 order->add(order->getNextStateNumber().second);
78 assert(order->getDoneBuilding());
83template<
typename ParametricType,
typename ConstantType>
85 : useOnlyGlobal(useOnlyGlobal), useBounds(useBounds) {
89template<
typename ParametricType,
typename ConstantType>
94template<
typename ParametricType,
typename ConstantType>
99template<
typename ParametricType,
typename ConstantType>
104 orderExtender->setMaxValuesInit(plaBoundFunction(env, region, storm::solver::OptimizationDirection::Maximize));
105 orderExtender->setMaxValuesInit(plaBoundFunction(env, region, storm::solver::OptimizationDirection::Minimize));
111 for (
auto& [var, kind] : this->globallyKnownMonotonicityInformation) {
112 if (kind == MonotonicityKind::Incr || kind == MonotonicityKind::Constant)
114 else if (kind == MonotonicityKind::Decr)
119 *this->parameterLifterRef);
123template<
typename ParametricType,
typename ConstantType>
126 STORM_LOG_ASSERT(annotation.has_value(),
"Order-based monotonicity annotation must be present.");
129 bool const changeOrder = !annotation->stateOrder->getDoneBuilding() && orderExtender->isHope(annotation->stateOrder);
130 if (changeOrder && annotation->stateOrder.use_count() > 1) {
133 auto newOrder = annotation->stateOrder->copy();
134 orderExtender->setUnknownStates(annotation->stateOrder, newOrder);
135 orderExtender->copyMinMax(annotation->stateOrder, newOrder);
136 annotation->stateOrder = newOrder;
142 bool const changeLocalMonotonicity = changeOrder && !annotation->localMonotonicityResult->isDone();
143 if (changeLocalMonotonicity && annotation->localMonotonicityResult.use_count() > 1) {
145 annotation->localMonotonicityResult = annotation->localMonotonicityResult->copy();
147 if (changeLocalMonotonicity) {
149 *this->parameterLifterRef);
153template<
typename ParametricType,
typename ConstantType>
157 STORM_LOG_ASSERT(annotation.has_value(),
"Order-based monotonicity annotation must be present.");
158 if (useBounds && !annotation->stateOrder->getDoneBuilding()) {
161 orderExtender->setMinMaxValues(annotation->stateOrder, plaBoundFunction(env, region, storm::solver::OptimizationDirection::Minimize),
162 plaBoundFunction(env, region, storm::solver::OptimizationDirection::Maximize));
166template<
typename ParametricType,
typename ConstantType>
167std::map<typename OrderBasedMonotonicityBackend<ParametricType, ConstantType>::VariableType,
176template<
typename ParametricType,
typename ConstantType>
182template<
typename ParametricType,
typename ConstantType>
183void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::initializeOrderExtender(
189template<
typename ParametricType,
typename ConstantType>
190void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::registerParameterLifterReference(
192 this->parameterLifterRef.reset(parameterLifter);
195template<
typename ParametricType,
typename ConstantType>
196void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::registerPLABoundFunction(
198 this->plaBoundFunction = fun;
201template<
typename ParametricType,
typename ConstantType>
207 STORM_LOG_ASSERT(parameterLifterRef.has_value(),
"Parameter lifter reference not initialized.");
209 auto monotonicityAnnotation = region.monotonicityAnnotation.getOrderBasedMonotonicityAnnotation();
210 STORM_LOG_ASSERT(monotonicityAnnotation.has_value() && monotonicityAnnotation->localMonotonicityResult !=
nullptr,
211 "Order-based monotonicity annotation must be present.");
212 auto const& localMonotonicityResult = *monotonicityAnnotation->localMonotonicityResult;
216 auto const& occurringVariables = parameterLifterRef->getOccurringVariablesAtState();
217 for (uint64_t state = 0; state < parameterLifterRef->getRowGroupCount(); ++state) {
218 auto oldStateNumber = parameterLifterRef->getOriginalStateNumber(state);
219 auto const& variables = occurringVariables.at(oldStateNumber);
222 STORM_LOG_THROW(variables.size() <= 1, storm::exceptions::NotImplementedException,
223 "Using localMonRes not yet implemented for states with 2 or more variables, please run without --use-monotonicity");
225 bool allMonotone =
true;
226 for (
auto var : variables) {
227 auto const monotonicity = localMonotonicityResult.getMonotonicity(oldStateNumber, var);
229 bool const fixToLowerBound =
230 monotonicity == MonotonicityKind::Constant || monotonicity == (
storm::solver::minimize(dir) ? MonotonicityKind::Incr : MonotonicityKind::Decr);
231 bool const fixToUpperBound =
232 monotonicity == MonotonicityKind::Constant || monotonicity == (
storm::solver::maximize(dir) ? MonotonicityKind::Incr : MonotonicityKind::Decr);
233 if (fixToLowerBound || fixToUpperBound) {
235 schedulerChoices[state] = fixToLowerBound ? 0 : 1;
247template class OrderBasedMonotonicityBackend<storm::RationalFunction, double>;
248template class OrderBasedMonotonicityBackend<storm::RationalFunction, storm::RationalNumber>;
Monotonicity checkLocalMonotonicity(std::shared_ptr< Order > const &order, uint_fast64_t state, VariableType const &var, storage::ParameterRegion< ValueType > const ®ion)
Checks for local monotonicity at the given state.
std::tuple< std::shared_ptr< Order >, uint_fast64_t, uint_fast64_t > extendOrder(std::shared_ptr< Order > order, storm::storage::ParameterRegion< ValueType > region, std::shared_ptr< MonotonicityResult< VariableType > > monRes=nullptr, std::shared_ptr< expressions::BinaryRelationExpression > assumption=nullptr)
Extends the order for the given region.
void setUnknownStates(std::shared_ptr< Order > order, uint_fast64_t state1, uint_fast64_t state2)
virtual std::map< VariableType, MonotonicityKind > getOptimisticMonotonicityApproximation(AnnotatedRegion< ParametricType > const ®ion)
Returns an optimistic approximation of the monotonicity of the parameters in this region.
OrderBasedMonotonicityBackend(bool useOnlyGlobal=false, bool useBounds=false)
virtual void initializeMonotonicity(storm::Environment const &env, AnnotatedRegion< ParametricType > ®ion) override
Initializes the monotonicity information for the given region.
virtual bool recommendModelSimplifications() const override
Returns whether additional model simplifications are recommended when using this backend.
virtual bool requiresInteractionWithRegionModelChecker() const override
Returns true, since a region model checker needs to implement specific methods to properly use this b...
typename MonotonicityBackend< ParametricType >::MonotonicityKind MonotonicityKind
virtual std::map< VariableType, MonotonicityKind > getOptimisticMonotonicityApproximation(AnnotatedRegion< ParametricType > const ®ion) override
Returns an optimistic approximation of the monotonicity of the parameters in this region.
virtual void updateMonotonicity(storm::Environment const &env, AnnotatedRegion< ParametricType > ®ion) override
Updates the monotonicity information for the given region.
virtual void updateMonotonicityBeforeSplitting(storm::Environment const &env, AnnotatedRegion< ParametricType > ®ion) override
Updates the monotonicity information for the given region right before splitting it.
A bit vector that is internally represented as a vector of 64-bit values.
storm::utility::parametric::VariableType< ParametricType >::type VariableType
A class that holds a possibly non-square matrix in the compressed row storage format.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
@ Unknown
the monotonicity result is unknown
bool isMonotone(MonotonicityKind kind)
void extendLocalMonotonicityResult(storm::storage::ParameterRegion< ParametricType > const ®ion, std::shared_ptr< storm::analysis::Order > const &order, storm::analysis::LocalMonotonicityResult< typename storm::storage::ParameterRegion< ParametricType >::VariableType > &localMonotonicityResult, storm::analysis::MonotonicityChecker< ParametricType > &monotonicityChecker, storm::transformer::ParameterLifter< ParametricType, ConstantType > const ¶meterLifter)
std::shared_ptr< storm::analysis::Order > extendOrder(storm::analysis::OrderExtender< ParametricType, ConstantType > &orderExtender, std::shared_ptr< storm::analysis::Order > order, storm::storage::ParameterRegion< ParametricType > region)
bool constexpr maximize(OptimizationDirection d)
bool constexpr minimize(OptimizationDirection d)
storm::modelchecker::MonotonicityAnnotation< ParametricType > monotonicityAnnotation
Whether the result is known through monotonicity.
Region const region
The subregions of this region.
std::shared_ptr< storm::analysis::Order > stateOrder
std::shared_ptr< storm::analysis::LocalMonotonicityResult< VariableType > > localMonotonicityResult