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 STORM_LOG_ASSERT(order->getDoneBuilding(),
"Order should be done building.");
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));
112 if (kind == MonotonicityKind::Incr || kind == MonotonicityKind::Constant) {
114 }
else if (kind == MonotonicityKind::Decr) {
120 *this->parameterLifterRef);
121 region.monotonicityAnnotation.data = annotation;
124template<
typename ParametricType,
typename ConstantType>
126 auto annotation =
region.monotonicityAnnotation.getOrderBasedMonotonicityAnnotation();
127 STORM_LOG_ASSERT(annotation.has_value(),
"Order-based monotonicity annotation must be present.");
130 bool const changeOrder = !annotation->stateOrder->getDoneBuilding() && orderExtender->isHope(annotation->stateOrder);
131 if (changeOrder && annotation->stateOrder.use_count() > 1) {
134 auto newOrder = annotation->stateOrder->copy();
135 orderExtender->setUnknownStates(annotation->stateOrder, newOrder);
136 orderExtender->copyMinMax(annotation->stateOrder, newOrder);
137 annotation->stateOrder = newOrder;
143 bool const changeLocalMonotonicity = changeOrder && !annotation->localMonotonicityResult->isDone();
144 if (changeLocalMonotonicity && annotation->localMonotonicityResult.use_count() > 1) {
146 annotation->localMonotonicityResult = annotation->localMonotonicityResult->copy();
148 if (changeLocalMonotonicity) {
150 *this->parameterLifterRef);
154template<
typename ParametricType,
typename ConstantType>
157 auto annotation =
region.monotonicityAnnotation.getOrderBasedMonotonicityAnnotation();
158 STORM_LOG_ASSERT(annotation.has_value(),
"Order-based monotonicity annotation must be present.");
159 if (useBounds && !annotation->stateOrder->getDoneBuilding()) {
162 orderExtender->setMinMaxValues(annotation->stateOrder, plaBoundFunction(env,
region, storm::solver::OptimizationDirection::Minimize),
163 plaBoundFunction(env,
region, storm::solver::OptimizationDirection::Maximize));
167template<
typename ParametricType,
typename ConstantType>
168std::map<typename OrderBasedMonotonicityBackend<ParametricType, ConstantType>::VariableType,
177template<
typename ParametricType,
typename ConstantType>
178void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::initializeMonotonicityChecker(
183template<
typename ParametricType,
typename ConstantType>
184void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::initializeOrderExtender(
190template<
typename ParametricType,
typename ConstantType>
191void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::registerParameterLifterReference(
193 this->parameterLifterRef.reset(parameterLifter);
196template<
typename ParametricType,
typename ConstantType>
197void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::registerPLABoundFunction(
199 this->plaBoundFunction = fun;
202template<
typename ParametricType,
typename ConstantType>
203storm::storage::BitVector OrderBasedMonotonicityBackend<ParametricType, ConstantType>::getChoicesToFixForPLASolver(
208 STORM_LOG_ASSERT(parameterLifterRef.has_value(),
"Parameter lifter reference not initialized.");
210 auto monotonicityAnnotation =
region.monotonicityAnnotation.getOrderBasedMonotonicityAnnotation();
211 STORM_LOG_ASSERT(monotonicityAnnotation.has_value() && monotonicityAnnotation->localMonotonicityResult !=
nullptr,
212 "Order-based monotonicity annotation must be present.");
213 auto const& localMonotonicityResult = *monotonicityAnnotation->localMonotonicityResult;
215 storm::storage::BitVector result(schedulerChoices.size(),
false);
217 auto const& occurringVariables = parameterLifterRef->getOccurringVariablesAtState();
218 for (uint64_t state = 0; state < parameterLifterRef->getRowGroupCount(); ++state) {
219 auto oldStateNumber = parameterLifterRef->getOriginalStateNumber(state);
220 auto const& variables = occurringVariables.at(oldStateNumber);
223 STORM_LOG_THROW(variables.size() <= 1, storm::exceptions::NotImplementedException,
224 "Using localMonRes not yet implemented for states with 2 or more variables, please run without --use-monotonicity.");
226 bool allMonotone =
true;
227 for (
auto var : variables) {
228 auto const monotonicity = localMonotonicityResult.getMonotonicity(oldStateNumber, var);
230 bool const fixToLowerBound =
231 monotonicity == MonotonicityKind::Constant || monotonicity == (
storm::solver::minimize(dir) ? MonotonicityKind::Incr : MonotonicityKind::Decr);
232 bool const fixToUpperBound =
233 monotonicity == MonotonicityKind::Constant || monotonicity == (
storm::solver::maximize(dir) ? MonotonicityKind::Incr : MonotonicityKind::Decr);
234 if (fixToLowerBound || fixToUpperBound) {
236 schedulerChoices[state] = fixToLowerBound ? 0 : 1;
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)
std::map< VariableType, MonotonicityKind > globallyKnownMonotonicityInformation
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)
solver::OptimizationDirection OptimizationDirection
std::shared_ptr< storm::analysis::Order > stateOrder
std::shared_ptr< storm::analysis::LocalMonotonicityResult< VariableType > > localMonotonicityResult