17 bool onlyInitialStatesRelevant)
20 stateLabeling(numberOfMemoryStates),
21 initialMemoryStates(onlyInitialStatesRelevant ? model.getInitialStates().getNumberOfSetBits() : model.getNumberOfStates(), 0),
22 onlyInitialStatesRelevant(onlyInitialStatesRelevant) {
39 STORM_LOG_THROW(!onlyInitialStatesRelevant || model.getInitialStates().get(initialModelState), storm::exceptions::InvalidOperationException,
40 "Invalid index of initial model state: " << initialMemoryState <<
". This is not an initial state of the model.");
42 initialMemoryState < transitions.size(), storm::exceptions::InvalidOperationException,
43 "Invalid index of initial memory state: " << initialMemoryState <<
". There are only " << transitions.size() <<
" states in this memory structure.");
45 auto initMemStateIt = initialMemoryStates.begin();
47 if (onlyInitialStatesRelevant) {
48 for (
auto initState : model.getInitialStates()) {
49 if (initState == initialModelState) {
50 *initMemStateIt = initialMemoryState;
57 for (uint_fast64_t state = 0; state < model.getNumberOfStates(); ++state) {
58 if (state == initialModelState) {
59 *initMemStateIt = initialMemoryState;
66 assert(initMemStateIt != initialMemoryStates.end());
72 boost::optional<storm::storage::BitVector>
const& modelChoices) {
73 auto const& modelTransitions = model.getTransitionMatrix();
75 STORM_LOG_THROW(startState < transitions.size(), storm::exceptions::InvalidOperationException,
76 "Invalid index of start state: " << startState <<
". There are only " << transitions.size() <<
" states in this memory structure.");
77 STORM_LOG_THROW(goalState < transitions.size(), storm::exceptions::InvalidOperationException,
78 "Invalid index of goal state: " << startState <<
". There are only " << transitions.size() <<
" states in this memory structure.");
79 STORM_LOG_THROW(modelStates.
size() == modelTransitions.getRowGroupCount(), storm::exceptions::InvalidOperationException,
80 "The modelStates have invalid size.");
81 STORM_LOG_THROW(!modelChoices || modelChoices->size() == modelTransitions.getRowGroupCount(), storm::exceptions::InvalidOperationException,
82 "The modelChoices have invalid size.");
88 for (
auto choice : modelChoices.get()) {
89 for (
auto entryIt = modelTransitions.getRow(choice).begin(); entryIt < modelTransitions.getRow(choice).end(); ++entryIt) {
90 if (modelStates.
get(entryIt->getColumn())) {
91 transitionVector.
set(entryIt - modelTransitions.begin());
96 for (uint_fast64_t choice = 0; choice < modelTransitions.getRowCount(); ++choice) {
97 for (
auto entryIt = modelTransitions.getRow(choice).begin(); entryIt < modelTransitions.getRow(choice).end(); ++entryIt) {
98 if (modelStates.
get(entryIt->getColumn())) {
99 transitionVector.
set(entryIt - modelTransitions.begin());
106 if (transitionVector.
empty()) {
107 transitions[startState][goalState] = boost::none;
109 transitions[startState][goalState] = std::move(transitionVector);
MemoryStructureBuilder(uint_fast64_t numberOfMemoryStates, storm::models::sparse::Model< ValueType, RewardModelType > const &model, bool onlyInitialStatesRelevant=true)
Initializes a new builder with the data from the provided memory structure.
void setTransition(uint_fast64_t const &startState, uint_fast64_t const &goalState, storm::storage::BitVector const &modelStates, boost::optional< storm::storage::BitVector > const &modelChoices=boost::none)
Specifies a transition of the memory structure.