16using namespace storm::utility::cstring;
18template<
typename ValueType,
typename RewardValueType>
19std::shared_ptr<storm::models::sparse::Model<ValueType, storm::models::sparse::StandardRewardModel<RewardValueType>>>
21 std::string
const& stateRewardFilename, std::string
const& transitionRewardFilename,
27 std::shared_ptr<storm::models::sparse::Model<ValueType, storm::models::sparse::StandardRewardModel<RewardValueType>>> model;
30 model = std::shared_ptr<storm::models::sparse::Model<ValueType, storm::models::sparse::StandardRewardModel<RewardValueType>>>(
33 transitionRewardFilename, choiceLabelingFilename, options))));
37 model = std::shared_ptr<storm::models::sparse::Model<ValueType, storm::models::sparse::StandardRewardModel<RewardValueType>>>(
40 transitionRewardFilename, choiceLabelingFilename, options))));
44 model = std::shared_ptr<storm::models::sparse::Model<ValueType, storm::models::sparse::StandardRewardModel<RewardValueType>>>(
47 transitionRewardFilename, choiceLabelingFilename, options))));
51 model = std::shared_ptr<storm::models::sparse::Model<ValueType, storm::models::sparse::StandardRewardModel<RewardValueType>>>(
54 transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename, choiceLabelingFilename, options))));
58 STORM_LOG_WARN(
"Unknown/Unhandled Model Type which cannot be parsed.");
64template<
typename ValueType,
typename RewardValueType>
71 STORM_LOG_THROW(file.getDataSize() >= hintLength, storm::exceptions::WrongFormatException,
"File too short to be readable.");
72 char const* fileData = file.getData();
74 char filehintBuffer[hintLength + 1];
75 memcpy(filehintBuffer, fileData, hintLength);
76 filehintBuffer[hintLength] = 0;
79 char hint[hintLength + 1] = {};
80 static_assert(hintLength == 10,
"sscanf format width must match the hint length");
81 constexpr const char* hintFormat =
"%10s";
82 sscanf(filehintBuffer, hintFormat, hint);
84 for (
char* c = hint; *c !=
'\0'; c++) {
89 if (strcmp(hint,
"DTMC") == 0) {
91 }
else if (strcmp(hint,
"CTMC") == 0) {
93 }
else if (strcmp(hint,
"MDP") == 0) {
95 }
else if (strcmp(hint,
"MA") == 0) {
98 STORM_LOG_THROW(
false, storm::exceptions::WrongFormatException,
"Unable to find model hint in explicit input.");
This class represents a continuous-time Markov chain.
This class represents a discrete-time Markov chain.
This class represents a Markov automaton.
This class represents a (discrete-time) Markov decision process.
This class automatically chooses the correct parser for the given files and returns the corresponding...
static std::shared_ptr< storm::models::sparse::Model< ValueType, storm::models::sparse::StandardRewardModel< RewardValueType > > > parseModel(std::string const &transitionsFilename, std::string const &labelingFilename, std::string const &stateRewardFilename="", std::string const &transitionRewardFilename="", std::string const &choiceLabelingFilename="", ExplicitModelParserOptions const &options=ExplicitModelParserOptions())
Checks the given files and parses the model within these files.
static storm::models::sparse::Dtmc< ValueType, storm::models::sparse::StandardRewardModel< RewardValueType > > parseDtmc(std::string const &transitionsFilename, std::string const &labelingFilename, std::string const &stateRewardFilename="", std::string const &transitionRewardFilename="", std::string const &choiceLabelingFilename="", ExplicitModelParserOptions const &options=ExplicitModelParserOptions())
Parse a Dtmc.
static storm::models::sparse::Ctmc< ValueType, storm::models::sparse::StandardRewardModel< RewardValueType > > parseCtmc(std::string const &transitionsFilename, std::string const &labelingFilename, std::string const &stateRewardFilename="", std::string const &transitionRewardFilename="", std::string const &choiceLabelingFilename="", ExplicitModelParserOptions const &options=ExplicitModelParserOptions())
Parse a Ctmc.
Opens a file and maps it to memory providing a char* containing the file content.
static storm::models::sparse::MarkovAutomaton< ValueType, storm::models::sparse::StandardRewardModel< RewardValueType > > parseMarkovAutomaton(std::string const &transitionsFilename, std::string const &labelingFilename, std::string const &stateRewardFilename="", std::string const &transitionRewardFilename="", std::string const &choiceLabelingFilename="", ExplicitModelParserOptions const &options=ExplicitModelParserOptions())
Parses the given Markov automaton and returns an object representing the automaton.
static storm::models::sparse::Mdp< ValueType, storm::models::sparse::StandardRewardModel< RewardValueType > > parseMdp(std::string const &transitionsFilename, std::string const &labelingFilename, std::string const &stateRewardFilename="", std::string const &transitionRewardFilename="", std::string const &choiceLabelingFilename="", ExplicitModelParserOptions const &options=ExplicitModelParserOptions())
Parse a Mdp.
#define STORM_LOG_WARN(message)
#define STORM_LOG_THROW(cond, exception, message)
Contains all file parsers and helper classes.