Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DeterministicModelParser.cpp
Go to the documentation of this file.
2
3#include <string>
4#include <vector>
5
7
11
13
14namespace storm {
15namespace parser {
16
17template<typename ValueType, typename RewardValueType>
19DeterministicModelParser<ValueType, RewardValueType>::parseDeterministicModel(std::string const& transitionsFilename, std::string const& labelingFilename,
20 std::string const& stateRewardFilename,
21 std::string const& transitionRewardFilename,
22 std::string const& choiceLabelingFilename) {
23 // Parse the transitions.
26
27 uint_fast64_t stateCount = transitions.getColumnCount();
28
29 // Parse the state labeling.
31
32 // Construct the result.
34 std::move(labeling));
35
36 // Only parse state rewards if a file is given.
37 std::optional<std::vector<RewardValueType>> stateRewards;
38 if (stateRewardFilename != "") {
39 stateRewards = storm::parser::SparseStateRewardParser<RewardValueType>::parseSparseStateReward(stateCount, stateRewardFilename);
40 }
41
42 // Only parse transition rewards if a file is given.
43 std::optional<storm::storage::SparseMatrix<RewardValueType>> transitionRewards;
44 if (transitionRewardFilename != "") {
46 result.transitionMatrix);
47 }
48
49 if (stateRewards || transitionRewards) {
50 result.rewardModels.insert(std::make_pair(
51 "", storm::models::sparse::StandardRewardModel<RewardValueType>(std::move(stateRewards), std::nullopt, std::move(transitionRewards))));
52 }
53
54 // Only parse choice labeling if a file is given.
55 std::optional<storm::models::sparse::ChoiceLabeling> choiceLabeling;
56 if (!choiceLabelingFilename.empty()) {
57 result.choiceLabeling = storm::parser::SparseItemLabelingParser::parseChoiceLabeling(result.transitionMatrix.getRowCount(), choiceLabelingFilename);
58 }
59
60 return result;
61}
62
63template<typename ValueType, typename RewardValueType>
65DeterministicModelParser<ValueType, RewardValueType>::parseDtmc(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 = parseDeterministicModel(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename, choiceLabelingFilename);
70}
71
72template<typename ValueType, typename RewardValueType>
74DeterministicModelParser<ValueType, RewardValueType>::parseCtmc(std::string const& transitionsFilename, std::string const& labelingFilename,
75 std::string const& stateRewardFilename, std::string const& transitionRewardFilename,
76 std::string const& choiceLabelingFilename) {
77 auto parserResult = parseDeterministicModel(transitionsFilename, labelingFilename, stateRewardFilename, transitionRewardFilename, choiceLabelingFilename);
78 parserResult.rateTransitions = true;
80}
81
83
84#ifdef STORM_HAVE_CARL
86#endif
87
88} /* namespace parser */
89} /* namespace storm */
This class represents a continuous-time Markov chain.
Definition Ctmc.h:15
This class represents a discrete-time Markov chain.
Definition Dtmc.h:14
This class manages the labeling of the state space with a number of (atomic) labels.
Loads a deterministic model (Dtmc or Ctmc) from files.
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="")
Parse a Ctmc.
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="")
Parse a Dtmc.
This class can be used to parse a file containing either transitions or transition rewards of a deter...
static storm::storage::SparseMatrix< ValueType > parseDeterministicTransitionRewards(std::string const &filename, storm::storage::SparseMatrix< MatrixValueType > const &transitionMatrix)
Load the transition rewards for a deterministic transition system from file and create a sparse adjac...
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.
static std::vector< ValueType > parseSparseStateReward(uint_fast64_t stateCount, std::string const &filename)
Reads a state reward file and puts the result in a state reward vector.
A class that holds a possibly non-square matrix in the compressed row storage format.
LabParser.cpp.
Definition cli.cpp:18