Storm 1.13.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Scheduler.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
7
8namespace storm {
9
10namespace storage {
11
17template<typename ValueType>
18class Scheduler {
19 public:
26 Scheduler(uint_fast64_t numberOfModelStates, boost::optional<storm::storage::MemoryStructure> const& memoryStructure = boost::none);
27 Scheduler(uint_fast64_t numberOfModelStates, boost::optional<storm::storage::MemoryStructure>&& memoryStructure);
28
36 void setChoice(SchedulerChoice<ValueType> const& choice, uint_fast64_t modelState, uint_fast64_t memoryState = 0);
37
41 bool isChoiceSelected(BitVector const& selectedStates, uint64_t memoryState = 0) const;
42
46 bool isChoiceSelected(uint64_t modelState, uint64_t memoryState = 0) const;
47
54 void clearChoice(uint_fast64_t modelState, uint_fast64_t memoryState = 0);
55
62 SchedulerChoice<ValueType> const& getChoice(uint_fast64_t modelState, uint_fast64_t memoryState = 0) const;
63
73 void setDontCare(uint_fast64_t modelState, uint_fast64_t memoryState = 0, bool setArbitraryChoice = true);
74
81 void unSetDontCare(uint_fast64_t modelState, uint_fast64_t memoryState = 0);
82
86 bool isDontCare(uint_fast64_t modelState, uint64_t memoryState = 0) const;
87
91 storm::storage::BitVector computeActionSupport(std::vector<uint64_t> const& nondeterministicChoiceIndicies) const;
92
96 bool isPartialScheduler() const;
97
101 bool isDeterministicScheduler() const;
102
106 bool isMemorylessScheduler() const;
107
111 uint_fast64_t getNumberOfMemoryStates() const;
115 uint_fast64_t getNumberOfModelStates() const;
116
120 boost::optional<storm::storage::MemoryStructure> const& getMemoryStructure() const;
121
127 Scheduler<ValueType> getMemorylessSchedulerForMemoryState(uint64_t memoryState = 0) const;
128
132 template<typename NewValueType>
134 uint_fast64_t numModelStates = schedulerChoices.front().size();
135 Scheduler<NewValueType> newScheduler(numModelStates, memoryStructure);
136 for (uint_fast64_t memState = 0; memState < this->getNumberOfMemoryStates(); ++memState) {
137 for (uint_fast64_t modelState = 0; modelState < numModelStates; ++modelState) {
138 newScheduler.setChoice(getChoice(modelState, memState).template toValueType<NewValueType>(), modelState, memState);
139 }
140 }
141 return newScheduler;
142 }
143
153 void printToStream(std::ostream& out, std::shared_ptr<storm::models::sparse::Model<ValueType>> model = nullptr, bool skipUniqueChoices = false,
154 bool skipDontCareStates = false) const;
155
165 void printJsonToStream(std::ostream& out, std::shared_ptr<storm::models::sparse::Model<ValueType>> model = nullptr, bool skipUniqueChoices = false,
166 bool skipDontCareStates = false) const;
167
168 private:
169 boost::optional<storm::storage::MemoryStructure> memoryStructure;
170 std::vector<std::vector<SchedulerChoice<ValueType>>> schedulerChoices;
171 std::vector<storm::storage::BitVector> dontCareStates;
172 uint_fast64_t numOfUndefinedChoices;
173 uint_fast64_t numOfDeterministicChoices;
174 uint_fast64_t numOfDontCareStates;
175};
176} // namespace storage
177} // namespace storm
Base class for all sparse models.
Definition Model.h:30
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
bool isDeterministicScheduler() const
Retrieves whether all defined choices are deterministic.
storm::storage::BitVector computeActionSupport(std::vector< uint64_t > const &nondeterministicChoiceIndicies) const
Compute the Action Support: A bit vector that indicates all actions that are selected with positive p...
void unSetDontCare(uint_fast64_t modelState, uint_fast64_t memoryState=0)
Unset the combination of model state and memoryStructure state to dontCare.
bool isPartialScheduler() const
Retrieves whether there is a reachable pair of model and memory state for which the choice is undefin...
uint_fast64_t getNumberOfModelStates() const
Retrieves the number of model states this scheduler considers.
SchedulerChoice< ValueType > const & getChoice(uint_fast64_t modelState, uint_fast64_t memoryState=0) const
Gets the choice defined by the scheduler for the given model and memory state.
Definition Scheduler.cpp:94
void clearChoice(uint_fast64_t modelState, uint_fast64_t memoryState=0)
Clears the choice defined by the scheduler for the given state.
Definition Scheduler.cpp:87
bool isDontCare(uint_fast64_t modelState, uint64_t memoryState=0) const
Is the combination of model state and memoryStructure state to reachable?
void setChoice(SchedulerChoice< ValueType > const &choice, uint_fast64_t modelState, uint_fast64_t memoryState=0)
Sets the choice defined by the scheduler for the given state.
Definition Scheduler.cpp:38
void printJsonToStream(std::ostream &out, std::shared_ptr< storm::models::sparse::Model< ValueType > > model=nullptr, bool skipUniqueChoices=false, bool skipDontCareStates=false) const
Prints the scheduler in json format to the given output stream.
boost::optional< storm::storage::MemoryStructure > const & getMemoryStructure() const
Retrieves the memory structure associated with this scheduler.
uint_fast64_t getNumberOfMemoryStates() const
Retrieves the number of memory states this scheduler considers.
void printToStream(std::ostream &out, std::shared_ptr< storm::models::sparse::Model< ValueType > > model=nullptr, bool skipUniqueChoices=false, bool skipDontCareStates=false) const
Prints the scheduler to the given output stream.
Scheduler< ValueType > getMemorylessSchedulerForMemoryState(uint64_t memoryState=0) const
Retrieves a memoryless scheduler that corresponds to the given memory state.
Scheduler< NewValueType > toValueType() const
Returns a copy of this scheduler with the new value type.
Definition Scheduler.h:133
Scheduler(uint_fast64_t numberOfModelStates, boost::optional< storm::storage::MemoryStructure > const &memoryStructure=boost::none)
Initializes a scheduler for the given number of model states.
Definition Scheduler.cpp:16
void setDontCare(uint_fast64_t modelState, uint_fast64_t memoryState=0, bool setArbitraryChoice=true)
Set the combination of model state and memoryStructure state to dontCare.
bool isChoiceSelected(BitVector const &selectedStates, uint64_t memoryState=0) const
Is the scheduler defined on the states indicated by the selected-states bitvector?
Definition Scheduler.cpp:69
bool isMemorylessScheduler() const
Retrieves whether the scheduler considers a trivial memory structure (i.e., a memory structure with j...