Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Order.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/container/flat_set.hpp>
4#include <iostream>
5#include <memory>
6#include <vector>
7
10
11namespace storm {
12namespace analysis {
13class Order {
14 public:
24
28 struct Node {
29 boost::container::flat_set<uint_fast64_t> states;
31 };
32
41 Order(storm::storage::BitVector* topStates, storm::storage::BitVector* bottomStates, uint_fast64_t numberOfStates,
42 storage::Decomposition<storage::StronglyConnectedComponent> sccsSorted, std::vector<uint_fast64_t> statesSorted);
43
52 Order(uint_fast64_t top, uint_fast64_t bottom, uint_fast64_t numberOfStates, storage::Decomposition<storage::StronglyConnectedComponent> sccsSorted,
53 std::vector<uint_fast64_t> statesSorted);
54
58 Order();
59
65 void add(uint_fast64_t state);
66
73 void addAbove(uint_fast64_t state, Node* node);
74
81 void addBelow(uint_fast64_t state, Node* node);
82
90 void addBetween(uint_fast64_t state, Node* node1, Node* node2);
91
100 void addBetween(uint_fast64_t state, uint_fast64_t above, uint_fast64_t below);
101
108 void addRelationNodes(storm::analysis::Order::Node* above, storm::analysis::Order::Node* below, bool allowMerge = false);
109
116 void addRelation(uint_fast64_t above, uint_fast64_t below, bool allowMerge = false);
117
124 void addToNode(uint_fast64_t state, Node* node);
125
130 bool mergeNodes(Node* node1, Node* node2);
131
136 bool merge(uint_fast64_t var1, uint_fast64_t var2);
137
149 Order::NodeComparison compare(uint_fast64_t state1, uint_fast64_t state2, NodeComparison hypothesis = UNKNOWN);
150 Order::NodeComparison compareFast(uint_fast64_t state1, uint_fast64_t state2, NodeComparison hypothesis = UNKNOWN) const;
151
162 NodeComparison compare(Node* node1, Node* node2, NodeComparison hypothesis = UNKNOWN);
163 NodeComparison compareFast(Node* node1, Node* node2, NodeComparison hypothesis = UNKNOWN) const;
164
168 bool contains(uint_fast64_t state) const;
169
175 Node* getBottom() const;
176
180 bool getDoneBuilding() const;
181
185 uint_fast64_t getNextDoneState(uint_fast64_t state) const;
186
187 uint_fast64_t getNumberOfDoneStates() const;
188
195 Node* getNode(uint_fast64_t state) const;
196
204 std::vector<Node*> getNodes() const;
205
206 std::vector<uint_fast64_t>& getStatesSorted();
212 Node* getTop() const;
213
217 uint_fast64_t getNumberOfAddedStates() const;
218
222 uint_fast64_t getNumberOfStates() const;
223
227 bool isBottomState(uint_fast64_t) const;
228
232 bool isTopState(uint_fast64_t) const;
233
237 bool isOnlyBottomTopOrder() const;
238
246 std::vector<uint_fast64_t> sortStates(std::vector<uint_fast64_t>* states);
247 std::pair<bool, bool> allAboveBelow(std::vector<uint_fast64_t> const states, uint_fast64_t state);
248
258 std::pair<std::pair<uint_fast64_t, uint_fast64_t>, std::vector<uint_fast64_t>> sortStatesForForward(uint_fast64_t currentState,
259 std::vector<uint_fast64_t> const& successors);
260
268 std::pair<std::pair<uint_fast64_t, uint_fast64_t>, std::vector<uint_fast64_t>> sortStatesUnorderedPair(const std::vector<uint_fast64_t>* states);
269
277 std::vector<uint_fast64_t> sortStates(storm::storage::BitVector* states);
278
279 bool isTrivial(uint_fast64_t state);
280 std::pair<uint_fast64_t, bool> getNextStateNumber();
281
282 // bool existsNextSCC();
283 bool existsNextState();
284 bool existsStateToHandle();
285
286 std::pair<uint_fast64_t, bool> getStateToHandle();
287
288 void addStateToHandle(uint_fast64_t state);
289 void addStateSorted(uint_fast64_t state);
290
294 void setDoneBuilding(bool done = true);
295
299 void toDotOutput() const;
300
306 void dotOutputToFile(std::ofstream& dotOutfile) const;
307
313 std::shared_ptr<Order> copy() const;
314 // void setAddedSCC(uint_fast64_t sccNumber);
315 void setDoneState(uint_fast64_t sccNumber);
316
317 bool isInvalid() const;
318
319 protected:
321
322 private:
323 bool above(Node* node1, Node* node2);
324
325 bool above(Node* node1, Node* node2, storm::analysis::Order::Node* nodePrev, storm::storage::BitVector* statesSeen);
326
327 bool aboveFast(Node* node1, Node* node2) const;
328
329 void init(uint_fast64_t numberOfStates, storage::Decomposition<storage::StronglyConnectedComponent>, bool doneBuilding = false);
330
331 std::string nodeName(Node n) const;
332
333 std::string nodeLabel(Node n) const;
334
335 bool invalid;
336
337 void nodeOutput();
338
339 bool doneBuilding;
340
341 bool onlyBottomTopOrder;
342
343 storm::storage::BitVector doneStates;
344 storm::storage::BitVector trivialStates;
345
346 std::vector<Node*> nodes;
347
348 std::vector<uint_fast64_t> statesToHandle;
349
350 Node* top;
351
352 Node* bottom;
353
354 uint_fast64_t numberOfStates;
355
356 uint_fast64_t numberOfAddedStates;
357
358 std::vector<uint_fast64_t> statesSorted;
359};
360} // namespace analysis
361} // namespace storm
uint_fast64_t getNumberOfDoneStates() const
Definition Order.cpp:797
void addAbove(uint_fast64_t state, Node *node)
Adds a node with the given state above the given node.
Definition Order.cpp:73
bool isTrivial(uint_fast64_t state)
Definition Order.cpp:747
void addStateSorted(uint_fast64_t state)
Definition Order.cpp:782
Node * getBottom() const
Retrieves the bottom node of the order.
Definition Order.cpp:293
bool contains(uint_fast64_t state) const
Check if state is already contained in order.
Definition Order.cpp:289
bool isInvalid() const
Definition Order.cpp:801
Order::NodeComparison compareFast(uint_fast64_t state1, uint_fast64_t state2, NodeComparison hypothesis=UNKNOWN) const
Definition Order.cpp:241
Order::NodeComparison compare(uint_fast64_t state1, uint_fast64_t state2, NodeComparison hypothesis=UNKNOWN)
Compares the level of the nodes of the states.
Definition Order.cpp:237
std::pair< uint_fast64_t, bool > getStateToHandle()
Definition Order.cpp:762
std::vector< uint_fast64_t > & getStatesSorted()
Definition Order.cpp:315
std::vector< uint_fast64_t > sortStates(std::vector< uint_fast64_t > *states)
Sorts the given states if possible.
Definition Order.cpp:345
NodeComparison
Constants for comparison of nodes/states.
Definition Order.h:18
Order()
Constructs a new Order.
Definition Order.cpp:61
void toDotOutput() const
Prints the dot output to normal STORM_PRINT.
Definition Order.cpp:561
void dotOutputToFile(std::ofstream &dotOutfile) const
Writes dotoutput to the given file.
Definition Order.cpp:603
storage::Decomposition< storage::StronglyConnectedComponent > getDecomposition() const
void addRelation(uint_fast64_t above, uint_fast64_t below, bool allowMerge=false)
Adds a new relation between two states to the order.
Definition Order.cpp:150
Node * getNode(uint_fast64_t state) const
Retrieves the pointer to a Node at which the state occurs.
Definition Order.cpp:306
bool merge(uint_fast64_t var1, uint_fast64_t var2)
Merges node of var2 into node of var1.
Definition Order.cpp:231
std::vector< Node * > getNodes() const
Returns the vector with the nodes of the order.
Definition Order.cpp:311
bool mergeNodes(Node *node1, Node *node2)
Merges node2 into node1.
Definition Order.cpp:192
std::pair< bool, bool > allAboveBelow(std::vector< uint_fast64_t > const states, uint_fast64_t state)
Definition Order.cpp:786
uint_fast64_t getNextDoneState(uint_fast64_t state) const
Returns the next done state of the order, returns the number of state if end of done states is reache...
Definition Order.cpp:302
bool getDoneBuilding() const
Returns true if done building the order.
Definition Order.cpp:297
void addToNode(uint_fast64_t state, Node *node)
Adds state to the states of the given node.
Definition Order.cpp:173
bool isTopState(uint_fast64_t) const
Checks if the given state is a top state.
Definition Order.cpp:336
std::pair< std::pair< uint_fast64_t, uint_fast64_t >, std::vector< uint_fast64_t > > sortStatesForForward(uint_fast64_t currentState, std::vector< uint_fast64_t > const &successors)
Sorts the given states if possible.
Definition Order.cpp:383
std::pair< std::pair< uint_fast64_t, uint_fast64_t >, std::vector< uint_fast64_t > > sortStatesUnorderedPair(const std::vector< uint_fast64_t > *states)
Sorts the given states if possible.
Definition Order.cpp:436
void addStateToHandle(uint_fast64_t state)
Definition Order.cpp:776
void addBetween(uint_fast64_t state, Node *node1, Node *node2)
Adds a node with the given state below node1 and above node2.
Definition Order.cpp:113
uint_fast64_t getNumberOfStates() const
Returns the number of possible states in the order.
Definition Order.cpp:327
void addBelow(uint_fast64_t state, Node *node)
Adds a node with the given state below the given node.
Definition Order.cpp:93
void setDoneState(uint_fast64_t sccNumber)
Definition Order.cpp:555
std::pair< uint_fast64_t, bool > getNextStateNumber()
Definition Order.cpp:751
std::shared_ptr< Order > copy() const
Creates a copy of the calling Order.
Definition Order.cpp:510
bool isOnlyBottomTopOrder() const
Returns if the order only consists of bottom and top states (so no in-between nodes).
Definition Order.cpp:341
uint_fast64_t getNumberOfAddedStates() const
Returns the number of added states.
Definition Order.cpp:323
bool isBottomState(uint_fast64_t) const
Checks if the given state is a bottom state.
Definition Order.cpp:331
Node * getTop() const
Retrieves the top node of the order.
Definition Order.cpp:319
void add(uint_fast64_t state)
Adds state between the top and bottom node of the order.
Definition Order.cpp:67
void setDoneBuilding(bool done=true)
If the order is fully built, this can be set to true.
void addRelationNodes(storm::analysis::Order::Node *above, storm::analysis::Order::Node *below, bool allowMerge=false)
Adds a new relation between two nodes to the order.
Definition Order.cpp:155
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
This class represents the decomposition of a model into blocks which are of the template type.
LabParser.cpp.
Definition cli.cpp:18
Nodes of the Reachability Order.
Definition Order.h:28
boost::container::flat_set< uint_fast64_t > states
Definition Order.h:29
storm::storage::BitVector statesAbove
Definition Order.h:30