#include "src/parser/DeterministicModelParser.h" #include #include #include "src/models/sparse/StandardRewardModel.h" #include "src/parser/DeterministicSparseTransitionParser.h" #include "src/parser/AtomicPropositionLabelingParser.h" #include "src/parser/SparseStateRewardParser.h" #include "src/adapters/CarlAdapter.h" namespace storm { namespace parser { template typename DeterministicModelParser::Result DeterministicModelParser::parseDeterministicModel(std::string const& transitionsFilename, std::string const& labelingFilename, std::string const& stateRewardFilename, std::string const& transitionRewardFilename) { // Parse the transitions. storm::storage::SparseMatrix transitions(std::move(storm::parser::DeterministicSparseTransitionParser::parseDeterministicTransitions(transitionsFilename))); uint_fast64_t stateCount = transitions.getColumnCount(); // Parse the state labeling. storm::models::sparse::StateLabeling labeling(storm::parser::AtomicPropositionLabelingParser::parseAtomicPropositionLabeling(stateCount, labelingFilename)); // Construct the result. DeterministicModelParser::Result result(std::move(transitions), std::move(labeling)); // Only parse state rewards if a file is given. if (stateRewardFilename != "") { result.stateRewards = storm::parser::SparseStateRewardParser::parseSparseStateReward(stateCount, stateRewardFilename); } // Only parse transition rewards if a file is given. if (transitionRewardFilename != "") { result.transitionRewards = storm::parser::DeterministicSparseTransitionParser::parseDeterministicTransitionRewards(transitionRewardFilename, result.transitionSystem); } return result; } template storm::models::sparse::Dtmc> DeterministicModelParser::parseDtmc(std::string const & transitionsFilename, std::string const & labelingFilename, std::string const& stateRewardFilename, std::string const& transitionRewardFilename) { typename DeterministicModelParser::Result parserResult(std::move(parseDeterministicModel(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename))); std::unordered_map> rewardModels; if (!stateRewardFilename.empty() || !transitionRewardFilename.empty()) { rewardModels.insert(std::make_pair("", storm::models::sparse::StandardRewardModel(parserResult.stateRewards, boost::optional>(), parserResult.transitionRewards))); } return storm::models::sparse::Dtmc>(std::move(parserResult.transitionSystem), std::move(parserResult.labeling), std::move(rewardModels)); } template storm::models::sparse::Ctmc> DeterministicModelParser::parseCtmc(std::string const& transitionsFilename, std::string const& labelingFilename, std::string const& stateRewardFilename, std::string const& transitionRewardFilename) { typename DeterministicModelParser::Result parserResult(std::move(parseDeterministicModel(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename))); std::unordered_map> rewardModels; if (!stateRewardFilename.empty() || !transitionRewardFilename.empty()) { rewardModels.insert(std::make_pair("", storm::models::sparse::StandardRewardModel(parserResult.stateRewards, boost::optional>(), parserResult.transitionRewards))); } return storm::models::sparse::Ctmc>(std::move(parserResult.transitionSystem), std::move(parserResult.labeling), std::move(rewardModels), boost::optional>>()); } template class DeterministicModelParser; #ifdef STORM_HAVE_CARL template class DeterministicModelParser; #endif } /* namespace parser */ } /* namespace storm */