10 changed files with 252 additions and 0 deletions
-
2src/storm/environment/SubEnvironment.cpp
-
9src/storm/environment/solver/SolverEnvironment.cpp
-
4src/storm/environment/solver/SolverEnvironment.h
-
60src/storm/environment/solver/TimeBoundedSolverEnvironment.cpp
-
36src/storm/environment/solver/TimeBoundedSolverEnvironment.h
-
2src/storm/settings/SettingsManager.cpp
-
62src/storm/settings/modules/TimeBoundedSolverSettings.cpp
-
66src/storm/settings/modules/TimeBoundedSolverSettings.h
-
10src/storm/solver/SolverSelectionOptions.cpp
-
1src/storm/solver/SolverSelectionOptions.h
@ -0,0 +1,60 @@ |
|||
#include "storm/environment/solver/TimeBoundedSolverEnvironment.h"
|
|||
|
|||
#include "storm/settings/SettingsManager.h"
|
|||
#include "storm/settings/modules/TimeBoundedSolverSettings.h"
|
|||
#include "storm/utility/constants.h"
|
|||
#include "storm/utility/macros.h"
|
|||
|
|||
namespace storm { |
|||
|
|||
TimeBoundedSolverEnvironment::TimeBoundedSolverEnvironment() { |
|||
auto const& tbSettings = storm::settings::getModule<storm::settings::modules::TimeBoundedSolverSettings>(); |
|||
maMethod = tbSettings.getMaMethod(); |
|||
maMethodSetFromDefault = tbSettings.isMaMethodSetFromDefaultValue(); |
|||
precision = storm::utility::convertNumber<storm::RationalNumber>(tbSettings.getPrecision()); |
|||
relative = tbSettings.isRelativePrecision(); |
|||
unifPlusKappa = tbSettings.getUnifPlusKappa(); |
|||
} |
|||
|
|||
TimeBoundedSolverEnvironment::~TimeBoundedSolverEnvironment() { |
|||
// Intentionally left empty
|
|||
} |
|||
|
|||
storm::solver::MaBoundedReachabilityMethod const& TimeBoundedSolverEnvironment::getMaMethod() const { |
|||
return maMethod; |
|||
} |
|||
|
|||
bool const& TimeBoundedSolverEnvironment::isMaMethodSetFromDefault() const { |
|||
return maMethodSetFromDefault; |
|||
} |
|||
|
|||
void TimeBoundedSolverEnvironment::setMaMethod(storm::solver::MaBoundedReachabilityMethod value, bool isSetFromDefault) { |
|||
maMethod = value; |
|||
maMethodSetFromDefault = isSetFromDefault; |
|||
} |
|||
|
|||
storm::RationalNumber const& TimeBoundedSolverEnvironment::getPrecision() const { |
|||
return precision; |
|||
} |
|||
|
|||
void TimeBoundedSolverEnvironment::setPrecision(storm::RationalNumber value) { |
|||
precision = value; |
|||
} |
|||
|
|||
bool const& TimeBoundedSolverEnvironment::getRelativeTerminationCriterion() const { |
|||
return relative; |
|||
} |
|||
|
|||
void TimeBoundedSolverEnvironment::setRelativeTerminationCriterion(bool value) { |
|||
relative = value; |
|||
} |
|||
|
|||
storm::RationalNumber const& TimeBoundedSolverEnvironment::getUnifPlusKappa() const { |
|||
return unifPlusKappa; |
|||
} |
|||
|
|||
void TimeBoundedSolverEnvironment::setUnifPlusKappa(storm::RationalNumber value) { |
|||
unifPlusKappa = value; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,36 @@ |
|||
#pragma once |
|||
|
|||
#include "storm/environment/solver/SolverEnvironment.h" |
|||
#include "storm/solver/SolverSelectionOptions.h" |
|||
|
|||
namespace storm { |
|||
|
|||
class TimeBoundedSolverEnvironment { |
|||
public: |
|||
|
|||
TimeBoundedSolverEnvironment(); |
|||
~TimeBoundedSolverEnvironment(); |
|||
|
|||
storm::solver::MaBoundedReachabilityMethod const& getMaMethod() const; |
|||
bool const& isMaMethodSetFromDefault() const; |
|||
void setMaMethod(storm::solver::MaBoundedReachabilityMethod value, bool isSetFromDefault = false); |
|||
|
|||
storm::RationalNumber const& getPrecision() const; |
|||
void setPrecision(storm::RationalNumber value); |
|||
bool const& getRelativeTerminationCriterion() const; |
|||
void setRelativeTerminationCriterion(bool value); |
|||
|
|||
storm::RationalNumber const& getUnifPlusKappa() const; |
|||
void setUnifPlusKappa(storm::RationalNumber value); |
|||
|
|||
private: |
|||
storm::solver::MaBoundedReachabilityMethod maMethod; |
|||
bool maMethodSetFromDefault; |
|||
|
|||
storm::RationalNumber precision; |
|||
bool relative; |
|||
|
|||
storm::RationalNumber unifPlusKappa; |
|||
}; |
|||
} |
|||
|
@ -0,0 +1,62 @@ |
|||
#include "storm/settings/modules/TimeBoundedSolverSettings.h"
|
|||
|
|||
#include "storm/settings/Option.h"
|
|||
#include "storm/settings/ArgumentBuilder.h"
|
|||
#include "storm/settings/OptionBuilder.h"
|
|||
|
|||
#include "storm/utility/macros.h"
|
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
namespace modules { |
|||
|
|||
const std::string TimeBoundedSolverSettings::moduleName = "timebounded"; |
|||
|
|||
const std::string TimeBoundedSolverSettings::maMethodOptionName = "mamethod"; |
|||
const std::string TimeBoundedSolverSettings::precisionOptionName = "precision"; |
|||
const std::string TimeBoundedSolverSettings::absoluteOptionName = "absolute"; |
|||
const std::string TimeBoundedSolverSettings::unifPlusKappaOptionName = "kappa"; |
|||
|
|||
TimeBoundedSolverSettings::TimeBoundedSolverSettings() : ModuleSettings(moduleName) { |
|||
std::vector<std::string> maMethods = {"imca", "unifplus"}; |
|||
this->addOption(storm::settings::OptionBuilder(moduleName, maMethodOptionName, false, "The method to use to solve bounded reachability queries on MAs.").setIsAdvanced().addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the method to use.").addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(maMethods)).setDefaultValueString("unifplus").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, unifPlusKappaOptionName, false, "The truncation factor used in unifPlus.").setIsAdvanced().addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("kappa", "The factor").setDefaultValueDouble(0.1).addValidatorDouble(ArgumentValidatorFactory::createDoubleRangeValidatorExcluding(0.0, 1.0)).build()).build()); |
|||
|
|||
} |
|||
|
|||
bool TimeBoundedSolverSettings::isPrecisionSet() const { |
|||
return this->getOption(precisionOptionName).getHasOptionBeenSet(); |
|||
} |
|||
|
|||
double TimeBoundedSolverSettings::getPrecision() const { |
|||
return this->getOption(precisionOptionName).getArgumentByName("value").getValueAsDouble(); |
|||
} |
|||
|
|||
bool TimeBoundedSolverSettings::isRelativePrecision() const { |
|||
return !this->getOption(absoluteOptionName).getHasOptionBeenSet(); |
|||
} |
|||
|
|||
storm::solver::MaBoundedReachabilityMethod TimeBoundedSolverSettings::getMaMethod() const { |
|||
std::string techniqueAsString = this->getOption(maMethodOptionName).getArgumentByName("name").getValueAsString(); |
|||
if (techniqueAsString == "imca") { |
|||
return storm::solver::MaBoundedReachabilityMethod::Imca; |
|||
} |
|||
return storm::solver::MaBoundedReachabilityMethod::UnifPlus; |
|||
} |
|||
|
|||
bool TimeBoundedSolverSettings::isMaMethodSetFromDefaultValue() const { |
|||
return !this->getOption(maMethodOptionName).getArgumentByName("name").getHasBeenSet() || this->getOption(maMethodOptionName).getArgumentByName("name").wasSetFromDefaultValue(); |
|||
} |
|||
|
|||
double TimeBoundedSolverSettings::getUnifPlusKappa() const { |
|||
return this->getOption(unifPlusKappaOptionName).getArgumentByName("kappa").getValueAsDouble(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,66 @@ |
|||
#pragma once |
|||
|
|||
#include "storm-config.h" |
|||
#include "storm/settings/modules/ModuleSettings.h" |
|||
|
|||
#include "storm/solver/SolverSelectionOptions.h" |
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
namespace modules { |
|||
|
|||
/*! |
|||
* This class represents the min/max solver settings. |
|||
*/ |
|||
class TimeBoundedSolverSettings : public ModuleSettings { |
|||
public: |
|||
|
|||
TimeBoundedSolverSettings(); |
|||
|
|||
/*! |
|||
* Retrieves whether solving technique for time bounded reachability on Markov Automata has been set from its default value. |
|||
*/ |
|||
bool isMaMethodSetFromDefaultValue() const; |
|||
|
|||
/*! |
|||
* Retrieves the selected solving technique for time bounded reachability on Markov Automata. |
|||
*/ |
|||
storm::solver::MaBoundedReachabilityMethod getMaMethod() 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 or absolute. |
|||
*/ |
|||
bool isRelativePrecision() const; |
|||
|
|||
/*! |
|||
* Retrieves the truncation factor used for unifPlus |
|||
*/ |
|||
double getUnifPlusKappa() const; |
|||
|
|||
// The name of the module. |
|||
static const std::string moduleName; |
|||
|
|||
private: |
|||
static const std::string maMethodOptionName; |
|||
static const std::string precisionOptionName; |
|||
static const std::string absoluteOptionName; |
|||
static const std::string unifPlusKappaOptionName; |
|||
}; |
|||
|
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue