Storm 1.13.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Umb.cpp
Go to the documentation of this file.
2
9
10namespace storm::umb {
11
12namespace detail {
13void warnNonStandardFiles(UmbModel const& umb, std::filesystem::path const& location) {
14 for (auto const& [filename, data] : umb.nonStandardFiles) {
15 STORM_LOG_WARN("UMB file " << location << " contains unexpected file " << filename << " (" << data.size() << " bytes).");
16 }
17 STORM_LOG_WARN_COND(umb.nonStandardFiles.empty(), "Unexpected file(s) found in " << location << ". These will be ignored in model import/export.");
18}
19} // namespace detail
20
21template<typename ValueType>
22std::shared_ptr<storm::models::sparse::Model<ValueType>> buildModelFromUmb(std::filesystem::path const& umbLocation, ImportOptions const& options) {
23 auto umb = storm::umb::importUmb(umbLocation, options);
24 STORM_LOG_INFO("Imported UMB model:\n" << umb.getModelInformation());
27}
28
29std::shared_ptr<storm::models::ModelBase> buildModelFromUmb(std::filesystem::path const& umbLocation, ImportOptions const& options) {
30 auto umb = storm::umb::importUmb(umbLocation, options);
31 STORM_LOG_INFO("Imported UMB model:\n" << umb.getModelInformation());
33 return storm::umb::sparseModelFromUmb(umb, options);
34}
35
36template<typename ValueType>
37void exportModelToUmb(storm::models::sparse::Model<ValueType> const& model, std::filesystem::path const& targetLocation, ExportOptions const& options) {
38 auto umb = storm::umb::sparseModelToUmb(model, options);
39 detail::warnNonStandardFiles(umb, targetLocation);
40 umb.encodeRationals(); // Ensure rationals are encoded in their right bit representation before export
41 STORM_LOG_INFO("Exporting UMB model:\n" << umb.getModelInformation());
42 storm::umb::toArchive(umb, targetLocation, options);
43}
44
45template std::shared_ptr<storm::models::sparse::Model<double>> buildModelFromUmb(std::filesystem::path const&, ImportOptions const&);
46template std::shared_ptr<storm::models::sparse::Model<storm::RationalNumber>> buildModelFromUmb(std::filesystem::path const&, ImportOptions const&);
47template std::shared_ptr<storm::models::sparse::Model<storm::Interval>> buildModelFromUmb(std::filesystem::path const&, ImportOptions const&);
48template std::shared_ptr<storm::models::sparse::Model<storm::RationalInterval>> buildModelFromUmb(std::filesystem::path const&, ImportOptions const&);
49
50template void exportModelToUmb(storm::models::sparse::Model<double> const&, std::filesystem::path const&, ExportOptions const&);
51template void exportModelToUmb(storm::models::sparse::Model<storm::RationalNumber> const&, std::filesystem::path const&, ExportOptions const&);
52template void exportModelToUmb(storm::models::sparse::Model<storm::Interval> const&, std::filesystem::path const&, ExportOptions const&);
53template void exportModelToUmb(storm::models::sparse::Model<storm::RationalInterval> const&, std::filesystem::path const&, ExportOptions const&);
54
55} // namespace storm::umb
Base class for all sparse models.
Definition Model.h:30
Represents a model in the UMB format.
Definition UmbModel.h:21
#define STORM_LOG_INFO(message)
Definition logging.h:24
#define STORM_LOG_WARN(message)
Definition logging.h:25
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:38
void warnNonStandardFiles(UmbModel const &umb, std::filesystem::path const &location)
Definition Umb.cpp:13
std::shared_ptr< storm::models::sparse::Model< ValueType > > buildModelFromUmb(std::filesystem::path const &umbLocation, ImportOptions const &options)
Definition Umb.cpp:22
storm::umb::UmbModel importUmb(std::filesystem::path const &umbLocation, ImportOptions const &options)
void toArchive(storm::umb::UmbModel const &umbModel, std::filesystem::path const &archivePath, ExportOptions const &options)
std::shared_ptr< storm::models::sparse::Model< ValueType > > sparseModelFromUmb(storm::umb::UmbModel const &umbModel, ImportOptions const &options)
Constructs a sparse model from the given UMB model.
storm::umb::UmbModel sparseModelToUmb(storm::models::sparse::Model< ValueType > const &model, ExportOptions const &options)
void exportModelToUmb(storm::models::sparse::Model< ValueType > const &model, std::filesystem::path const &targetLocation, ExportOptions const &options)
Definition Umb.cpp:37