Storm 1.14.0.1
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 gspn = storm::parser::GspnParser::parse(gspnSettings.getGspnFilename(), constantDefinitionString);
70
71 std::string formulaString = "";
74 }
75 boost::optional<std::set<std::string>> propertyFilter;
76 storm::parser::FormulaParser formulaParser(gspn->getExpressionManager());
77 std::vector<storm::jani::Property> properties = storm::api::parseProperties(formulaParser, formulaString, propertyFilter);
78 properties = storm::api::substituteConstantsInProperties(properties, gspn->getConstantsSubstitution());
79
80 if (!gspn->isValid()) {
81 STORM_LOG_ERROR("The GSPN is not valid.");
82 }
83
84 if (gspnSettings.isCapacitiesFileSet()) {
85 auto capacities = storm::api::parseCapacitiesList(gspnSettings.getCapacitiesFilename(), *gspn);
86 gspn->setCapacities(capacities);
87 } else if (gspnSettings.isCapacitySet()) {
88 uint64_t capacity = gspnSettings.getCapacity();
89 std::unordered_map<std::string, uint64_t> capacities;
90 for (auto const& place : gspn->getPlaces()) {
91 capacities.emplace(place.getName(), capacity);
92 }
93 gspn->setCapacities(capacities);
94 }
95
96 storm::api::handleGSPNExportSettings(*gspn, [&](storm::builder::JaniGSPNBuilder const&) { return properties; });
97
98 // // construct ma
99 // auto builder = storm::builder::ExplicitGspnModelBuilder<>();
100 // auto ma = builder.translateGspn(gspn, formula);
101 //
102
103 delete gspn;
104}
105
106int main(const int argc, const char** argv) {
107 try {
108 return storm::cli::process("Storm-GSPN", "storm-gspn", initializeSettings, processOptions, argc, argv);
109 } catch (storm::exceptions::BaseException const& exception) {
110 STORM_LOG_ERROR("An exception caused Storm to terminate. The message of the exception is: " << exception.what());
111 return 1;
112 } catch (std::exception const& exception) {
113 STORM_LOG_ERROR("An unexpected exception occurred and caused Storm to terminate. The message of this exception is: " << exception.what());
114 return 2;
115 }
116}
This class represents the base class of all exception classes.
virtual const char * what() const noexcept override
Retrieves the message associated with this exception.
static storm::gspn::GSPN * parse(std::string const &filename, std::string const &constantDefinitions="")
void setName(std::string const &name, std::string const &executableName)
Sets the name of the tool.
#define STORM_LOG_ERROR(message)
Definition logging.h:29
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:96
SettingsType const & getModule()
Get module.
void addModule(bool doRegister=true)
Add new module to use for the settings.
SettingsManager & mutableManager()
Retrieves the settings manager.
void processOptions()
Definition storm-cli.cpp:17
void processOptions()
void initializeSettings(std::string const &name, std::string const &executableName)
Initialize the settings manager.
int main(const int argc, const char **argv)