Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
PermissiveSchedulerPenalty.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <unordered_map>
5#include <utility>
6
9
10namespace storm {
11namespace ps {
12
14 std::unordered_map<storage::StateActionPair, double> mPenalties;
15
16 public:
17 double get(uint_fast64_t state, uint_fast64_t action) const {
18 return get(storage::StateActionPair(state, action));
19 }
20
21 double get(storage::StateActionPair const& sap) const {
22 auto it = mPenalties.find(sap);
23 if (it == mPenalties.end()) {
24 return 1.0;
25 } else {
26 return it->second;
27 }
28 }
29
30 void set(uint64_t state, uint64_t action, double penalty) {
31 STORM_LOG_ASSERT(penalty >= 1.0, "Penalty too low.");
32 if (penalty == 1.0) {
33 auto it = mPenalties.find(std::make_pair(state, action));
34 if (it != mPenalties.end()) {
35 mPenalties.erase(it);
36 }
37 } else {
38 mPenalties.emplace(std::make_pair(state, action), penalty);
39 }
40 }
41
42 void clear() {
43 mPenalties.clear();
44 }
45};
46} // namespace ps
47} // namespace storm
double get(storage::StateActionPair const &sap) const
void set(uint64_t state, uint64_t action, double penalty)
double get(uint_fast64_t state, uint_fast64_t action) const
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9