Storm
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
7
11
14
15namespace storm {
16namespace parser {
17
18template<typename ValueType, typename RewardValueType>
20NondeterministicModelParser<ValueType, RewardValueType>::parseNondeterministicModel(std::string const& transitionsFilename, std::string const& labelingFilename,
21 std::string const& stateRewardFilename,
22 std::string const& transitionRewardFilename,
23 std::string const& choiceLabelingFilename) {
24 // Parse the transitions.
27
28 uint_fast64_t stateCount = transitions.getColumnCount();
29
30 // Parse the state labeling.
32
33 // Initialize result.
35 std::move(labeling));
36
37 // Only parse state rewards if a file is given.
38 std::optional<std::vector<RewardValueType>> stateRewards;
39 if (!stateRewardFilename.empty()) {
40 stateRewards = std::move(storm::parser::SparseStateRewardParser<RewardValueType>::parseSparseStateReward(stateCount, stateRewardFilename));
41 }
42
43 // Only parse transition rewards if a file is given.
44 std::optional<storm::storage::SparseMatrix<RewardValueType>> transitionRewards;
45 if (!transitionRewardFilename.empty()) {
47 transitionRewardFilename, result.transitionMatrix));
48 }
49
50 if (stateRewards || transitionRewards) {
51 result.rewardModels.insert(std::make_pair(
52 "", storm::models::sparse::StandardRewardModel<RewardValueType>(std::move(stateRewards), std::nullopt, std::move(transitionRewards))));
53 }
54
55 // Only parse choice labeling if a file is given.
56 std::optional<storm::models::sparse::ChoiceLabeling> choiceLabeling;
57 if (!choiceLabelingFilename.empty()) {
58 result.choiceLabeling = storm::parser::SparseItemLabelingParser::parseChoiceLabeling(result.transitionMatrix.getRowCount(), choiceLabelingFilename,
59 result.transitionMatrix.getRowGroupIndices());
60 }
61
62 return result;
63}
64
65template<typename ValueType, typename RewardValueType>
67NondeterministicModelParser<ValueType, RewardValueType>::parseMdp(std::string const& transitionsFilename, std::string const& labelingFilename,
68 std::string const& stateRewardFilename, std::string const& transitionRewardFilename,
69 std::string const& choiceLabelingFilename) {
70 auto parserResult =
71 parseNondeterministicModel(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename, choiceLabelingFilename);
72
74}
75
77
78#ifdef STORM_HAVE_CARL
80#endif
81
82} /* namespace parser */
83} /* namespace storm */
This class represents a (discrete-time) Markov decision process.
Definition Mdp.h:14
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.
LabParser.cpp.
Definition cli.cpp:18