Browse Source

Added feature to also show help for a given option name.

Former-commit-id: 4a2a37a874
tempestpy_adaptions
dehnert 10 years ago
parent
commit
7e56e0d8f7
  1. 32
      src/settings/SettingsManager.cpp
  2. 10
      src/settings/SettingsManager.h
  3. 5
      src/settings/modules/GeneralSettings.cpp
  4. 6
      src/settings/modules/GmmxxEquationSolverSettings.cpp
  5. 6
      src/settings/modules/NativeEquationSolverSettings.cpp

32
src/settings/SettingsManager.cpp

@ -111,18 +111,42 @@ namespace storm {
LOG_ASSERT(false, "Not yet implemented");
}
void SettingsManager::printHelp(std::string const& moduleName) const {
void SettingsManager::printHelp(std::string const& hint) const {
std::cout << "usage: storm [options]" << std::endl << std::endl;
if (moduleName == "all") {
if (hint == "all") {
// Find longest option name.
uint_fast64_t maxLength = getPrintLengthOfLongestOption();
for (auto const& moduleName : this->moduleNames) {
printHelpForModule(moduleName, maxLength);
}
} else {
uint_fast64_t maxLength = getPrintLengthOfLongestOption(moduleName);
printHelpForModule(moduleName, maxLength);
auto moduleIterator = this->modules.find(hint);
// If the supplied information is a module, print the help text of the module.
if (moduleIterator != this->modules.end()) {
uint_fast64_t maxLength = getPrintLengthOfLongestOption(hint);
printHelpForModule(hint, maxLength);
} else {
auto optionIterator = this->longNameToOptions.find(hint);
if (optionIterator != this->longNameToOptions.end()) {
// Save the flags for std::cout so we can manipulate them and be sure they will be restored as soon as this
// stream goes out of scope.
boost::io::ios_flags_saver out(std::cout);
std::cout << "Matching options:" << std::endl;
uint_fast64_t maxLength = 0;
for (auto const& option : optionIterator->second) {
maxLength = std::max(maxLength, option->getPrintLength());
}
for (auto const& option : optionIterator->second) {
std::cout << std::setw(maxLength) << std::left << *option << std::endl;
}
} else {
LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unable to show help for unknown entity '" << hint << "'.");
}
}
}
}

10
src/settings/SettingsManager.h

@ -74,14 +74,12 @@ namespace storm {
void setFromConfigurationFile(std::string const& configFilename);
/*!
* This function prints a help message to the standard output. Optionally, a module name can be given. If
* it is present, name must correspond to a known module. Then, only the help text for this module is
* printed.
* This function prints a help message to the standard output. Optionally, a string can be given that either
* identifies a module or some options to cut down the help text.
*
* @param moduleName The name of the module for which to show the help or "all" if the full help text is to
* be printed.
* @param hint The name of a module, some options or "all" for the full help text.
*/
void printHelp(std::string const& moduleName = "all") const;
void printHelp(std::string const& hint = "all") const;
/*!
* This function prints a help message for the specified module to the standard output.

5
src/settings/modules/GeneralSettings.cpp

@ -37,11 +37,10 @@ namespace storm {
const std::string GeneralSettings::constantsOptionShortName = "const";
GeneralSettings::GeneralSettings(storm::settings::SettingsManager& settingsManager) : ModuleSettings(settingsManager, moduleName) {
std::vector<std::string> moduleNames = {"all", "general", "debug", "cudd", "counterexample", "glpk", "gurobi", "gmm++", "native"};
this->addOption(storm::settings::OptionBuilder(moduleName, helpOptionName, false, "Shows all available options, arguments and descriptions.").setShortName(helpOptionShortName)
.addArgument(storm::settings::ArgumentBuilder::createStringArgument("module", "The module for which to show the help or 'all' for all modules.").setDefaultValueString("all").addValidationFunctionString(storm::settings::ArgumentValidators::stringInListValidator(moduleNames)).build()).build());
.addArgument(storm::settings::ArgumentBuilder::createStringArgument("module", "The module for which to show the help or 'all' for all modules.").setDefaultValueString("all").build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, verboseOptionName, false, "Enables more verbose output.").setShortName(verboseOptionShortName).build());
this->addOption(storm::settings::OptionBuilder(moduleName, precisionOptionName, true, "The internally used precision.").setShortName(precisionOptionShortName)
this->addOption(storm::settings::OptionBuilder(moduleName, precisionOptionName, false, "The internally used precision.").setShortName(precisionOptionShortName)
.addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision to use.").setDefaultValueDouble(1e-06).addValidationFunctionDouble(storm::settings::ArgumentValidators::doubleRangeValidatorExcluding(0.0, 1.0)).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, exportDotOptionName, "", "If given, the loaded model will be written to the specified file in the dot format.")
.addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the file to which the model is to be written.").build()).build());

6
src/settings/modules/GmmxxEquationSolverSettings.cpp

@ -25,11 +25,11 @@ namespace storm {
this->addOption(storm::settings::OptionBuilder(moduleName, restartOptionName, true, "The number of iteration until restarted methods are actually restarted.").addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The number of iterations.").setDefaultValueUnsignedInteger(50).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, maximalIterationsOptionName, true, "The maximal number of iterations to perform before iterative solving is aborted.").setShortName(maximalIterationsOptionShortName).addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The maximal iteration count.").setDefaultValueUnsignedInteger(20000).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, maximalIterationsOptionName, false, "The maximal number of iterations to perform before iterative solving is aborted.").setShortName(maximalIterationsOptionShortName).addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The maximal iteration count.").setDefaultValueUnsignedInteger(20000).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, precisionOptionName, true, "The precision used for detecting convergence of iterative methods.").addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision to achieve.").setDefaultValueDouble(1e-06).addValidationFunctionDouble(storm::settings::ArgumentValidators::doubleRangeValidatorExcluding(0.0, 1.0)).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, precisionOptionName, false, "The precision used for detecting convergence of iterative methods.").addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision to achieve.").setDefaultValueDouble(1e-06).addValidationFunctionDouble(storm::settings::ArgumentValidators::doubleRangeValidatorExcluding(0.0, 1.0)).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, absoluteOptionName, true, "Sets whether the relative or the absolute error is considered for detecting convergence.").build());
this->addOption(storm::settings::OptionBuilder(moduleName, absoluteOptionName, false, "Sets whether the relative or the absolute error is considered for detecting convergence.").build());
}
GmmxxEquationSolverSettings::LinearEquationTechnique GmmxxEquationSolverSettings::getLinearEquationSystemTechnique() const {

6
src/settings/modules/NativeEquationSolverSettings.cpp

@ -17,11 +17,11 @@ namespace storm {
std::vector<std::string> methods = { "jacobi" };
this->addOption(storm::settings::OptionBuilder(moduleName, techniqueOptionName, true, "The method to be used for solving linear equation systems with the native engine. Available are: { jacobi }.").addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the method to use.").addValidationFunctionString(storm::settings::ArgumentValidators::stringInListValidator(methods)).setDefaultValueString("jacobi").build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, maximalIterationsOptionName, true, "The maximal number of iterations to perform before iterative solving is aborted.").setShortName(maximalIterationsOptionShortName).addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The maximal iteration count.").setDefaultValueUnsignedInteger(20000).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, maximalIterationsOptionName, false, "The maximal number of iterations to perform before iterative solving is aborted.").setShortName(maximalIterationsOptionShortName).addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The maximal iteration count.").setDefaultValueUnsignedInteger(20000).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, precisionOptionName, true, "The precision used for detecting convergence of iterative methods.").addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision to achieve.").setDefaultValueDouble(1e-06).addValidationFunctionDouble(storm::settings::ArgumentValidators::doubleRangeValidatorExcluding(0.0, 1.0)).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, precisionOptionName, false, "The precision used for detecting convergence of iterative methods.").addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision to achieve.").setDefaultValueDouble(1e-06).addValidationFunctionDouble(storm::settings::ArgumentValidators::doubleRangeValidatorExcluding(0.0, 1.0)).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, absoluteOptionName, true, "Sets whether the relative or the absolute error is considered for detecting convergence.").build());
this->addOption(storm::settings::OptionBuilder(moduleName, absoluteOptionName, false, "Sets whether the relative or the absolute error is considered for detecting convergence.").build());
}
NativeEquationSolverSettings::LinearEquationTechnique NativeEquationSolverSettings::getLinearEquationSystemTechnique() const {

Loading…
Cancel
Save