Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
OrderExtender.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/container/flat_set.hpp>
4#include <cstddef>
5#include <optional>
9
16
17namespace storm {
18namespace analysis {
19template<typename ValueType, typename ConstantType>
21 public:
25
33 OrderExtender(std::shared_ptr<models::sparse::Model<ValueType>> model, std::shared_ptr<logic::Formula const> formula);
34
43
52 std::tuple<std::shared_ptr<Order>, uint_fast64_t, uint_fast64_t> toOrder(storage::ParameterRegion<ValueType> region,
53 std::shared_ptr<MonotonicityResult<VariableType>> monRes = nullptr);
54
64 std::tuple<std::shared_ptr<Order>, uint_fast64_t, uint_fast64_t> extendOrder(std::shared_ptr<Order> order,
66 std::shared_ptr<MonotonicityResult<VariableType>> monRes = nullptr,
67 std::optional<Assumption> assumption = std::nullopt);
68
69 void setMinMaxValues(std::shared_ptr<Order> order, std::vector<ConstantType>&& minValues, std::vector<ConstantType>&& maxValues);
70 void setMinValues(std::shared_ptr<Order> order, std::vector<ConstantType>&& minValues);
71 void setMaxValues(std::shared_ptr<Order> order, std::vector<ConstantType>&& maxValues);
72 void setMinValuesInit(std::vector<ConstantType>&& minValues);
73 void setMaxValuesInit(std::vector<ConstantType>&& minValues);
74
75 void setUnknownStates(std::shared_ptr<Order> order, uint_fast64_t state1, uint_fast64_t state2);
76
77 std::pair<uint_fast64_t, uint_fast64_t> getUnknownStates(std::shared_ptr<Order> order) const;
78 void copyContext(std::shared_ptr<Order> orderOriginal, std::shared_ptr<Order> orderCopy);
80 void checkParOnStateMonRes(uint_fast64_t s, std::shared_ptr<Order> order, typename OrderExtender<ValueType, ConstantType>::VariableType param,
81 std::shared_ptr<MonotonicityResult<VariableType>> monResult);
82
83 bool isHope(std::shared_ptr<Order> order);
84
86 std::vector<std::set<VariableType>> const& getVariablesOccuringAtState();
87
88 private:
89 Order::NodeComparison addStatesBasedOnMinMax(std::shared_ptr<Order> order, uint_fast64_t state1, uint_fast64_t state2) const;
90 std::tuple<std::shared_ptr<Order>, uint_fast64_t, uint_fast64_t> extendOrder(std::shared_ptr<Order> order,
91 std::shared_ptr<MonotonicityResult<VariableType>> monRes,
92 std::optional<Assumption> assumption = std::nullopt);
93 std::pair<uint_fast64_t, uint_fast64_t> extendNormal(std::shared_ptr<Order> order, uint_fast64_t currentState, std::vector<uint_fast64_t> const& successors,
94 bool allowMerge);
95 std::pair<uint_fast64_t, uint_fast64_t> extendByBackwardReasoning(std::shared_ptr<Order> order, uint_fast64_t currentState,
96 std::vector<uint_fast64_t> const& successors, bool allowMerge);
97 std::pair<uint_fast64_t, uint_fast64_t> extendByForwardReasoning(std::shared_ptr<Order> order, uint_fast64_t currentState,
98 std::vector<uint_fast64_t> const& successors, bool allowMerge);
99 bool extendByAssumption(std::shared_ptr<Order> order, uint_fast64_t state1, uint_fast64_t state2);
100
101 void handleOneSuccessor(std::shared_ptr<Order> order, uint_fast64_t currentState, uint_fast64_t successor);
102 void handleAssumption(std::shared_ptr<Order> order, Assumption const& assumption) const;
103
104 std::pair<uint_fast64_t, bool> getNextState(std::shared_ptr<Order> order, uint_fast64_t stateNumber, bool done);
105 std::shared_ptr<Order> computeInitialOrder(storm::storage::BitVector const& topStates, storm::storage::BitVector const& bottomStates,
106 storm::storage::SparseMatrix<ValueType> const& matrix, bool addStatesWithDirectBoundaryTransition);
107 std::shared_ptr<Order> getBottomTopOrder();
108
109 std::shared_ptr<Order> bottomTopOrder = nullptr;
110
111 // Per-in-progress-order bookkeeping used while extending an order (PLA bounds, whether PLA is
112 // usable/worth continuing, and the pair of states this order got stuck on, if any). Keyed by
113 // weak_ptr so this bookkeeping neither keeps an order alive nor inflates its use_count()
114 // while the order is still being extended.
115 struct Context {
116 std::vector<ConstantType> minValues;
117 std::vector<ConstantType> maxValues;
118 bool usePLA = false;
119 bool continueExtending = true;
120 // The pair of states this order got stuck on, i.e., the first unordered pair (state1, state2)
121 // whose relation could not be resolved during extension. Initialized to (numberOfStates,
122 // numberOfStates) meaning "no unknown pair recorded". It is set externally via
123 // setUnknownStates() and read via getUnknownStates() when the region refinement loop decides
124 // whether a sub-region can resolve more of the order.
125 std::pair<uint_fast64_t, uint_fast64_t> unknownStates;
126 };
127 Context& context(std::shared_ptr<Order> const& order);
128 Context const& contextAt(std::shared_ptr<Order> const& order) const;
129 std::map<std::weak_ptr<Order>, Context, std::owner_less<std::weak_ptr<Order>>> contexts;
130
131 // Weak keys do not keep orders alive, so entries for destroyed orders linger. Once the map grows
132 // past this size, expired entries are purged on the next insertion, keeping the scan cost
133 // amortized O(1) per inserted context.
134 std::size_t nextContextPruneSize = 64;
135
136 boost::optional<std::vector<ConstantType>> minValuesInit;
137 boost::optional<std::vector<ConstantType>> maxValuesInit;
138
140 std::shared_ptr<models::sparse::Model<ValueType>> model;
141
142 std::map<uint_fast64_t, std::vector<uint_fast64_t>> stateMap;
143
144 bool cyclic;
145
146 std::shared_ptr<logic::Formula const> formula;
147
149
150 uint_fast64_t numberOfStates;
151
152 std::unique_ptr<analysis::AssumptionMaker<ValueType, ConstantType>> assumptionMaker;
153
154 boost::container::flat_set<uint_fast64_t> nonParametricStates;
155
156 std::map<VariableType, std::vector<uint_fast64_t>> occuringStatesAtVariable;
157 std::vector<std::set<VariableType>> occuringVariablesAtState;
158 MonotonicityChecker<ValueType> monotonicityChecker;
159};
160} // namespace analysis
161} // namespace storm
storm::analysis::MonotonicityKind Monotonicity
void initializeMinMaxValues(Environment const &env, storage::ParameterRegion< ValueType > region)
void setMaxValuesInit(std::vector< ConstantType > &&minValues)
std::vector< std::set< VariableType > > const & getVariablesOccuringAtState()
std::pair< uint_fast64_t, uint_fast64_t > getUnknownStates(std::shared_ptr< Order > order) const
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 setMaxValues(std::shared_ptr< Order > order, std::vector< ConstantType > &&maxValues)
MonotonicityChecker< ValueType > & getMonotoncityChecker()
void setMinValues(std::shared_ptr< Order > order, std::vector< ConstantType > &&minValues)
void setMinValuesInit(std::vector< ConstantType > &&minValues)
void setUnknownStates(std::shared_ptr< Order > order, uint_fast64_t state1, uint_fast64_t state2)
OrderExtender(std::shared_ptr< models::sparse::Model< ValueType > > model, std::shared_ptr< logic::Formula const > formula)
Constructs a new OrderExtender.
void copyContext(std::shared_ptr< Order > orderOriginal, std::shared_ptr< Order > orderCopy)
utility::parametric::VariableType< ValueType >::type VariableType
MonotonicityResult< VariableType >::Monotonicity Monotonicity
std::tuple< std::shared_ptr< Order >, uint_fast64_t, uint_fast64_t > toOrder(storage::ParameterRegion< ValueType > region, std::shared_ptr< MonotonicityResult< VariableType > > monRes=nullptr)
Creates an order based on the given formula.
void setMinMaxValues(std::shared_ptr< Order > order, std::vector< ConstantType > &&minValues, std::vector< ConstantType > &&maxValues)
void checkParOnStateMonRes(uint_fast64_t s, std::shared_ptr< Order > order, typename OrderExtender< ValueType, ConstantType >::VariableType param, std::shared_ptr< MonotonicityResult< VariableType > > monResult)
bool isHope(std::shared_ptr< Order > order)
utility::parametric::CoefficientType< ValueType >::type CoefficientType
NodeComparison
Constants for comparison of nodes/states.
Definition Order.h:18
Base class for all sparse models.
Definition Model.h:34
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
A class that holds a possibly non-square matrix in the compressed row storage format.
A candidate relation between two states of a reachability order: either state1 > state2 (Greater) or ...
Definition Assumption.h:20