Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
storm-gspn.cpp
Go to the documentation of this file.
7
10
11#include "storm/api/storm.h"
12
15
17
18#include <fstream>
19#include <iostream>
20#include <string>
24
25#include <boost/algorithm/string.hpp>
26
28
37
54
57
58 // parse GSPN from file
59 if (!gspnSettings.isGspnFileSet()) {
60 // If no GSPN file is given, nothing needs to be done.
61 return;
62 }
63
64 std::string constantDefinitionString = "";
65 if (gspnSettings.isConstantsSet()) {
66 constantDefinitionString = gspnSettings.getConstantDefinitionString();
67 }
68
69 auto parser = storm::parser::GspnParser();
70 auto gspn = parser.parse(gspnSettings.getGspnFilename(), constantDefinitionString);
71
72 std::string formulaString = "";
75 }
76 boost::optional<std::set<std::string>> propertyFilter;
77 storm::parser::FormulaParser formulaParser(gspn->getExpressionManager());
78 std::vector<storm::jani::Property> properties = storm::api::parseProperties(formulaParser, formulaString, propertyFilter);
79 properties = storm::api::substituteConstantsInProperties(properties, gspn->getConstantsSubstitution());
80
81 if (!gspn->isValid()) {
82 STORM_LOG_ERROR("The GSPN is not valid.");
83 }
84
85 if (gspnSettings.isCapacitiesFileSet()) {
86 auto capacities = storm::api::parseCapacitiesList(gspnSettings.getCapacitiesFilename(), *gspn);
87 gspn->setCapacities(capacities);
88 } else if (gspnSettings.isCapacitySet()) {
89 uint64_t capacity = gspnSettings.getCapacity();
90 std::unordered_map<std::string, uint64_t> capacities;
91 for (auto const& place : gspn->getPlaces()) {
92 capacities.emplace(place.getName(), capacity);
93 }
94 gspn->setCapacities(capacities);
95 }
96
97 storm::api::handleGSPNExportSettings(*gspn, [&](storm::builder::JaniGSPNBuilder const&) { return properties; });
98
99 // // construct ma
100 // auto builder = storm::builder::ExplicitGspnModelBuilder<>();
101 // auto ma = builder.translateGspn(gspn, formula);
102 //
103
104 delete gspn;
105}
106
107int main(const int argc, const char** argv) {
108 try {
109 return storm::cli::process("Storm-GSPN", "storm-gspn", initializeSettings, processOptions, argc, argv);
110 } catch (storm::exceptions::BaseException const& exception) {
111 STORM_LOG_ERROR("An exception caused Storm to terminate. The message of the exception is: " << exception.what());
112 return 1;
113 } catch (std::exception const& exception) {
114 STORM_LOG_ERROR("An unexpected exception occurred and caused Storm to terminate. The message of this exception is: " << exception.what());
115 return 2;
116 }
117}
This class represents the base class of all exception classes.
virtual const char * what() const NOEXCEPT override
Retrieves the message associated with this exception.
void setName(std::string const &name, std::string const &executableName)
Sets the name of the tool.
#define STORM_LOG_ERROR(message)
Definition logging.h:31
std::vector< storm::jani::Property > parseProperties(storm::parser::FormulaParser &formulaParser, std::string const &inputString, boost::optional< std::set< std::string > > const &propertyFilter)
void handleGSPNExportSettings(storm::gspn::GSPN const &gspn, std::function< std::vector< storm::jani::Property >(storm::builder::JaniGSPNBuilder const &)> const &janiProperyGetter)
std::unordered_map< std::string, uint64_t > parseCapacitiesList(std::string const &filename, storm::gspn::GSPN const &gspn)
std::vector< storm::jani::Property > substituteConstantsInProperties(std::vector< storm::jani::Property > const &properties, std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution)
int process(std::string const &name, std::string const &executableName, std::function< void(std::string const &, std::string const &)> initSettingsFunc, std::function< void(void)> processOptionsFunc, const int argc, const char **argv)
Processes the options and returns the exit code.
Definition cli.cpp:81
SettingsType const & getModule()
Get module.
SettingsManager & mutableManager()
Retrieves the settings manager.
void processOptions()
void initializeSettings(std::string const &name, std::string const &executableName)
Initialize the settings manager.
int main(const int argc, const char **argv)