Browse Source

state lookup does not crash when state does not exist

main
Sebastian Junges 4 years ago
parent
commit
42ec9ec60d
  1. 10
      src/storm/builder/ExplicitModelBuilder.cpp
  2. 9
      src/storm/builder/ExplicitModelBuilder.h

10
src/storm/builder/ExplicitModelBuilder.cpp

@ -41,10 +41,18 @@ namespace storm {
template<typename StateType>
StateType ExplicitStateLookup<StateType>::lookup(std::map<storm::expressions::Variable, storm::expressions::Expression> const& stateDescription) const {
auto cs = storm::generator::createCompressedState(this->varInfo, stateDescription, true);
STORM_LOG_THROW(stateToId.contains(cs), storm::exceptions::IllegalArgumentException, "State unknown.");
//TODO search once
if (!stateToId.contains(cs)) {
return static_cast<StateType>(this->size());
}
return this->stateToId.getValue(cs);
}
template<typename StateType>
uint64_t ExplicitStateLookup<StateType>::size() const {
return this->stateToId.size();
}
template <typename ValueType, typename RewardModelType, typename StateType>
ExplicitModelBuilder<ValueType, RewardModelType, StateType>::Options::Options() : explorationOrder(storm::settings::getModule<storm::settings::modules::BuildSettings>().getExplorationOrder()) {
// Intentionally left empty.

9
src/storm/builder/ExplicitModelBuilder.h

@ -53,7 +53,16 @@ namespace storm {
// intentionally left empty.
}
/**
* Lookup state
* @param stateDescription A map describing the state
* @return The id of the state, or size() when no state is found
*/
StateType lookup(std::map<storm::expressions::Variable, storm::expressions::Expression> const& stateDescription) const;
/**
* How many states have been stored?
*/
uint64_t size() const;
private:
VariableInformation varInfo;

Loading…
Cancel
Save