Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
NondeterministicModelParser.cpp
Go to the documentation of this file.
2
3#include <string>
4#include <vector>
5
12
13namespace storm {
14namespace parser {
15
16template<typename ValueType, typename RewardValueType>
18NondeterministicModelParser<ValueType, RewardValueType>::parseNondeterministicModel(std::string const& transitionsFilename, std::string const& labelingFilename,
19 std::string const& stateRewardFilename,
20 std::string const& transitionRewardFilename,
21 std::string const& choiceLabelingFilename) {
22 // Parse the transitions.
25
26 uint_fast64_t stateCount = transitions.getColumnCount();
27
28 // Parse the state labeling.
30
31 // Initialize result.
33 std::move(labeling));
34
35 // Only parse state rewards if a file is given.
36 std::optional<std::vector<RewardValueType>> stateRewards;
37 if (!stateRewardFilename.empty()) {
38 stateRewards = std::move(storm::parser::SparseStateRewardParser<RewardValueType>::parseSparseStateReward(stateCount, stateRewardFilename));
39 }
40
41 // Only parse transition rewards if a file is given.
42 std::optional<storm::storage::SparseMatrix<RewardValueType>> transitionRewards;
43 if (!transitionRewardFilename.empty()) {
45 transitionRewardFilename, result.transitionMatrix));
46 }
47
48 if (stateRewards || transitionRewards) {
49 result.rewardModels.insert(std::make_pair(
50 "", storm::models::sparse::StandardRewardModel<RewardValueType>(std::move(stateRewards), std::nullopt, std::move(transitionRewards))));
51 }
52
53 // Only parse choice labeling if a file is given.
54 std::optional<storm::models::sparse::ChoiceLabeling> choiceLabeling;
55 if (!choiceLabelingFilename.empty()) {
56 result.choiceLabeling = storm::parser::SparseItemLabelingParser::parseChoiceLabeling(result.transitionMatrix.getRowCount(), choiceLabelingFilename,
57 result.transitionMatrix.getRowGroupIndices());
58 }
59
60 return result;
61}
62
63template<typename ValueType, typename RewardValueType>
65NondeterministicModelParser<ValueType, RewardValueType>::parseMdp(std::string const& transitionsFilename, std::string const& labelingFilename,
66 std::string const& stateRewardFilename, std::string const& transitionRewardFilename,
67 std::string const& choiceLabelingFilename) {
68 auto parserResult =
69 parseNondeterministicModel(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename, choiceLabelingFilename);
70
72}
73
75
76#ifdef STORM_HAVE_CARL
78#endif
79
80} /* namespace parser */
81} /* namespace storm */
This class represents a (discrete-time) Markov decision process.
Definition Mdp.h:13
This class manages the labeling of the state space with a number of (atomic) labels.
Loads a nondeterministic model (Mdp or Ctmdp) from files.
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="")
Parse a Mdp.
A class providing the functionality to parse the transitions of a nondeterministic model.
static storm::models::sparse::ChoiceLabeling parseChoiceLabeling(uint_fast64_t choiceCount, std::string const &filename, boost::optional< std::vector< uint_fast64_t > > const &nondeterministicChoiceIndices=boost::none)
Parses the given file and returns the resulting choice labeling.
static storm::models::sparse::StateLabeling parseAtomicPropositionLabeling(uint_fast64_t stateCount, std::string const &filename)
Parses the given file and returns the resulting state labeling.
A class providing the functionality to parse a the state rewards of a model.
A class that holds a possibly non-square matrix in the compressed row storage format.