Storm
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
49 void clearChoice(uint_fast64_t modelState, uint_fast64_t memoryState = 0);
50
57 SchedulerChoice<ValueType> const& getChoice(uint_fast64_t modelState, uint_fast64_t memoryState = 0) const;
58
68 void setDontCare(uint_fast64_t modelState, uint_fast64_t memoryState = 0, bool setArbitraryChoice = true);
69
76 void unSetDontCare(uint_fast64_t modelState, uint_fast64_t memoryState = 0);
77
81 bool isDontCare(uint_fast64_t modelState, uint64_t memoryState = 0) const;
82
86 storm::storage::BitVector computeActionSupport(std::vector<uint64_t> const& nondeterministicChoiceIndicies) const;
87
91 bool isPartialScheduler() const;
92
96 bool isDeterministicScheduler() const;
97
101 bool isMemorylessScheduler() const;
102
106 uint_fast64_t getNumberOfMemoryStates() const;
107
111 boost::optional<storm::storage::MemoryStructure> const& getMemoryStructure() const;
112
116 template<typename NewValueType>
118 uint_fast64_t numModelStates = schedulerChoices.front().size();
119 Scheduler<NewValueType> newScheduler(numModelStates, memoryStructure);
120 for (uint_fast64_t memState = 0; memState < this->getNumberOfMemoryStates(); ++memState) {
121 for (uint_fast64_t modelState = 0; modelState < numModelStates; ++modelState) {
122 newScheduler.setChoice(getChoice(modelState, memState).template toValueType<NewValueType>(), modelState, memState);
123 }
124 }
125 return newScheduler;
126 }
127
137 void printToStream(std::ostream& out, std::shared_ptr<storm::models::sparse::Model<ValueType>> model = nullptr, bool skipUniqueChoices = false,
138 bool skipDontCareStates = false) const;
139
149 void printJsonToStream(std::ostream& out, std::shared_ptr<storm::models::sparse::Model<ValueType>> model = nullptr, bool skipUniqueChoices = false,
150 bool skipDontCareStates = false) const;
151
152 private:
153 boost::optional<storm::storage::MemoryStructure> memoryStructure;
154 std::vector<std::vector<SchedulerChoice<ValueType>>> schedulerChoices;
155 std::vector<storm::storage::BitVector> dontCareStates;
156 uint_fast64_t numOfUndefinedChoices;
157 uint_fast64_t numOfDeterministicChoices;
158 uint_fast64_t numOfDontCareStates;
159};
160} // namespace storage
161} // namespace storm
Base class for all sparse models.
Definition Model.h:33
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
This class defines which action is chosen in a particular state of a non-deterministic model.
Definition Scheduler.h:18
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...
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:86
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:79
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:37
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< NewValueType > toValueType() const
Returns a copy of this scheduler with the new value type.
Definition Scheduler.h:117
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.
Definition Scheduler.cpp:93
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:68
bool isMemorylessScheduler() const
Retrieves whether the scheduler considers a trivial memory structure (i.e., a memory structure with j...
LabParser.cpp.
Definition cli.cpp:18