Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ExplorationQueue.cpp
Go to the documentation of this file.
2
5
6namespace storm::pomdp::beliefs {
7
9 // Intentionally left empty.
10}
11
13 STORM_LOG_ASSERT((order == ExplorationQueueOrder::Unordered) ? queue.empty() : (contents.size() == queue.size()), "inconsistent queue state");
14 if (newOrder == order) {
15 return; // nothing to do.
16 }
17 if (newOrder == ExplorationQueueOrder::Unordered) {
18 queue.clear(); // just keep the contents, drop the queue order
19 } else if (order == ExplorationQueueOrder::Unordered) {
20 // since newOrder != order, the newOrder will need the queue
21 for (auto const id : contents) {
22 queue.push_back(id);
23 }
24 }
25 order = newOrder;
26 STORM_LOG_ASSERT((order == ExplorationQueueOrder::Unordered) ? queue.empty() : (contents.size() == queue.size()), "inconsistent queue state");
27}
28
30 STORM_LOG_ASSERT((order == ExplorationQueueOrder::Unordered) ? queue.empty() : (contents.size() == queue.size()), "inconsistent queue state");
31 return !contents.empty();
32}
33
35 if (contents.insert(id).second) {
37 queue.push_back(id);
38 }
39 return true;
40 }
41 return false;
42}
43
45 STORM_LOG_ASSERT(hasNext(), "Trying to pop from empty queue.");
47 BeliefId const id = *contents.begin();
48 contents.erase(contents.begin());
49 return id;
50 } else {
51 BeliefId id;
52 if (order == ExplorationQueueOrder::LIFO) {
53 id = queue.back();
54 queue.pop_back();
55 } else {
56 id = queue.front();
57 queue.pop_front();
58 }
59 STORM_LOG_ASSERT(contents.count(id) == 1, "Queue contains belief that is not in contents.");
60 contents.erase(id);
61 return id;
62 }
63}
64
65std::unordered_set<storm::pomdp::beliefs::BeliefId> ExplorationQueue::getContents() const {
66 return contents;
67}
68} // namespace storm::pomdp::beliefs
std::unordered_set< storm::pomdp::beliefs::BeliefId > getContents() const
void changeOrder(ExplorationQueueOrder const newOrder)
Changes the order in which the queue processes the elements.
ExplorationQueue(ExplorationQueueOrder const order=ExplorationQueueOrder::Unordered)
bool push(BeliefId const id)
Adds the given belief id to the queue.
BeliefId popNext()
Removes and returns the next belief id from the queue.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
uint64_t BeliefId
Definition types.h:12
ExplorationQueueOrder
Order used to select the next discovered belief for exploration.