15template<
typename ParametricType,
typename ConstantType>
18 auto [orderPtr, unknState1, unknState2] = orderExtender.
extendOrder(order,
region);
22 STORM_LOG_THROW(!order->isInvalid(), storm::exceptions::InvalidStateException,
"Order-based monotonicity analysis produced an inconsistent order.");
23 if (unknState1 != order->getNumberOfStates()) {
29template<
typename ParametricType,
typename ConstantType>
35 auto state = order->getNextDoneState(-1);
37 while (state != order->getNumberOfStates()) {
38 if (localMonotonicityResult.getMonotonicity(state) ==
nullptr) {
39 auto variables = variablesAtState[state];
40 if (variables.size() == 0 || order->isBottomState(state) || order->isTopState(state)) {
41 localMonotonicityResult.setConstant(state);
43 for (
auto const& var : variables) {
44 auto monotonicity = localMonotonicityResult.getMonotonicity(state, var);
48 localMonotonicityResult.setMonotonicity(state, var, monotonicity);
56 state = order->getNextDoneState(state);
60 for (
auto const& entry : statesAtVariable) {
61 auto states = entry.second;
62 auto var = entry.first;
64 for (
auto const& state : states) {
73 localMonotonicityResult.getGlobalMonotonicityResult()->setDoneForVar(var);
77 localMonotonicityResult.setDone();
78 while (order->existsNextState()) {
80 order->add(order->getNextStateNumber().second);
82 STORM_LOG_ASSERT(order->getDoneBuilding(),
"Order should be done building.");
87template<
typename ParametricType,
typename ConstantType>
89 : useOnlyGlobal(useOnlyGlobal), useBounds(useBounds) {
93template<
typename ParametricType,
typename ConstantType>
98template<
typename ParametricType,
typename ConstantType>
103template<
typename ParametricType,
typename ConstantType>
108 orderExtender->setMaxValuesInit(plaBoundFunction(env,
region, storm::solver::OptimizationDirection::Maximize));
109 orderExtender->setMinValuesInit(plaBoundFunction(env,
region, storm::solver::OptimizationDirection::Minimize));
116 if (kind == MonotonicityKind::Incr || kind == MonotonicityKind::Constant) {
118 }
else if (kind == MonotonicityKind::Decr) {
124 *this->parameterLifterRef);
125 region.monotonicityAnnotation.data = annotation;
128template<
typename ParametricType,
typename ConstantType>
130 auto annotation =
region.monotonicityAnnotation.getOrderBasedMonotonicityAnnotation();
131 STORM_LOG_ASSERT(annotation.has_value(),
"Order-based monotonicity annotation must be present.");
134 bool const changeOrder = !annotation->stateOrder->getDoneBuilding() && orderExtender->isHope(annotation->stateOrder);
135 if (changeOrder && annotation->stateOrder.use_count() > 1) {
137 auto newOrder = annotation->stateOrder->copy();
138 orderExtender->copyContext(annotation->stateOrder, newOrder);
139 annotation->stateOrder = newOrder;
145 bool const changeLocalMonotonicity = changeOrder && !annotation->localMonotonicityResult->isDone();
146 if (changeLocalMonotonicity && annotation->localMonotonicityResult.use_count() > 1) {
148 annotation->localMonotonicityResult = annotation->localMonotonicityResult->copy();
150 if (changeLocalMonotonicity) {
152 *this->parameterLifterRef);
156template<
typename ParametricType,
typename ConstantType>
159 auto annotation =
region.monotonicityAnnotation.getOrderBasedMonotonicityAnnotation();
160 STORM_LOG_ASSERT(annotation.has_value(),
"Order-based monotonicity annotation must be present.");
161 if (useBounds && !annotation->stateOrder->getDoneBuilding()) {
164 orderExtender->setMinMaxValues(annotation->stateOrder, plaBoundFunction(env,
region, storm::solver::OptimizationDirection::Minimize),
165 plaBoundFunction(env,
region, storm::solver::OptimizationDirection::Maximize));
169template<
typename ParametricType,
typename ConstantType>
170std::map<typename OrderBasedMonotonicityBackend<ParametricType, ConstantType>::VariableType,
179template<
typename ParametricType,
typename ConstantType>
180void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::initializeMonotonicityChecker(
185template<
typename ParametricType,
typename ConstantType>
186void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::initializeOrderExtender(
192template<
typename ParametricType,
typename ConstantType>
193void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::registerParameterLifterReference(
195 this->parameterLifterRef.reset(parameterLifter);
198template<
typename ParametricType,
typename ConstantType>
199void OrderBasedMonotonicityBackend<ParametricType, ConstantType>::registerPLABoundFunction(
201 this->plaBoundFunction = fun;
204template<
typename ParametricType,
typename ConstantType>
205storm::storage::BitVector OrderBasedMonotonicityBackend<ParametricType, ConstantType>::getChoicesToFixForPLASolver(
210 STORM_LOG_ASSERT(parameterLifterRef.has_value(),
"Parameter lifter reference not initialized.");
212 auto monotonicityAnnotation =
region.monotonicityAnnotation.getOrderBasedMonotonicityAnnotation();
213 STORM_LOG_ASSERT(monotonicityAnnotation.has_value() && monotonicityAnnotation->localMonotonicityResult !=
nullptr,
214 "Order-based monotonicity annotation must be present.");
215 auto const& localMonotonicityResult = *monotonicityAnnotation->localMonotonicityResult;
217 storm::storage::BitVector result(schedulerChoices.size(),
false);
219 auto const& occurringVariables = parameterLifterRef->getOccurringVariablesAtState();
220 for (uint64_t state = 0; state < parameterLifterRef->getRowGroupCount(); ++state) {
221 auto oldStateNumber = parameterLifterRef->getOriginalStateNumber(state);
222 auto const& variables = occurringVariables.at(oldStateNumber);
225 STORM_LOG_THROW(variables.size() <= 1, storm::exceptions::NotImplementedException,
226 "Using localMonRes not yet implemented for states with 2 or more variables, please run without --use-monotonicity.");
228 bool allMonotone =
true;
229 for (
auto var : variables) {
230 auto const monotonicity = localMonotonicityResult.getMonotonicity(oldStateNumber, var);
232 bool const fixToLowerBound =
233 monotonicity == MonotonicityKind::Constant || monotonicity == (
storm::solver::minimize(dir) ? MonotonicityKind::Incr : MonotonicityKind::Decr);
234 bool const fixToUpperBound =
235 monotonicity == MonotonicityKind::Constant || monotonicity == (
storm::solver::maximize(dir) ? MonotonicityKind::Incr : MonotonicityKind::Decr);
236 if (fixToLowerBound || fixToUpperBound) {
238 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::optional< Assumption > assumption=std::nullopt)
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