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
11
12namespace storm {
13namespace parser {
14
15template<typename ValueType, typename RewardValueType>
17NondeterministicModelParser<ValueType, RewardValueType>::parseNondeterministicModel(std::string const& transitionsFilename, std::string const& labelingFilename,
18 std::string const& stateRewardFilename,
19 std::string const& transitionRewardFilename,
20 std::string const& choiceLabelingFilename) {
21 // Parse the transitions.
24
25 uint_fast64_t stateCount = transitions.getColumnCount();
26
27 // Parse the state labeling.
29
30 // Initialize result.
32 std::move(labeling));
33
34 // Only parse state rewards if a file is given.
35 std::optional<std::vector<RewardValueType>> stateRewards;
36 if (!stateRewardFilename.empty()) {
37 stateRewards = std::move(storm::parser::SparseStateRewardParser<RewardValueType>::parseSparseStateReward(stateCount, stateRewardFilename));
38 }
39
40 // Only parse transition rewards if a file is given.
41 std::optional<storm::storage::SparseMatrix<RewardValueType>> transitionRewards;
42 if (!transitionRewardFilename.empty()) {
44 transitionRewardFilename, result.transitionMatrix));
45 }
46
47 if (stateRewards || transitionRewards) {
48 result.rewardModels.insert(std::make_pair(
49 "", storm::models::sparse::StandardRewardModel<RewardValueType>(std::move(stateRewards), std::nullopt, std::move(transitionRewards))));
50 }
51
52 // Only parse choice labeling if a file is given.
53 std::optional<storm::models::sparse::ChoiceLabeling> choiceLabeling;
54 if (!choiceLabelingFilename.empty()) {
55 result.choiceLabeling = storm::parser::SparseItemLabelingParser::parseChoiceLabeling(result.transitionMatrix.getRowCount(), choiceLabelingFilename,
56 result.transitionMatrix.getRowGroupIndices());
57 }
58
59 return result;
60}
61
62template<typename ValueType, typename RewardValueType>
64NondeterministicModelParser<ValueType, RewardValueType>::parseMdp(std::string const& transitionsFilename, std::string const& labelingFilename,
65 std::string const& stateRewardFilename, std::string const& transitionRewardFilename,
66 std::string const& choiceLabelingFilename) {
67 auto parserResult =
68 parseNondeterministicModel(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename, choiceLabelingFilename);
69
71}
72
75
76} /* namespace parser */
77} /* 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.