6 changed files with 152 additions and 8 deletions
-
26src/modelchecker/reachability/SparseMdpLearningModelChecker.cpp
-
11src/modelchecker/reachability/SparseMdpLearningModelChecker.h
-
5src/settings/SettingsManager.cpp
-
7src/settings/SettingsManager.h
-
52src/settings/modules/LearningSettings.cpp
-
59src/settings/modules/LearningSettings.h
@ -0,0 +1,52 @@ |
|||||
|
#include "src/settings/modules/LearningSettings.h"
|
||||
|
#include "src/settings/modules/GeneralSettings.h"
|
||||
|
#include "src/settings/Option.h"
|
||||
|
#include "src/settings/OptionBuilder.h"
|
||||
|
#include "src/settings/ArgumentBuilder.h"
|
||||
|
#include "src/settings/Argument.h"
|
||||
|
#include "src/settings/SettingsManager.h"
|
||||
|
|
||||
|
namespace storm { |
||||
|
namespace settings { |
||||
|
namespace modules { |
||||
|
|
||||
|
const std::string LearningSettings::moduleName = "learning"; |
||||
|
const std::string LearningSettings::ecDetectionTypeOptionName = "ecdetection"; |
||||
|
|
||||
|
LearningSettings::LearningSettings(storm::settings::SettingsManager& settingsManager) : ModuleSettings(settingsManager, moduleName) { |
||||
|
std::vector<std::string> types = { "local", "global" }; |
||||
|
this->addOption(storm::settings::OptionBuilder(moduleName, ecDetectionTypeOptionName, true, "Sets the kind of EC-detection used. Available are: { local, global }.").addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the type to use.").addValidationFunctionString(storm::settings::ArgumentValidators::stringInListValidator(types)).setDefaultValueString("local").build()).build()); |
||||
|
} |
||||
|
|
||||
|
bool LearningSettings::isLocalECDetectionSet() const { |
||||
|
if (this->getOption(ecDetectionTypeOptionName).getArgumentByName("name").getValueAsString() == "local") { |
||||
|
return true; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
bool LearningSettings::isGlobalECDetectionSet() const { |
||||
|
if (this->getOption(ecDetectionTypeOptionName).getArgumentByName("name").getValueAsString() == "global") { |
||||
|
return true; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
LearningSettings::ECDetectionType LearningSettings::getECDetectionType() const { |
||||
|
std::string typeAsString = this->getOption(ecDetectionTypeOptionName).getArgumentByName("name").getValueAsString(); |
||||
|
if (typeAsString == "local") { |
||||
|
return LearningSettings::ECDetectionType::Local; |
||||
|
} else if (typeAsString == "global") { |
||||
|
return LearningSettings::ECDetectionType::Global; |
||||
|
} |
||||
|
STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown EC-detection type '" << typeAsString << "'."); |
||||
|
} |
||||
|
|
||||
|
bool LearningSettings::check() const { |
||||
|
bool optionsSet = this->getOption(ecDetectionTypeOptionName).getHasOptionBeenSet(); |
||||
|
STORM_LOG_WARN_COND(storm::settings::generalSettings().getEngine() == storm::settings::modules::GeneralSettings::Engine::Learning || !optionsSet, "Bisimulation minimization is not selected, so setting options for bisimulation has no effect."); |
||||
|
return true; |
||||
|
} |
||||
|
} // namespace modules
|
||||
|
} // namespace settings
|
||||
|
} // namespace storm
|
@ -0,0 +1,59 @@ |
|||||
|
#ifndef STORM_SETTINGS_MODULES_LEARNINGSETTINGS_H_ |
||||
|
#define STORM_SETTINGS_MODULES_LEARNINGSETTINGS_H_ |
||||
|
|
||||
|
#include "src/settings/modules/ModuleSettings.h" |
||||
|
|
||||
|
namespace storm { |
||||
|
namespace settings { |
||||
|
namespace modules { |
||||
|
|
||||
|
/*! |
||||
|
* This class represents the learning settings. |
||||
|
*/ |
||||
|
class LearningSettings : public ModuleSettings { |
||||
|
public: |
||||
|
// An enumeration of all available EC-detection types. |
||||
|
enum class ECDetectionType { Local, Global }; |
||||
|
|
||||
|
/*! |
||||
|
* Creates a new set of learning settings that is managed by the given manager. |
||||
|
* |
||||
|
* @param settingsManager The responsible manager. |
||||
|
*/ |
||||
|
LearningSettings(storm::settings::SettingsManager& settingsManager); |
||||
|
|
||||
|
/*! |
||||
|
* Retrieves whether local EC-detection is to be used. |
||||
|
* |
||||
|
* @return True iff local EC-detection is to be used. |
||||
|
*/ |
||||
|
bool isLocalECDetectionSet() const; |
||||
|
|
||||
|
/*! |
||||
|
* Retrieves whether global EC-detection is to be used. |
||||
|
* |
||||
|
* @return True iff global EC-detection is to be used. |
||||
|
*/ |
||||
|
bool isGlobalECDetectionSet() const; |
||||
|
|
||||
|
/*! |
||||
|
* Retrieves the selected EC-detection type. |
||||
|
* |
||||
|
* @return The selected EC-detection type. |
||||
|
*/ |
||||
|
ECDetectionType getECDetectionType() const; |
||||
|
|
||||
|
virtual 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 ecDetectionTypeOptionName; |
||||
|
}; |
||||
|
} // namespace modules |
||||
|
} // namespace settings |
||||
|
} // namespace storm |
||||
|
|
||||
|
#endif /* STORM_SETTINGS_MODULES_LEARNINGSETTINGS_H_ */ |
Reference in new issue
xxxxxxxxxx