Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
export.h
Go to the documentation of this file.
3#include "storm/io/file.h"
6
7namespace storm {
8namespace api {
9template<typename ValueType>
11 std::string const&) {
12 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Cannot export non-parametric result.");
13}
14
15template<>
16inline void exportParametricResultToFile(std::optional<storm::RationalFunction> result,
18 std::string const& path) {
19 std::ofstream filestream;
20 storm::io::openFile(path, filestream);
21 if (constraintCollector.has_value()) {
22 filestream << "$Parameters: ";
23 auto const& vars = constraintCollector->getVariables();
24 std::copy(vars.begin(), vars.end(), std::ostream_iterator<storm::RationalFunctionVariable>(filestream, "; "));
25 filestream << '\n';
26 } else {
27 if (result) {
28 filestream << "$Parameters: ";
29 auto const& vars = result->gatherVariables();
30 std::copy(vars.begin(), vars.end(), std::ostream_iterator<storm::RationalFunctionVariable>(filestream, "; "));
31 filestream << '\n';
32 }
33 }
34 if (result) {
35 filestream << "$Result: " << result->toString(false, true) << '\n';
36 }
37 if (constraintCollector.has_value()) {
38 filestream << "$Well-formed Constraints: \n";
39 std::vector<std::string> stringConstraints;
40 std::transform(constraintCollector->getWellformedConstraints().begin(), constraintCollector->getWellformedConstraints().end(),
41 std::back_inserter(stringConstraints),
42 [](carl::Formula<typename storm::Polynomial::PolyType> const& c) -> std::string { return c.toString(); });
43 std::copy(stringConstraints.begin(), stringConstraints.end(), std::ostream_iterator<std::string>(filestream, "\n"));
44 filestream << "$Graph-preserving Constraints: \n";
45 stringConstraints.clear();
46 std::transform(constraintCollector->getGraphPreservingConstraints().begin(), constraintCollector->getGraphPreservingConstraints().end(),
47 std::back_inserter(stringConstraints),
48 [](carl::Formula<typename storm::Polynomial::PolyType> const& c) -> std::string { return c.toString(); });
49 std::copy(stringConstraints.begin(), stringConstraints.end(), std::ostream_iterator<std::string>(filestream, "\n"));
50 }
51 storm::io::closeFile(filestream);
52}
53} // namespace api
54} // namespace storm
Helper class that optionally holds a reference to an object of type T.
Definition OptionalRef.h:48
Class to collect constraints on parametric Markov chains.
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
void exportParametricResultToFile(std::optional< ValueType >, storm::OptionalRef< storm::analysis::ConstraintCollector< ValueType > const > const &, std::string const &)
Definition export.h:10
void closeFile(std::ofstream &stream)
Close the given file after writing.
Definition file.h:47
void openFile(std::string const &filepath, std::ofstream &filestream, bool append=false, bool silent=false)
Open the given file for writing.
Definition file.h:18
LabParser.cpp.
Definition cli.cpp:18