Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DftIOSettings.cpp
Go to the documentation of this file.
1#include "DftIOSettings.h"
2
10
11namespace storm::dft {
12namespace settings {
13namespace modules {
14
15const std::string DftIOSettings::moduleName = "dftIO";
16const std::string DftIOSettings::dftFileOptionName = "dftfile";
17const std::string DftIOSettings::dftFileOptionShortName = "dft";
18const std::string DftIOSettings::dftJsonFileOptionName = "dftfile-json";
19const std::string DftIOSettings::dftJsonFileOptionShortName = "dftjson";
20const std::string DftIOSettings::propExpectedTimeOptionName = "expectedtime";
21const std::string DftIOSettings::propExpectedTimeOptionShortName = "mttf";
22const std::string DftIOSettings::propProbabilityOptionName = "probability";
23const std::string DftIOSettings::propTimeboundOptionName = "timebound";
24const std::string DftIOSettings::propTimepointsOptionName = "timepoints";
25const std::string DftIOSettings::minValueOptionName = "min";
26const std::string DftIOSettings::maxValueOptionName = "max";
27const std::string DftIOSettings::analyzeWithBdds = "bdd";
28const std::string DftIOSettings::minimalCutSets = "mcs";
29const std::string DftIOSettings::exportToJsonOptionName = "export-json";
30const std::string DftIOSettings::exportToSmtOptionName = "export-smt";
31const std::string DftIOSettings::exportToBddDotOptionName = "export-bdd-dot";
32const std::string DftIOSettings::dftStatisticsOptionName = "dft-statistics";
33const std::string DftIOSettings::dftStatisticsOptionShortName = "dftstats";
34const std::string DftIOSettings::importanceMeasureOptionName = "importance";
35
36DftIOSettings::DftIOSettings() : ModuleSettings(moduleName) {
37 this->addOption(
38 storm::settings::OptionBuilder(moduleName, dftFileOptionName, false, "Parses the model given in the Galileo format.")
39 .setShortName(dftFileOptionShortName)
40 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the file from which to read the DFT model.")
42 .build())
43 .build());
44 this->addOption(
45 storm::settings::OptionBuilder(moduleName, dftJsonFileOptionName, false, "Parses the model given in the Cytoscape JSON format.")
46 .setShortName(dftJsonFileOptionShortName)
47 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the JSON file from which to read the DFT model.")
49 .build())
50 .build());
51 this->addOption(storm::settings::OptionBuilder(moduleName, propExpectedTimeOptionName, false, "Compute expected time of system failure.")
52 .setShortName(propExpectedTimeOptionShortName)
53 .build());
54 this->addOption(storm::settings::OptionBuilder(moduleName, propProbabilityOptionName, false, "Compute probability of system failure.").build());
55 this->addOption(storm::settings::OptionBuilder(moduleName, propTimeboundOptionName, false, "Compute probability of system failure up to given timebound.")
56 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("time", "The timebound to use.")
58 .build())
59 .build());
60 this->addOption(storm::settings::OptionBuilder(moduleName, propTimepointsOptionName, false,
61 "Compute probability of system failure up to given timebound for a set of given timepoints [starttime, "
62 "starttime+inc, starttime+2inc, ... ,endtime]")
63 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("starttime", "The timebound to start from.")
65 .build())
66 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("endtime", "The timebound to end with.")
68 .build())
69 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("inc", "The value to increment with to get the next timepoint.")
71 .setDefaultValueDouble(1.0)
72 .makeOptional()
73 .build())
74 .build());
75 this->addOption(storm::settings::OptionBuilder(moduleName, minValueOptionName, false, "Compute minimal value in case of non-determinism.").build());
76 this->addOption(storm::settings::OptionBuilder(moduleName, maxValueOptionName, false, "Compute maximal value in case of non-determinism.").build());
77
78 this->addOption(
79 storm::settings::OptionBuilder(moduleName, analyzeWithBdds, false, "Try to use Bdds for the analysis. Unsupportet properties will be ignored.")
80 .build());
81 this->addOption(storm::settings::OptionBuilder(moduleName, minimalCutSets, false, "Calculate minimal cut sets.").build());
82
83 this->addOption(storm::settings::OptionBuilder(moduleName, exportToJsonOptionName, false, "Export the model to the Cytoscape JSON format.")
84 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the JSON file to export to.").build())
85 .build());
86 this->addOption(storm::settings::OptionBuilder(moduleName, exportToSmtOptionName, false, "Export the model as SMT encoding to the smtlib2 format.")
87 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the smtlib2 file to export to.").build())
88 .build());
89 this->addOption(storm::settings::OptionBuilder(moduleName, exportToBddDotOptionName, false, "Export the model as the graph of a BDD in the dot format.")
90 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the dot file to export to.").build())
91 .build());
92 this->addOption(storm::settings::OptionBuilder(moduleName, dftStatisticsOptionName, false, "Sets whether to display DFT statistics if available.")
93 .setShortName(dftStatisticsOptionShortName)
94 .build());
95 this->addOption(
96 storm::settings::OptionBuilder(moduleName, importanceMeasureOptionName, false, "Calculate importance measures for all basic events in the SFT.")
97 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("measure", "The name of the measure. Valid values: [MIF,DIF,CIF,RAW,RRW]")
98 .addValidatorString(storm::settings::ArgumentValidatorFactory::createMultipleChoiceValidator({"MIF", "DIF", "CIF", "RAW", "RRW"}))
99 .build())
100 .build());
101}
102
104 return this->getOption(dftFileOptionName).getHasOptionBeenSet();
105}
106
107std::string DftIOSettings::getDftFilename() const {
108 return this->getOption(dftFileOptionName).getArgumentByName("filename").getValueAsString();
109}
110
112 return this->getOption(dftJsonFileOptionName).getHasOptionBeenSet();
113}
114
116 return this->getOption(dftJsonFileOptionName).getArgumentByName("filename").getValueAsString();
117}
118
120 return this->getOption(propExpectedTimeOptionName).getHasOptionBeenSet();
121}
122
124 return this->getOption(propProbabilityOptionName).getHasOptionBeenSet();
125}
126
128 return this->getOption(propTimeboundOptionName).getHasOptionBeenSet();
129}
130
132 return this->getOption(propTimeboundOptionName).getArgumentByName("time").getValueAsDouble();
133}
134
136 return this->getOption(propTimepointsOptionName).getHasOptionBeenSet();
137}
138
139std::vector<double> DftIOSettings::getPropTimepoints() const {
140 double starttime = this->getOption(propTimepointsOptionName).getArgumentByName("starttime").getValueAsDouble();
141 double endtime = this->getOption(propTimepointsOptionName).getArgumentByName("endtime").getValueAsDouble();
142 double inc = this->getOption(propTimepointsOptionName).getArgumentByName("inc").getValueAsDouble();
143 std::vector<double> timepoints;
144 for (double time = starttime; time <= endtime; time += inc) {
145 timepoints.push_back(time);
146 }
147 return timepoints;
148}
149
151 return this->getOption(minValueOptionName).getHasOptionBeenSet();
152}
153
155 return this->getOption(maxValueOptionName).getHasOptionBeenSet();
156}
157
159 return this->getOption(analyzeWithBdds).getHasOptionBeenSet();
160}
161
163 return this->getOption(minimalCutSets).getHasOptionBeenSet();
164}
165
167 return this->getOption(exportToJsonOptionName).getHasOptionBeenSet();
168}
169
171 return this->getOption(exportToJsonOptionName).getArgumentByName("filename").getValueAsString();
172}
173
175 return this->getOption(exportToSmtOptionName).getHasOptionBeenSet();
176}
177
179 return this->getOption(exportToSmtOptionName).getArgumentByName("filename").getValueAsString();
180}
181
183 return this->getOption(exportToBddDotOptionName).getHasOptionBeenSet();
184}
185
187 return this->getOption(exportToBddDotOptionName).getArgumentByName("filename").getValueAsString();
188}
189
191 return this->getOption(dftStatisticsOptionName).getHasOptionBeenSet();
192}
193
195 return this->getOption(importanceMeasureOptionName).getHasOptionBeenSet();
196}
197
199 return this->getOption(importanceMeasureOptionName).getArgumentByName("measure").getValueAsString();
200}
201
203
205 // Ensure that at most one of min or max is set
206 STORM_LOG_THROW(!isComputeMinimalValue() || !isComputeMaximalValue(), storm::exceptions::InvalidSettingsException, "Min and max can not both be set.");
207 return true;
208}
209
210} // namespace modules
211} // namespace settings
212} // namespace storm::dft
bool usePropTimepoints() const
Retrieves whether the property timepoints should be used.
void finalize() override
Prepares the modules for further usage, should be called at the end of the initialization,...
DftIOSettings()
Creates a new set of IO settings for DFTs.
bool usePropTimebound() const
Retrieves whether the property timebound should be used.
bool usePropExpectedTime() const
Retrieves whether the property expected time should be used.
bool isDftFileSet() const
Retrieves whether the dft file option was set.
std::string getDftJsonFilename() const
Retrieves the name of the json file that contains the dft specification.
bool isAnalyzeWithBdds() const
Retrieves whether the analyze with Bdds option was set.
bool isMinimalCutSets() const
Retrieves whether the minimal cut sets option was set.
double getPropTimebound() const
Retrieves the timebound for the timebound property.
bool usePropProbability() const
Retrieves whether the property probability should be used.
bool isComputeMaximalValue() const
Retrieves whether the maximal value should be computed for non-determinism.
bool isShowDftStatisticsSet() const
Retrieves whether statistics about the DFT analysis should be displayed.
bool isExportToSmt() const
Retrieves whether the export to smtlib2 file option was set.
bool isDftJsonFileSet() const
Retrieves whether the dft file option for Json was set.
std::string getExportSmtFilename() const
Retrieves the name of the smtlib2 file to export to.
bool isExportToJson() const
Retrieves whether the export to Json file option was set.
std::string getDftFilename() const
Retrieves the name of the file that contains the dft specification.
bool isImportanceMeasureSet() const
Retrieves whether to calculate an importance measure.
bool isComputeMinimalValue() const
Retrieves whether the minimal value should be computed for non-determinism.
bool check() const override
Checks whether the settings are consistent.
std::string getImportanceMeasure() const
Retrieves the name of the importance measure to calculate.
std::vector< double > getPropTimepoints() const
Retrieves the settings for the timepoints property.
std::string getExportBddDotFilename() const
Retrieves the name of the dot file to export to.
bool isExportToBddDot() const
Retrieves whether the export to Bdd Dot file option was set.
std::string getExportJsonFilename() const
Retrieves the name of the json file to export to.
virtual std::string getValueAsString() const =0
Retrieves the value of this argument as a string.
virtual double getValueAsDouble() const =0
Retrieves the value of this argument as a double.
static ArgumentBuilder createDoubleArgument(std::string const &name, std::string const &description)
Creates a double argument with the given parameters.
static ArgumentBuilder createStringArgument(std::string const &name, std::string const &description)
Creates a string argument with the given parameters.
static std::shared_ptr< ArgumentValidator< double > > createDoubleGreaterValidator(double lowerBound)
static std::shared_ptr< ArgumentValidator< double > > createDoubleGreaterEqualValidator(double lowerBound)
static std::shared_ptr< ArgumentValidator< std::string > > createMultipleChoiceValidator(std::vector< std::string > const &choices)
static std::shared_ptr< ArgumentValidator< std::string > > createExistingFileValidator()
This class provides the interface to create an option...
ArgumentBase const & getArgumentByName(std::string const &argumentName) const
Returns a reference to the argument with the specified long name.
Definition Option.cpp:79
bool getHasOptionBeenSet() const
Retrieves whether the option has been set.
Definition Option.cpp:125
void addOption(std::shared_ptr< Option > const &option)
Adds and registers the given option.
Option & getOption(std::string const &longName)
Retrieves the option with the given long name.
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30