Browse Source
started to fill value iteration implementation in new general min-max solver
started to fill value iteration implementation in new general min-max solver
Former-commit-id: e54cb8a0f9
tempestpy_adaptions
dehnert
9 years ago
21 changed files with 422 additions and 77 deletions
-
1src/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp
-
6src/settings/SettingsManager.cpp
-
14src/settings/modules/CoreSettings.cpp
-
21src/settings/modules/CoreSettings.h
-
72src/settings/modules/MinMaxEquationSolverSettings.cpp
-
91src/settings/modules/MinMaxEquationSolverSettings.h
-
31src/solver/EigenLinearEquationSolver.cpp
-
4src/solver/EigenLinearEquationSolver.h
-
35src/solver/EliminationLinearEquationSolver.cpp
-
2src/solver/EliminationLinearEquationSolver.h
-
8src/solver/GmmxxLinearEquationSolver.cpp
-
4src/solver/GmmxxLinearEquationSolver.h
-
14src/solver/LinearEquationSolver.h
-
8src/solver/MinMaxLinearEquationSolver.cpp
-
17src/solver/NativeLinearEquationSolver.cpp
-
2src/solver/NativeLinearEquationSolver.h
-
8src/solver/SolverSelectionOptions.cpp
-
2src/solver/SolverSelectionOptions.h
-
133src/solver/StandardMinMaxLinearEquationSolver.cpp
-
20src/solver/StandardMinMaxLinearEquationSolver.h
-
6test/functional/solver/MinMaxTechniqueSelectionTest.cpp
@ -0,0 +1,72 @@ |
|||
#include "src/settings/modules/MinMaxEquationSolverSettings.h"
|
|||
|
|||
#include "src/settings/Option.h"
|
|||
#include "src/settings/ArgumentBuilder.h"
|
|||
#include "src/settings/OptionBuilder.h"
|
|||
|
|||
#include "src/utility/macros.h"
|
|||
#include "src/exceptions/IllegalArgumentValueException.h"
|
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
namespace modules { |
|||
|
|||
const std::string MinMaxEquationSolverSettings::moduleName = "minmax"; |
|||
const std::string MinMaxEquationSolverSettings::solvingMethodOptionName = "method"; |
|||
const std::string MinMaxEquationSolverSettings::maximalIterationsOptionName = "maxiter"; |
|||
const std::string MinMaxEquationSolverSettings::maximalIterationsOptionShortName = "i"; |
|||
const std::string MinMaxEquationSolverSettings::precisionOptionName = "precision"; |
|||
|
|||
MinMaxEquationSolverSettings::MinMaxEquationSolverSettings() : ModuleSettings(moduleName) { |
|||
std::vector<std::string> minMaxSolvingTechniques = {"vi", "value-iteration", "pi", "policy-iteration"}; |
|||
this->addOption(storm::settings::OptionBuilder(moduleName, solvingMethodOptionName, false, "Sets which min/max linear equation solving technique is preferred.") |
|||
.addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of a min/max linear equation solving technique. Available are: value-iteration (vi) and policy-iteration (pi).").addValidationFunctionString(storm::settings::ArgumentValidators::stringInListValidator(minMaxSolvingTechniques)).setDefaultValueString("vi").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, 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, false, "Sets whether the relative or the absolute error is considered for detecting convergence.").build()); |
|||
} |
|||
|
|||
storm::solver::MinMaxMethod MinMaxEquationSolverSettings::getMinMaxEquationSolvingMethod() const { |
|||
std::string minMaxEquationSolvingTechnique = this->getOption(solvingMethodOptionName).getArgumentByName("name").getValueAsString(); |
|||
if (minMaxEquationSolvingTechnique == "value-iteration" || minMaxEquationSolvingTechnique == "vi") { |
|||
return storm::solver::MinMaxMethod::ValueIteration; |
|||
} else if (minMaxEquationSolvingTechnique == "policy-iteration" || minMaxEquationSolvingTechnique == "pi") { |
|||
return storm::solver::MinMaxMethod::PolicyIteration; |
|||
} |
|||
STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown min/max equation solving technique '" << minMaxEquationSolvingTechnique << "'."); |
|||
} |
|||
|
|||
bool MinMaxEquationSolverSettings::isMinMaxEquationSolvingMethodSet() const { |
|||
return this->getOption(solvingMethodOptionName).getHasOptionBeenSet(); |
|||
} |
|||
|
|||
bool MinMaxEquationSolverSettings::isMaximalIterationCountSet() const { |
|||
return this->getOption(maximalIterationsOptionName).getHasOptionBeenSet(); |
|||
} |
|||
|
|||
uint_fast64_t MinMaxEquationSolverSettings::getMaximalIterationCount() const { |
|||
return this->getOption(maximalIterationsOptionName).getArgumentByName("count").getValueAsUnsignedInteger(); |
|||
} |
|||
|
|||
bool MinMaxEquationSolverSettings::isPrecisionSet() const { |
|||
return this->getOption(precisionOptionName).getHasOptionBeenSet(); |
|||
} |
|||
|
|||
double MinMaxEquationSolverSettings::getPrecision() const { |
|||
return this->getOption(precisionOptionName).getArgumentByName("value").getValueAsDouble(); |
|||
} |
|||
|
|||
bool MinMaxEquationSolverSettings::isConvergenceCriterionSet() const { |
|||
return this->getOption(absoluteOptionName).getHasOptionBeenSet(); |
|||
} |
|||
|
|||
MinMaxEquationSolverSettings::ConvergenceCriterion MinMaxEquationSolverSettings::getConvergenceCriterion() const { |
|||
return this->getOption(absoluteOptionName).getHasOptionBeenSet() ? MinMaxEquationSolverSettings::ConvergenceCriterion::Absolute : MinMaxEquationSolverSettings::ConvergenceCriterion::Relative; |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,91 @@ |
|||
#pragma once |
|||
|
|||
#include "storm-config.h" |
|||
#include "src/settings/modules/ModuleSettings.h" |
|||
|
|||
#include "src/solver/SolverSelectionOptions.h" |
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
namespace modules { |
|||
|
|||
/*! |
|||
* This class represents the min/max solver settings. |
|||
*/ |
|||
class MinMaxEquationSolverSettings : public ModuleSettings { |
|||
public: |
|||
// An enumeration of all available convergence criteria. |
|||
enum class ConvergenceCriterion { Absolute, Relative }; |
|||
|
|||
MinMaxEquationSolverSettings(); |
|||
|
|||
/*! |
|||
* Retrieves whether a min/max equation solving technique has been set. |
|||
* |
|||
* @return True iff an equation solving technique has been set. |
|||
*/ |
|||
bool isMinMaxEquationSolvingMethodSet() const; |
|||
|
|||
/*! |
|||
* Retrieves the selected min/max equation solving technique. |
|||
* |
|||
* @return The selected min/max equation solving technique. |
|||
*/ |
|||
storm::solver::MinMaxMethod getMinMaxEquationSolvingMethod() const; |
|||
|
|||
/*! |
|||
* Retrieves whether the maximal iteration count has been set. |
|||
* |
|||
* @return True iff the maximal iteration count has been set. |
|||
*/ |
|||
bool isMaximalIterationCountSet() const; |
|||
|
|||
/*! |
|||
* Retrieves the maximal number of iterations to perform until giving up on converging. |
|||
* |
|||
* @return The maximal iteration count. |
|||
*/ |
|||
uint_fast64_t getMaximalIterationCount() const; |
|||
|
|||
/*! |
|||
* Retrieves whether the precision has been set. |
|||
* |
|||
* @return True iff the precision has been set. |
|||
*/ |
|||
bool isPrecisionSet() const; |
|||
|
|||
/*! |
|||
* Retrieves the precision that is used for detecting convergence. |
|||
* |
|||
* @return The precision to use for detecting convergence. |
|||
*/ |
|||
double getPrecision() const; |
|||
|
|||
/*! |
|||
* Retrieves whether the convergence criterion has been set. |
|||
* |
|||
* @return True iff the convergence criterion has been set. |
|||
*/ |
|||
bool isConvergenceCriterionSet() const; |
|||
|
|||
/*! |
|||
* Retrieves the selected convergence criterion. |
|||
* |
|||
* @return The selected convergence criterion. |
|||
*/ |
|||
ConvergenceCriterion getConvergenceCriterion() const; |
|||
|
|||
// The name of the module. |
|||
static const std::string moduleName; |
|||
|
|||
private: |
|||
static const std::string solvingMethodOptionName; |
|||
static const std::string maximalIterationsOptionName; |
|||
static const std::string maximalIterationsOptionShortName; |
|||
static const std::string precisionOptionName; |
|||
static const std::string absoluteOptionName; |
|||
}; |
|||
|
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue