Browse Source

introduced topological equation solver settings

tempestpy_adaptions
TimQu 7 years ago
parent
commit
304b8e32c6
  1. 9
      src/storm/environment/solver/TopologicalLinearEquationSolverEnvironment.cpp
  2. 2
      src/storm/settings/SettingsManager.cpp
  3. 67
      src/storm/settings/modules/TopologicalEquationSolverSettings.cpp
  4. 55
      src/storm/settings/modules/TopologicalEquationSolverSettings.h

9
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<storm::settings::modules::GameSolverSettings>();
std::cout << "TODO: get actual settings in topo environment." << std::endl;
underlyingSolverType = storm::solver::EquationSolverType::Native;
underlyingSolverTypeSetFromDefault = true;
auto const& topologicalSettings = storm::settings::getModule<storm::settings::modules::TopologicalEquationSolverSettings>();
underlyingSolverType = topologicalSettings.getUnderlyingEquationSolverType();
underlyingSolverTypeSetFromDefault = topologicalSettings.isUnderlyingEquationSolverTypeSetFromDefaultValue();
}
TopologicalLinearEquationSolverEnvironment::~TopologicalLinearEquationSolverEnvironment() {

2
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::modules::GlpkSettings>();
storm::settings::addModule<storm::settings::modules::GurobiSettings>();
storm::settings::addModule<storm::settings::modules::TopologicalValueIterationEquationSolverSettings>();
storm::settings::addModule<storm::settings::modules::TopologicalEquationSolverSettings>();
storm::settings::addModule<storm::settings::modules::Smt2SmtSolverSettings>();
storm::settings::addModule<storm::settings::modules::ExplorationSettings>();
storm::settings::addModule<storm::settings::modules::ResourceSettings>();

67
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<std::string> 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

55
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
Loading…
Cancel
Save