Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
export.h
Go to the documentation of this file.
1#pragma once
2
5#include "storm/io/file.h"
8
9namespace storm {
10namespace api {
11template<typename ValueType>
13 std::string const&) {
14 STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Cannot export non-parametric result.");
15}
16
17template<>
18inline void exportParametricResultToFile(std::optional<storm::RationalFunction> result,
20 std::string const& path) {
21 std::ofstream filestream;
22 storm::io::openFile(path, filestream);
23 if (constraintCollector.has_value()) {
24 filestream << "$Parameters: ";
25 auto const& vars = constraintCollector->getVariables();
26 std::copy(vars.begin(), vars.end(), std::ostream_iterator<storm::RationalFunctionVariable>(filestream, "; "));
27 filestream << '\n';
28 } else {
29 if (result) {
30 filestream << "$Parameters: ";
31 auto const& vars = result->gatherVariables();
32 std::copy(vars.begin(), vars.end(), std::ostream_iterator<storm::RationalFunctionVariable>(filestream, "; "));
33 filestream << '\n';
34 }
35 }
36 if (result) {
37 filestream << "$Result: " << result->toString(false, true) << '\n';
38 }
39 if (constraintCollector.has_value()) {
40 filestream << "$Well-formed Constraints: \n";
41 std::vector<std::string> stringConstraints;
42 std::transform(constraintCollector->getWellformedConstraints().begin(), constraintCollector->getWellformedConstraints().end(),
43 std::back_inserter(stringConstraints),
44 [](carl::Formula<typename storm::Polynomial::PolyType> const& c) -> std::string { return c.toString(); });
45 std::copy(stringConstraints.begin(), stringConstraints.end(), std::ostream_iterator<std::string>(filestream, "\n"));
46 filestream << "$Graph-preserving Constraints: \n";
47 stringConstraints.clear();
48 std::transform(constraintCollector->getGraphPreservingConstraints().begin(), constraintCollector->getGraphPreservingConstraints().end(),
49 std::back_inserter(stringConstraints),
50 [](carl::Formula<typename storm::Polynomial::PolyType> const& c) -> std::string { return c.toString(); });
51 std::copy(stringConstraints.begin(), stringConstraints.end(), std::ostream_iterator<std::string>(filestream, "\n"));
52 }
53 storm::io::closeFile(filestream);
54}
55} // namespace api
56} // 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:12
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