Storm 1.14.0.1
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 const& topStates, storm::storage::BitVector const& 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
64 Order(Order const& other);
65
66 Order(Order&&) noexcept = default;
67
68 Order& operator=(Order other);
69
70 friend void swap(Order& first, Order& second) noexcept;
71
77 void add(uint_fast64_t state);
78
85 void addAbove(uint_fast64_t state, Node* node);
86
93 void addBelow(uint_fast64_t state, Node* node);
94
102 void addBetween(uint_fast64_t state, Node* node1, Node* node2);
103
112 void addBetween(uint_fast64_t state, uint_fast64_t above, uint_fast64_t below);
113
120 void addRelationNodes(storm::analysis::Order::Node* above, storm::analysis::Order::Node* below, bool allowMerge = false);
121
128 void addRelation(uint_fast64_t above, uint_fast64_t below, bool allowMerge = false);
129
136 void addToNode(uint_fast64_t state, Node* node);
137
142 bool mergeNodes(Node* node1, Node* node2);
143
148 bool merge(uint_fast64_t var1, uint_fast64_t var2);
149
161 Order::NodeComparison compare(uint_fast64_t state1, uint_fast64_t state2, NodeComparison hypothesis = UNKNOWN);
162 Order::NodeComparison compareFast(uint_fast64_t state1, uint_fast64_t state2, NodeComparison hypothesis = UNKNOWN) const;
163
174 NodeComparison compare(Node* node1, Node* node2, NodeComparison hypothesis = UNKNOWN);
175 NodeComparison compareFast(Node* node1, Node* node2, NodeComparison hypothesis = UNKNOWN) const;
176
180 bool contains(uint_fast64_t state) const;
181
187 Node* getBottom() const;
188
192 bool getDoneBuilding() const;
193
197 uint_fast64_t getNextDoneState(uint_fast64_t state) const;
198
199 uint_fast64_t getNumberOfDoneStates() const;
200
207 Node* getNode(uint_fast64_t state) const;
208
216 std::vector<Node*> getNodes() const;
217
218 std::vector<uint_fast64_t>& getStatesSorted();
224 Node* getTop() const;
225
229 uint_fast64_t getNumberOfAddedStates() const;
230
234 uint_fast64_t getNumberOfStates() const;
235
239 bool isBottomState(uint_fast64_t) const;
240
244 bool isTopState(uint_fast64_t) const;
245
249 bool isOnlyBottomTopOrder() const;
250
258 std::vector<uint_fast64_t> sortStates(std::vector<uint_fast64_t>* states);
259 std::pair<bool, bool> allAboveBelow(std::vector<uint_fast64_t> const states, uint_fast64_t state);
260
270 std::pair<std::pair<uint_fast64_t, uint_fast64_t>, std::vector<uint_fast64_t>> sortStatesForForward(uint_fast64_t currentState,
271 std::vector<uint_fast64_t> const& successors);
272
280 std::pair<std::pair<uint_fast64_t, uint_fast64_t>, std::vector<uint_fast64_t>> sortStatesUnorderedPair(const std::vector<uint_fast64_t>* states);
281
289 std::vector<uint_fast64_t> sortStates(storm::storage::BitVector* states);
290
291 bool isTrivial(uint_fast64_t state);
292 std::pair<uint_fast64_t, bool> getNextStateNumber();
293
294 // bool existsNextSCC();
295 bool existsNextState();
296 bool existsStateToHandle();
297
298 std::pair<uint_fast64_t, bool> getStateToHandle();
299
300 void addStateToHandle(uint_fast64_t state);
301 void addStateSorted(uint_fast64_t state);
302
306 void toDotOutput() const;
307
313 void dotOutputToFile(std::ofstream& dotOutfile) const;
314
320 std::shared_ptr<Order> copy() const;
321 // void setAddedSCC(uint_fast64_t sccNumber);
322 void setDoneState(uint_fast64_t sccNumber);
323
324 bool isInvalid() const;
325
326 private:
327 bool above(Node* node1, Node* node2);
328
329 bool aboveFast(Node* node1, Node* node2) const;
330
331 void init(uint_fast64_t numberOfStates, storage::Decomposition<storage::StronglyConnectedComponent>, bool doneBuilding = false);
332
337 Node* allocateNode();
338
339 std::string nodeName(Node n) const;
340
341 std::string nodeLabel(Node n) const;
342
343 bool invalid;
344
345 bool doneBuilding;
346
347 bool onlyBottomTopOrder;
348
349 storm::storage::BitVector doneStates;
350 storm::storage::BitVector trivialStates;
351
352 std::vector<Node*> nodes;
353
354 // Sole owner of every Node allocated for this Order; `nodes`, `top` and `bottom` are
355 // non-owning observer pointers into this storage.
356 std::vector<std::unique_ptr<Node>> nodeStorage;
357
358 std::vector<uint_fast64_t> statesToHandle;
359
360 Node* top;
361
362 Node* bottom;
363
364 uint_fast64_t numberOfStates;
365
366 uint_fast64_t numberOfAddedStates;
367
368 std::vector<uint_fast64_t> statesSorted;
369};
370} // namespace analysis
371} // namespace storm
uint_fast64_t getNumberOfDoneStates() const
Definition Order.cpp:845
void addAbove(uint_fast64_t state, Node *node)
Adds a node with the given state above the given node.
Definition Order.cpp:145
bool isTrivial(uint_fast64_t state)
Definition Order.cpp:795
void addStateSorted(uint_fast64_t state)
Definition Order.cpp:830
Node * getBottom() const
Retrieves the bottom node of the order.
Definition Order.cpp:372
bool contains(uint_fast64_t state) const
Check if state is already contained in order.
Definition Order.cpp:368
bool isInvalid() const
Definition Order.cpp:849
Order::NodeComparison compareFast(uint_fast64_t state1, uint_fast64_t state2, NodeComparison hypothesis=UNKNOWN) const
Definition Order.cpp:318
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:314
std::pair< uint_fast64_t, bool > getStateToHandle()
Definition Order.cpp:810
std::vector< uint_fast64_t > & getStatesSorted()
Definition Order.cpp:395
friend void swap(Order &first, Order &second) noexcept
Definition Order.cpp:115
std::vector< uint_fast64_t > sortStates(std::vector< uint_fast64_t > *states)
Sorts the given states if possible.
Definition Order.cpp:425
NodeComparison
Constants for comparison of nodes/states.
Definition Order.h:18
Order()
Constructs a new Order.
Definition Order.cpp:63
void toDotOutput() const
Prints the dot output to stdout.
Definition Order.cpp:603
void dotOutputToFile(std::ofstream &dotOutfile) const
Writes dotoutput to the given file.
Definition Order.cpp:647
Order(storm::storage::BitVector const &topStates, storm::storage::BitVector const &bottomStates, uint_fast64_t numberOfStates, storage::Decomposition< storage::StronglyConnectedComponent > sccsSorted, std::vector< uint_fast64_t > statesSorted)
Constructs an order with the given top and bottom states.
Definition Order.cpp:10
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:221
Node * getNode(uint_fast64_t state) const
Retrieves the pointer to a Node at which the state occurs.
Definition Order.cpp:386
bool merge(uint_fast64_t var1, uint_fast64_t var2)
Merges node of var2 into node of var1.
Definition Order.cpp:308
std::vector< Node * > getNodes() const
Returns the vector with the nodes of the order.
Definition Order.cpp:391
bool mergeNodes(Node *node1, Node *node2)
Merges node2 into node1.
Definition Order.cpp:263
std::pair< bool, bool > allAboveBelow(std::vector< uint_fast64_t > const states, uint_fast64_t state)
Definition Order.cpp:834
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:382
bool getDoneBuilding() const
Returns true if done building the order.
Definition Order.cpp:376
void addToNode(uint_fast64_t state, Node *node)
Adds state to the states of the given node.
Definition Order.cpp:244
bool isTopState(uint_fast64_t) const
Checks if the given state is a top state.
Definition Order.cpp:416
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:463
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:517
void addStateToHandle(uint_fast64_t state)
Definition Order.cpp:824
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:185
Order(Order &&) noexcept=default
uint_fast64_t getNumberOfStates() const
Returns the number of possible states in the order.
Definition Order.cpp:407
void addBelow(uint_fast64_t state, Node *node)
Adds a node with the given state below the given node.
Definition Order.cpp:165
void setDoneState(uint_fast64_t sccNumber)
Definition Order.cpp:597
std::pair< uint_fast64_t, bool > getNextStateNumber()
Definition Order.cpp:799
std::shared_ptr< Order > copy() const
Creates a copy of the calling Order.
Definition Order.cpp:591
bool isOnlyBottomTopOrder() const
Returns if the order only consists of bottom and top states (so no in-between nodes).
Definition Order.cpp:421
uint_fast64_t getNumberOfAddedStates() const
Returns the number of added states.
Definition Order.cpp:403
bool isBottomState(uint_fast64_t) const
Checks if the given state is a bottom state.
Definition Order.cpp:411
Node * getTop() const
Retrieves the top node of the order.
Definition Order.cpp:399
void add(uint_fast64_t state)
Adds state between the top and bottom node of the order.
Definition Order.cpp:139
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:226
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
This class represents the decomposition of a model into blocks which are of the template type.
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