diff --git a/src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h b/src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h index b927b6203..80ba611aa 100644 --- a/src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h +++ b/src/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.h @@ -494,7 +494,7 @@ namespace storm { storm::expressions::Expression constraint = storm::expressions::Expression::createDoubleVariable(stateToVariableNameMap.at(state)); for (auto element : transitionMatrix.getRow(nondeterministicChoiceIndices[state])) { - constraint = constraint - storm::expressions::Expression::createDoubleVariable(stateToVariableNameMap.at(element.getColumn())); + constraint = constraint - storm::expressions::Expression::createDoubleVariable(stateToVariableNameMap.at(element.getColumn())) * storm::expressions::Expression::createDoubleLiteral(element.getValue()); } constraint = constraint + storm::expressions::Expression::createDoubleLiteral(storm::utility::constantOne() / exitRates[state]) * storm::expressions::Expression::createDoubleVariable("k"); @@ -512,7 +512,7 @@ namespace storm { storm::expressions::Expression constraint = storm::expressions::Expression::createDoubleVariable(stateToVariableNameMap.at(state)); for (auto element : transitionMatrix.getRow(choice)) { - constraint = constraint - storm::expressions::Expression::createDoubleVariable(stateToVariableNameMap.at(element.getColumn())); + constraint = constraint - storm::expressions::Expression::createDoubleVariable(stateToVariableNameMap.at(element.getColumn())) * storm::expressions::Expression::createDoubleLiteral(element.getValue()); } storm::expressions::Expression rightHandSide = storm::expressions::Expression::createDoubleLiteral(storm::utility::constantZero()); diff --git a/src/settings/SettingsManager.cpp b/src/settings/SettingsManager.cpp index d8b9284d9..26fb6070d 100644 --- a/src/settings/SettingsManager.cpp +++ b/src/settings/SettingsManager.cpp @@ -110,14 +110,42 @@ namespace storm { if (optionActive) { setOptionsArguments(activeOptionName, activeOptionIsShortName ? this->shortNameToOptions : this->longNameToOptions, argumentCache); } + + // Include the options from a possibly specified configuration file, but don't overwrite existing settings. + if (storm::settings::generalSettings().isConfigSet()) { + this->setFromConfigurationFile(storm::settings::generalSettings().getConfigFilename()); + } + + // Finally, check whether all modules are okay with the current settings. + this->checkAllModules(); } void SettingsManager::setFromConfigurationFile(std::string const& configFilename) { - STORM_LOG_ASSERT(false, "Not yet implemented."); + std::map> configurationFileSettings = parseConfigFile(configFilename); + + for (auto const& optionArgumentsPair : configurationFileSettings) { + auto options = this->longNameToOptions.find(optionArgumentsPair.first); + + // We don't need to check whether this option exists or not, because this is already checked when + // parsing the configuration file. + + // Now go through all the matching options and set them according to the values. + for (auto option : options->second) { + if (option->getHasOptionBeenSet()) { + // If the option was already set from the command line, we issue a warning and ignore the + // settings from the configuration file. + STORM_LOG_WARN("The option '" << option->getLongName() << "' of module '" << option->getModuleName() << "' has been set in the configuration file '" << configFilename << "', but was overwritten on the command line." << std::endl); + } else { + // If, however, the option has not been set yet, we try to assign values ot its arguments + // based on the argument strings. + setOptionArguments(optionArgumentsPair.first, option, optionArgumentsPair.second); + } + } + } } void SettingsManager::printHelp(std::string const& hint) const { - std::cout << "usage: storm [options]" << std::endl << std::endl; + STORM_PRINT("usage: storm [options]" << std::endl << std::endl); if (hint == "all") { // Find longest option name. @@ -166,7 +194,7 @@ namespace storm { // Print the matching modules. uint_fast64_t maxLength = std::max(maxLengthModules, maxLengthOptions); if (matchingModuleNames.size() > 0) { - std::cout << "Matching modules for hint '" << hint << "':" << std::endl; + STORM_PRINT("Matching modules for hint '" << hint << "':" << std::endl) for (auto const& matchingModuleName : matchingModuleNames) { printHelpForModule(matchingModuleName, maxLength); } @@ -174,14 +202,14 @@ namespace storm { // Print the matching options. if (matchingOptions.size() > 0) { - std::cout << "Matching options for hint '" << hint << "':" << std::endl; + STORM_PRINT("Matching options for hint '" << hint << "':" << std::endl); for (auto const& option : matchingOptions) { - std::cout << std::setw(maxLength) << std::left << *option << std::endl; + STORM_PRINT(std::setw(maxLength) << std::left << *option << std::endl); } } if (matchingModuleNames.empty() && matchingOptions.empty()) { - std::cout << "Hint '" << hint << "' did not match any modules or options." << std::endl; + STORM_PRINT("Hint '" << hint << "' did not match any modules or options." << std::endl); } } } @@ -189,20 +217,16 @@ namespace storm { void SettingsManager::printHelpForModule(std::string const& moduleName, uint_fast64_t maxLength) const { auto moduleIterator = moduleOptions.find(moduleName); STORM_LOG_THROW(moduleIterator != moduleOptions.end(), storm::exceptions::IllegalFunctionCallException, "Cannot print help for unknown module '" << moduleName << "'."); - std::cout << "##### Module '" << moduleName << "' "; - for (uint_fast64_t i = 0; i < std::min(maxLength, maxLength - moduleName.length() - 16); ++i) { - std::cout << "#"; - } - std::cout << std::endl; + STORM_PRINT("##### Module '" << moduleName << "' " << std::string(std::min(maxLength, maxLength - moduleName.length() - 16), '#') << std::endl); // 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); for (auto const& option : moduleIterator->second) { - std::cout << std::setw(maxLength) << std::left << *option << std::endl; + STORM_PRINT(std::setw(maxLength) << std::left << *option << std::endl); } - std::cout << std::endl; + STORM_PRINT(std::endl); } uint_fast64_t SettingsManager::getPrintLengthOfLongestOption() const { @@ -290,27 +314,32 @@ namespace storm { return true; } + void SettingsManager::setOptionArguments(std::string const& optionName, std::shared_ptr