Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Bounds.cpp
Go to the documentation of this file.
2
4
5namespace storm {
6namespace modelchecker {
7namespace exploration_detail {
8
9template<typename StateType, typename ValueType>
11 StateType const& state, ExplorationInformation<StateType, ValueType> const& explorationInformation) const {
12 ActionType index = explorationInformation.getRowGroup(state);
13 if (index == explorationInformation.getUnexploredMarker()) {
14 return std::make_pair(storm::utility::zero<ValueType>(), storm::utility::one<ValueType>());
15 } else {
16 return boundsPerState[index];
17 }
18}
19
20template<typename StateType, typename ValueType>
22 ExplorationInformation<StateType, ValueType> const& explorationInformation) const {
23 ActionType index = explorationInformation.getRowGroup(state);
24 if (index == explorationInformation.getUnexploredMarker()) {
25 return storm::utility::zero<ValueType>();
26 } else {
27 return getLowerBoundForRowGroup(index);
28 }
29}
30
31template<typename StateType, typename ValueType>
32ValueType const& Bounds<StateType, ValueType>::getLowerBoundForRowGroup(StateType const& rowGroup) const {
33 return boundsPerState[rowGroup].first;
34}
35
36template<typename StateType, typename ValueType>
38 ExplorationInformation<StateType, ValueType> const& explorationInformation) const {
39 ActionType index = explorationInformation.getRowGroup(state);
40 if (index == explorationInformation.getUnexploredMarker()) {
41 return storm::utility::one<ValueType>();
42 } else {
43 return getUpperBoundForRowGroup(index);
44 }
45}
46
47template<typename StateType, typename ValueType>
48ValueType const& Bounds<StateType, ValueType>::getUpperBoundForRowGroup(StateType const& rowGroup) const {
49 return boundsPerState[rowGroup].second;
50}
51
52template<typename StateType, typename ValueType>
53std::pair<ValueType, ValueType> const& Bounds<StateType, ValueType>::getBoundsForAction(ActionType const& action) const {
54 return boundsPerAction[action];
55}
56
57template<typename StateType, typename ValueType>
59 return boundsPerAction[action].first;
60}
61
62template<typename StateType, typename ValueType>
64 return boundsPerAction[action].second;
65}
66
67template<typename StateType, typename ValueType>
68ValueType const& Bounds<StateType, ValueType>::getBoundForAction(storm::OptimizationDirection const& direction, ActionType const& action) const {
69 if (direction == storm::OptimizationDirection::Maximize) {
70 return getUpperBoundForAction(action);
71 } else {
72 return getLowerBoundForAction(action);
73 }
74}
75
76template<typename StateType, typename ValueType>
78 ExplorationInformation<StateType, ValueType> const& explorationInformation) const {
79 std::pair<ValueType, ValueType> bounds = getBoundsForState(state, explorationInformation);
80 return bounds.second - bounds.first;
81}
82
83template<typename StateType, typename ValueType>
84void Bounds<StateType, ValueType>::initializeBoundsForNextState(std::pair<ValueType, ValueType> const& vals) {
85 boundsPerState.push_back(vals);
86}
87
88template<typename StateType, typename ValueType>
89void Bounds<StateType, ValueType>::initializeBoundsForNextAction(std::pair<ValueType, ValueType> const& vals) {
90 boundsPerAction.push_back(vals);
91}
92
93template<typename StateType, typename ValueType>
95 ValueType const& value) {
96 setLowerBoundForRowGroup(explorationInformation.getRowGroup(state), value);
97}
98
99template<typename StateType, typename ValueType>
100void Bounds<StateType, ValueType>::setLowerBoundForRowGroup(StateType const& group, ValueType const& value) {
101 boundsPerState[group].first = value;
102}
103
104template<typename StateType, typename ValueType>
106 ValueType const& value) {
107 setUpperBoundForRowGroup(explorationInformation.getRowGroup(state), value);
108}
109
110template<typename StateType, typename ValueType>
111void Bounds<StateType, ValueType>::setUpperBoundForRowGroup(StateType const& group, ValueType const& value) {
112 boundsPerState[group].second = value;
113}
114
115template<typename StateType, typename ValueType>
116void Bounds<StateType, ValueType>::setBoundsForAction(ActionType const& action, std::pair<ValueType, ValueType> const& values) {
117 boundsPerAction[action] = values;
118}
119
120template<typename StateType, typename ValueType>
122 std::pair<ValueType, ValueType> const& values) {
123 StateType const& rowGroup = explorationInformation.getRowGroup(state);
124 setBoundsForRowGroup(rowGroup, values);
125}
126
127template<typename StateType, typename ValueType>
128void Bounds<StateType, ValueType>::setBoundsForRowGroup(StateType const& rowGroup, std::pair<ValueType, ValueType> const& values) {
129 boundsPerState[rowGroup] = values;
130}
131
132template<typename StateType, typename ValueType>
134 ExplorationInformation<StateType, ValueType> const& explorationInformation,
135 ValueType const& newLowerValue) {
136 StateType const& rowGroup = explorationInformation.getRowGroup(state);
137 if (boundsPerState[rowGroup].first < newLowerValue) {
138 boundsPerState[rowGroup].first = newLowerValue;
139 return true;
140 }
141 return false;
142}
143
144template<typename StateType, typename ValueType>
146 ExplorationInformation<StateType, ValueType> const& explorationInformation,
147 ValueType const& newUpperValue) {
148 StateType const& rowGroup = explorationInformation.getRowGroup(state);
149 if (newUpperValue < boundsPerState[rowGroup].second) {
150 boundsPerState[rowGroup].second = newUpperValue;
151 return true;
152 }
153 return false;
154}
155
156template class Bounds<uint32_t, double>;
157
158} // namespace exploration_detail
159} // namespace modelchecker
160} // namespace storm
void setLowerBoundForRowGroup(StateType const &group, ValueType const &value)
Definition Bounds.cpp:100
ValueType const & getLowerBoundForRowGroup(StateType const &rowGroup) const
Definition Bounds.cpp:32
ValueType getDifferenceOfStateBounds(StateType const &state, ExplorationInformation< StateType, ValueType > const &explorationInformation) const
Definition Bounds.cpp:77
void setBoundsForState(StateType const &state, ExplorationInformation< StateType, ValueType > const &explorationInformation, std::pair< ValueType, ValueType > const &values)
Definition Bounds.cpp:121
std::pair< ValueType, ValueType > getBoundsForState(StateType const &state, ExplorationInformation< StateType, ValueType > const &explorationInformation) const
Definition Bounds.cpp:10
void setBoundsForAction(ActionType const &action, std::pair< ValueType, ValueType > const &values)
Definition Bounds.cpp:116
ValueType const & getUpperBoundForRowGroup(StateType const &rowGroup) const
Definition Bounds.cpp:48
std::pair< ValueType, ValueType > const & getBoundsForAction(ActionType const &action) const
Definition Bounds.cpp:53
bool setLowerBoundOfStateIfGreaterThanOld(StateType const &state, ExplorationInformation< StateType, ValueType > const &explorationInformation, ValueType const &newLowerValue)
Definition Bounds.cpp:133
void initializeBoundsForNextState(std::pair< ValueType, ValueType > const &vals=std::pair< ValueType, ValueType >(storm::utility::zero< ValueType >(), storm::utility::one< ValueType >()))
Definition Bounds.cpp:84
ValueType getLowerBoundForState(StateType const &state, ExplorationInformation< StateType, ValueType > const &explorationInformation) const
Definition Bounds.cpp:21
bool setUpperBoundOfStateIfLessThanOld(StateType const &state, ExplorationInformation< StateType, ValueType > const &explorationInformation, ValueType const &newUpperValue)
Definition Bounds.cpp:145
ValueType const & getBoundForAction(storm::OptimizationDirection const &direction, ActionType const &action) const
Definition Bounds.cpp:68
void setBoundsForRowGroup(StateType const &rowGroup, std::pair< ValueType, ValueType > const &values)
Definition Bounds.cpp:128
void initializeBoundsForNextAction(std::pair< ValueType, ValueType > const &vals=std::pair< ValueType, ValueType >(storm::utility::zero< ValueType >(), storm::utility::one< ValueType >()))
Definition Bounds.cpp:89
ValueType getUpperBoundForState(StateType const &state, ExplorationInformation< StateType, ValueType > const &explorationInformation) const
Definition Bounds.cpp:37
ValueType const & getLowerBoundForAction(ActionType const &action) const
Definition Bounds.cpp:58
void setUpperBoundForState(StateType const &state, ExplorationInformation< StateType, ValueType > const &explorationInformation, ValueType const &value)
Definition Bounds.cpp:105
ValueType const & getUpperBoundForAction(ActionType const &action) const
Definition Bounds.cpp:63
void setLowerBoundForState(StateType const &state, ExplorationInformation< StateType, ValueType > const &explorationInformation, ValueType const &value)
Definition Bounds.cpp:94
void setUpperBoundForRowGroup(StateType const &group, ValueType const &value)
Definition Bounds.cpp:111
LabParser.cpp.
Definition cli.cpp:18