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";
35const std::string DftIOSettings::variableOrderingFileOptionName = "be-order";
36
37DftIOSettings::DftIOSettings() : ModuleSettings(moduleName) {
38 this->addOption(
39 storm::settings::OptionBuilder(moduleName, dftFileOptionName, false, "Parses the model given in the Galileo format.")
40 .setShortName(dftFileOptionShortName)
41 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the file from which to read the DFT model.")
43 .build())
44 .build());
45 this->addOption(
46 storm::settings::OptionBuilder(moduleName, dftJsonFileOptionName, false, "Parses the model given in the Cytoscape JSON format.")
47 .setShortName(dftJsonFileOptionShortName)
48 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the JSON file from which to read the DFT model.")
50 .build())
51 .build());
52 this->addOption(storm::settings::OptionBuilder(moduleName, propExpectedTimeOptionName, false, "Compute expected time of system failure.")
53 .setShortName(propExpectedTimeOptionShortName)
54 .build());
55 this->addOption(storm::settings::OptionBuilder(moduleName, propProbabilityOptionName, false, "Compute probability of system failure.").build());
56 this->addOption(storm::settings::OptionBuilder(moduleName, propTimeboundOptionName, false, "Compute probability of system failure up to given timebound.")
57 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("time", "The timebound to use.")
59 .build())
60 .build());
61 this->addOption(storm::settings::OptionBuilder(moduleName, propTimepointsOptionName, false,
62 "Compute probability of system failure up to given timebound for a set of given timepoints [starttime, "
63 "starttime+inc, starttime+2inc, ... ,endtime]")
64 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("starttime", "The timebound to start from.")
66 .build())
67 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("endtime", "The timebound to end with.")
69 .build())
70 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("inc", "The value to increment with to get the next timepoint.")
72 .setDefaultValueDouble(1.0)
73 .makeOptional()
74 .build())
75 .build());
76 this->addOption(storm::settings::OptionBuilder(moduleName, minValueOptionName, false, "Compute minimal value in case of non-determinism.").build());
77 this->addOption(storm::settings::OptionBuilder(moduleName, maxValueOptionName, false, "Compute maximal value in case of non-determinism.").build());
78
79 this->addOption(
80 storm::settings::OptionBuilder(moduleName, analyzeWithBdds, false, "Try to use Bdds for the analysis. Unsupportet properties will be ignored.")
81 .build());
82 this->addOption(storm::settings::OptionBuilder(moduleName, minimalCutSets, false, "Calculate minimal cut sets.").build());
83
84 this->addOption(storm::settings::OptionBuilder(moduleName, exportToJsonOptionName, false, "Export the model to the Cytoscape JSON format.")
85 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the JSON file to export to.").build())
86 .build());
87 this->addOption(storm::settings::OptionBuilder(moduleName, exportToSmtOptionName, false, "Export the model as SMT encoding to the smtlib2 format.")
88 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the smtlib2 file to export to.").build())
89 .build());
90 this->addOption(storm::settings::OptionBuilder(moduleName, exportToBddDotOptionName, false, "Export the model as the graph of a BDD in the dot format.")
91 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the dot file to export to.").build())
92 .build());
93 this->addOption(storm::settings::OptionBuilder(moduleName, dftStatisticsOptionName, false, "Sets whether to display DFT statistics if available.")
94 .setShortName(dftStatisticsOptionShortName)
95 .build());
96 this->addOption(
97 storm::settings::OptionBuilder(moduleName, importanceMeasureOptionName, false, "Calculate importance measures for all basic events in the SFT.")
98 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("measure", "The name of the measure. Valid values: [MIF,DIF,CIF,RAW,RRW]")
99 .addValidatorString(storm::settings::ArgumentValidatorFactory::createMultipleChoiceValidator({"MIF", "DIF", "CIF", "RAW", "RRW"}))
100 .build())
101 .build());
102 this->addOption(
103 storm::settings::OptionBuilder(moduleName, variableOrderingFileOptionName, false,
104 "File containing the order of BEs used as variable ordering for the BDD.")
105 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the file from which to read the variable ordering.")
107 .build())
108 .build());
109}
110
112 return this->getOption(dftFileOptionName).getHasOptionBeenSet();
113}
114
115std::string DftIOSettings::getDftFilename() const {
116 return this->getOption(dftFileOptionName).getArgumentByName("filename").getValueAsString();
117}
118
120 return this->getOption(dftJsonFileOptionName).getHasOptionBeenSet();
121}
122
124 return this->getOption(dftJsonFileOptionName).getArgumentByName("filename").getValueAsString();
125}
126
128 return this->getOption(propExpectedTimeOptionName).getHasOptionBeenSet();
129}
130
132 return this->getOption(propProbabilityOptionName).getHasOptionBeenSet();
133}
134
136 return this->getOption(propTimeboundOptionName).getHasOptionBeenSet();
137}
138
140 return this->getOption(propTimeboundOptionName).getArgumentByName("time").getValueAsDouble();
141}
142
144 return this->getOption(propTimepointsOptionName).getHasOptionBeenSet();
145}
146
147std::vector<double> DftIOSettings::getPropTimepoints() const {
148 double starttime = this->getOption(propTimepointsOptionName).getArgumentByName("starttime").getValueAsDouble();
149 double endtime = this->getOption(propTimepointsOptionName).getArgumentByName("endtime").getValueAsDouble();
150 double inc = this->getOption(propTimepointsOptionName).getArgumentByName("inc").getValueAsDouble();
151 std::vector<double> timepoints;
152 for (double time = starttime; time <= endtime; time += inc) {
153 timepoints.push_back(time);
154 }
155 return timepoints;
156}
157
159 return this->getOption(minValueOptionName).getHasOptionBeenSet();
160}
161
163 return this->getOption(maxValueOptionName).getHasOptionBeenSet();
164}
165
167 return this->getOption(analyzeWithBdds).getHasOptionBeenSet();
168}
169
171 return this->getOption(minimalCutSets).getHasOptionBeenSet();
172}
173
175 return this->getOption(exportToJsonOptionName).getHasOptionBeenSet();
176}
177
179 return this->getOption(exportToJsonOptionName).getArgumentByName("filename").getValueAsString();
180}
181
183 return this->getOption(exportToSmtOptionName).getHasOptionBeenSet();
184}
185
187 return this->getOption(exportToSmtOptionName).getArgumentByName("filename").getValueAsString();
188}
189
191 return this->getOption(exportToBddDotOptionName).getHasOptionBeenSet();
192}
193
195 return this->getOption(exportToBddDotOptionName).getArgumentByName("filename").getValueAsString();
196}
197
199 return this->getOption(dftStatisticsOptionName).getHasOptionBeenSet();
200}
201
203 return this->getOption(importanceMeasureOptionName).getHasOptionBeenSet();
204}
205
207 return this->getOption(importanceMeasureOptionName).getArgumentByName("measure").getValueAsString();
208}
209
211 return this->getOption(variableOrderingFileOptionName).getHasOptionBeenSet();
212}
213
215 return this->getOption(variableOrderingFileOptionName).getArgumentByName("filename").getValueAsString();
216}
217
219
221 // Ensure that at most one input file is set
222 STORM_LOG_THROW(!isDftFileSet() || !isDftJsonFileSet(), storm::exceptions::InvalidSettingsException,
223 "The DFT may be either given in Galileo or JSON format, but not both.");
224 // Ensure that at most one of min or max is set
225 STORM_LOG_THROW(!isComputeMinimalValue() || !isComputeMaximalValue(), storm::exceptions::InvalidSettingsException, "Min and max can not both be set.");
226 return true;
227}
228
229} // namespace modules
230} // namespace settings
231} // 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.
std::string getVariableOrderingFilename() const
Retrieves the name of the file that contains the variable ordering.
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.
bool isVariableOrderingFileSet() const
Retrieves whether the varialble ordering file option 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