Tim Quatmann
5 years ago
6 changed files with 332 additions and 113 deletions
-
2src/storm-pars/settings/ParsSettings.cpp
-
244src/storm/modelchecker/csl/helper/SparseCtmcCslHelper.cpp
-
2src/storm/settings/SettingsManager.cpp
-
101src/storm/settings/modules/LongRunAverageSolverSettings.cpp
-
92src/storm/settings/modules/LongRunAverageSolverSettings.h
-
4src/test/storm/modelchecker/prctl/dtmc/LraDtmcPrctlModelCheckerTest.cpp
@ -0,0 +1,101 @@ |
|||
#include "storm/settings/modules/LongRunAverageSolverSettings.h"
|
|||
|
|||
#include "storm/settings/Option.h"
|
|||
#include "storm/settings/ArgumentBuilder.h"
|
|||
#include "storm/settings/OptionBuilder.h"
|
|||
|
|||
#include "storm/utility/macros.h"
|
|||
#include "storm/exceptions/IllegalArgumentValueException.h"
|
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
namespace modules { |
|||
|
|||
const std::string LongRunAverageSolverSettings::moduleName = "lra"; |
|||
const std::string LongRunAverageSolverSettings::detLraMethodOptionName = "detmethod"; |
|||
const std::string LongRunAverageSolverSettings::nondetLraMethodOptionName = "nondetmethod"; |
|||
const std::string LongRunAverageSolverSettings::maximalIterationsOptionName = "maxiter"; |
|||
const std::string LongRunAverageSolverSettings::maximalIterationsOptionShortName = "i"; |
|||
const std::string LongRunAverageSolverSettings::precisionOptionName = "precision"; |
|||
const std::string LongRunAverageSolverSettings::absoluteOptionName = "absolute"; |
|||
const std::string LongRunAverageSolverSettings::aperiodicFactorOptionName = "aperiodicfactor"; |
|||
|
|||
LongRunAverageSolverSettings::LongRunAverageSolverSettings() : ModuleSettings(moduleName) { |
|||
|
|||
std::vector<std::string> detLraMethods = {"gb", "gain-bias-equations", "distr", "lra-distribution-equations", "vi", "value-iteration"}; |
|||
this->addOption(storm::settings::OptionBuilder(moduleName, detLraMethodOptionName, true, "Sets which method is preferred for computing long run averages on deterministic models.").setIsAdvanced() |
|||
.addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of a long run average computation method.").addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(detLraMethods)).setDefaultValueString("gb").build()).build()); |
|||
|
|||
std::vector<std::string> nondetLraMethods = {"vi", "value-iteration", "linear-programming", "lp"}; |
|||
this->addOption(storm::settings::OptionBuilder(moduleName, nondetLraMethodOptionName, true, "Sets which method is preferred for computing long run averages on models with nondeterminism.").setIsAdvanced() |
|||
.addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of a long run average computation method.").addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(nondetLraMethods)).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).setIsAdvanced().addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The maximal iteration count.").build()).build()); |
|||
|
|||
this->addOption(storm::settings::OptionBuilder(moduleName, precisionOptionName, false, "The precision used for detecting convergence of iterative methods.").setIsAdvanced().addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision to achieve.").setDefaultValueDouble(1e-06).addValidatorDouble(ArgumentValidatorFactory::createDoubleRangeValidatorExcluding(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.").setIsAdvanced().build()); |
|||
|
|||
this->addOption(storm::settings::OptionBuilder(moduleName, aperiodicFactorOptionName, true, "If required by the selected method (e.g. vi), this factor controls how the system is made aperiodic").setIsAdvanced().addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The factor.").setDefaultValueDouble(0.125).addValidatorDouble(ArgumentValidatorFactory::createDoubleRangeValidatorExcluding(0.0, 1.0)).build()).build()); |
|||
|
|||
} |
|||
|
|||
storm::solver::LraMethod LongRunAverageSolverSettings::getDetLraMethod() const { |
|||
std::string lraMethodString = this->getOption(nondetLraMethodOptionName).getArgumentByName("name").getValueAsString(); |
|||
if (lraMethodString == "gain-bias-equations" || lraMethodString == "gb") { |
|||
return storm::solver::LraMethod::GainBiasEquations; |
|||
} |
|||
if (lraMethodString == "lra-distribution-equations" || lraMethodString == "distr") { |
|||
return storm::solver::LraMethod::LraDistributionEquations; |
|||
} |
|||
if (lraMethodString == "value-iteration" || lraMethodString == "vi") { |
|||
return storm::solver::LraMethod::ValueIteration; |
|||
} |
|||
STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown lra solving technique for deterministic models:'" << lraMethodString << "'."); |
|||
} |
|||
|
|||
bool LongRunAverageSolverSettings::isDetLraMethodSetFromDefaultValue() const { |
|||
return !this->getOption(detLraMethodOptionName).getArgumentByName("name").getHasBeenSet() || this->getOption(detLraMethodOptionName).getArgumentByName("name").wasSetFromDefaultValue(); |
|||
} |
|||
|
|||
storm::solver::LraMethod LongRunAverageSolverSettings::getNondetLraMethod() const { |
|||
std::string lraMethodString = this->getOption(nondetLraMethodOptionName).getArgumentByName("name").getValueAsString(); |
|||
if (lraMethodString == "value-iteration" || lraMethodString == "vi") { |
|||
return storm::solver::LraMethod::ValueIteration; |
|||
} else if (lraMethodString == "linear-programming" || lraMethodString == "lp") { |
|||
return storm::solver::LraMethod::LinearProgramming; |
|||
} |
|||
STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown lra solving technique for nondeterministic models:'" << lraMethodString << "'."); |
|||
} |
|||
|
|||
bool LongRunAverageSolverSettings::isNondetLraMethodSetFromDefaultValue() const { |
|||
return !this->getOption(nondetLraMethodOptionName).getArgumentByName("name").getHasBeenSet() || this->getOption(nondetLraMethodOptionName).getArgumentByName("name").wasSetFromDefaultValue(); |
|||
} |
|||
|
|||
bool LongRunAverageSolverSettings::isMaximalIterationCountSet() const { |
|||
return this->getOption(maximalIterationsOptionName).getHasOptionBeenSet(); |
|||
} |
|||
|
|||
uint_fast64_t LongRunAverageSolverSettings::getMaximalIterationCount() const { |
|||
return this->getOption(maximalIterationsOptionName).getArgumentByName("count").getValueAsUnsignedInteger(); |
|||
} |
|||
|
|||
bool LongRunAverageSolverSettings::isPrecisionSet() const { |
|||
return this->getOption(precisionOptionName).getHasOptionBeenSet(); |
|||
} |
|||
|
|||
double LongRunAverageSolverSettings::getPrecision() const { |
|||
return this->getOption(precisionOptionName).getArgumentByName("value").getValueAsDouble(); |
|||
} |
|||
|
|||
bool LongRunAverageSolverSettings::isRelativePrecision() const { |
|||
return this->getOption(absoluteOptionName).getHasOptionBeenSet(); |
|||
} |
|||
|
|||
double LongRunAverageSolverSettings::getAperiodicFactor() const { |
|||
return this->getOption(aperiodicFactorOptionName).getArgumentByName("value").getValueAsDouble(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,92 @@ |
|||
#pragma once |
|||
|
|||
#include "storm-config.h" |
|||
#include "storm/settings/modules/ModuleSettings.h" |
|||
|
|||
#include "storm/solver/SolverSelectionOptions.h" |
|||
#include "storm/solver/MultiplicationStyle.h" |
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
namespace modules { |
|||
|
|||
/*! |
|||
* This class represents the LRA solver settings. |
|||
*/ |
|||
class LongRunAverageSolverSettings : public ModuleSettings { |
|||
public: |
|||
|
|||
LongRunAverageSolverSettings(); |
|||
|
|||
/*! |
|||
* Retrieves the selected long run average method for deterministic models. |
|||
*/ |
|||
storm::solver::LraMethod getDetLraMethod() const; |
|||
|
|||
/*! |
|||
* Retrieves whether the LraMethod for deterministic models was set from a default value. |
|||
*/ |
|||
bool isDetLraMethodSetFromDefaultValue() const; |
|||
|
|||
/*! |
|||
* Retrieves the selected long run average method for nondeterministic models. |
|||
*/ |
|||
storm::solver::LraMethod getNondetLraMethod() const; |
|||
|
|||
/*! |
|||
* Retrieves whether the LraMethod for nondeterministic models was set from a default value. |
|||
*/ |
|||
bool isNondetLraMethodSetFromDefaultValue() const; |
|||
|
|||
/*! |
|||
* Retrieves whether a maximal iteration count for iterative methods was 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 to relative. |
|||
*/ |
|||
bool isRelativePrecision() const; |
|||
|
|||
/*! |
|||
* Retrieves a factor that describes how the system is made aperiodic (if necessary by the method) |
|||
*/ |
|||
double getAperiodicFactor() const; |
|||
|
|||
// The name of the module. |
|||
static const std::string moduleName; |
|||
|
|||
private: |
|||
static const std::string detLraMethodOptionName; |
|||
static const std::string nondetLraMethodOptionName; |
|||
static const std::string maximalIterationsOptionName; |
|||
static const std::string maximalIterationsOptionShortName; |
|||
static const std::string precisionOptionName; |
|||
static const std::string absoluteOptionName; |
|||
static const std::string aperiodicFactorOptionName; |
|||
}; |
|||
|
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue