diff --git a/src/storm/environment/solver/TopologicalLinearEquationSolverEnvironment.cpp b/src/storm/environment/solver/TopologicalLinearEquationSolverEnvironment.cpp index e49c0c15f..a0f3ac030 100644 --- a/src/storm/environment/solver/TopologicalLinearEquationSolverEnvironment.cpp +++ b/src/storm/environment/solver/TopologicalLinearEquationSolverEnvironment.cpp @@ -1,7 +1,7 @@ #include "storm/environment/solver/TopologicalLinearEquationSolverEnvironment.h" #include "storm/settings/SettingsManager.h" -#include "storm/settings/modules/GameSolverSettings.h" +#include "storm/settings/modules/TopologicalEquationSolverSettings.h" #include "storm/utility/macros.h" #include "storm/exceptions/InvalidArgumentException.h" @@ -9,10 +9,9 @@ namespace storm { TopologicalLinearEquationSolverEnvironment::TopologicalLinearEquationSolverEnvironment() { - auto const& topologicalSettings = storm::settings::getModule(); - std::cout << "TODO: get actual settings in topo environment." << std::endl; - underlyingSolverType = storm::solver::EquationSolverType::Native; - underlyingSolverTypeSetFromDefault = true; + auto const& topologicalSettings = storm::settings::getModule(); + underlyingSolverType = topologicalSettings.getUnderlyingEquationSolverType(); + underlyingSolverTypeSetFromDefault = topologicalSettings.isUnderlyingEquationSolverTypeSetFromDefaultValue(); } TopologicalLinearEquationSolverEnvironment::~TopologicalLinearEquationSolverEnvironment() { diff --git a/src/storm/settings/SettingsManager.cpp b/src/storm/settings/SettingsManager.cpp index 188d1cba2..80cfbb58b 100644 --- a/src/storm/settings/SettingsManager.cpp +++ b/src/storm/settings/SettingsManager.cpp @@ -31,6 +31,7 @@ #include "storm/settings/modules/GurobiSettings.h" #include "storm/settings/modules/Smt2SmtSolverSettings.h" #include "storm/settings/modules/TopologicalValueIterationEquationSolverSettings.h" +#include "storm/settings/modules/TopologicalEquationSolverSettings.h" #include "storm/settings/modules/ExplorationSettings.h" #include "storm/settings/modules/ResourceSettings.h" #include "storm/settings/modules/AbstractionSettings.h" @@ -527,6 +528,7 @@ namespace storm { storm::settings::addModule(); storm::settings::addModule(); storm::settings::addModule(); + storm::settings::addModule(); storm::settings::addModule(); storm::settings::addModule(); storm::settings::addModule(); diff --git a/src/storm/settings/modules/TopologicalEquationSolverSettings.cpp b/src/storm/settings/modules/TopologicalEquationSolverSettings.cpp new file mode 100644 index 000000000..906a6e472 --- /dev/null +++ b/src/storm/settings/modules/TopologicalEquationSolverSettings.cpp @@ -0,0 +1,67 @@ +#include "storm/settings/modules/TopologicalEquationSolverSettings.h" + + +#include "storm/settings/modules/CoreSettings.h" + +#include "storm/settings/SettingsManager.h" +#include "storm/settings/SettingMemento.h" +#include "storm/settings/Option.h" +#include "storm/settings/OptionBuilder.h" +#include "storm/settings/ArgumentBuilder.h" +#include "storm/settings/Argument.h" +#include "storm/solver/SolverSelectionOptions.h" + +#include "storm/storage/dd/DdType.h" + +#include "storm/utility/macros.h" +#include "storm/exceptions/IllegalArgumentValueException.h" +#include "storm/exceptions/InvalidOptionException.h" + +namespace storm { + namespace settings { + namespace modules { + + const std::string TopologicalEquationSolverSettings::moduleName = "topological"; + const std::string TopologicalEquationSolverSettings::underlyingEquationSolverOptionName = "eqsolver"; + + TopologicalEquationSolverSettings::TopologicalEquationSolverSettings() : ModuleSettings(moduleName) { + std::vector linearEquationSolver = {"gmm++", "native", "eigen", "elimination"}; + this->addOption(storm::settings::OptionBuilder(moduleName, underlyingEquationSolverOptionName, false, "Sets which solver is considered for solving the underlying equation systems.") + .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the used solver.").addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(linearEquationSolver)).setDefaultValueString("gmm++").build()).build()); + } + + bool TopologicalEquationSolverSettings::isUnderlyingEquationSolverTypeSet() const { + return this->getOption(underlyingEquationSolverOptionName).getHasOptionBeenSet(); + } + + bool TopologicalEquationSolverSettings::isUnderlyingEquationSolverTypeSetFromDefaultValue() const { + return !this->getOption(underlyingEquationSolverOptionName).getHasOptionBeenSet() || this->getOption(underlyingEquationSolverOptionName).getArgumentByName("name").wasSetFromDefaultValue(); + } + + storm::solver::EquationSolverType TopologicalEquationSolverSettings::getUnderlyingEquationSolverType() const { + std::string equationSolverName = this->getOption(underlyingEquationSolverOptionName).getArgumentByName("name").getValueAsString(); + if (equationSolverName == "gmm++") { + return storm::solver::EquationSolverType::Gmmxx; + } else if (equationSolverName == "native") { + return storm::solver::EquationSolverType::Native; + } else if (equationSolverName == "eigen") { + return storm::solver::EquationSolverType::Eigen; + } else if (equationSolverName == "elimination") { + return storm::solver::EquationSolverType::Elimination; + } + STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown underlying equation solver '" << equationSolverName << "'."); + } + + bool TopologicalEquationSolverSettings::check() const { + if (this->isUnderlyingEquationSolverTypeSet() && getUnderlyingEquationSolverType() == storm::solver::EquationSolverType::Topological) { + STORM_LOG_WARN("Underlying solver type of the topological solver can not be the topological solver."); + return false; + } + return true; + } + + } // namespace modules + } // namespace settings +} // namespace storm + + diff --git a/src/storm/settings/modules/TopologicalEquationSolverSettings.h b/src/storm/settings/modules/TopologicalEquationSolverSettings.h new file mode 100644 index 000000000..45014db32 --- /dev/null +++ b/src/storm/settings/modules/TopologicalEquationSolverSettings.h @@ -0,0 +1,55 @@ +#pragma once + +#include "storm/settings/modules/ModuleSettings.h" + +#include "storm/solver/SolverSelectionOptions.h" + +namespace storm { + namespace settings { + namespace modules { + + /*! + * This class represents the settings for the native equation solver. + */ + class TopologicalEquationSolverSettings : public ModuleSettings { + public: + + /*! + * Creates a new set of native equation solver settings. + */ + TopologicalEquationSolverSettings(); + + /*! + * Retrieves whether the underlying equation solver type has been set. + * + * @return True iff the linear equation system technique has been set. + */ + bool isUnderlyingEquationSolverTypeSet() const; + + /*! + * Retrieves whether the underlying equation solver type is set from its default value. + * + * @return True iff it was set from its default value. + */ + bool isUnderlyingEquationSolverTypeSetFromDefaultValue() const; + + /*! + * Retrieves the method that is to be used for solving systems of linear equations. + * + * @return The method to use. + */ + storm::solver::EquationSolverType getUnderlyingEquationSolverType() const; + + bool check() const override; + + // The name of the module. + static const std::string moduleName; + + private: + // Define the string names of the options as constants. + static const std::string underlyingEquationSolverOptionName; + }; + + } // namespace modules + } // namespace settings +} // namespace storm