Browse Source

Merge branch 'future' into multi-objective

Former-commit-id: 0e77076976
tempestpy_adaptions
TimQu 9 years ago
parent
commit
87351d9bd6
  1. 14
      src/models/sparse/StandardRewardModel.cpp
  2. 9
      src/models/sparse/StandardRewardModel.h
  3. 2
      src/settings/SettingsManager.h
  4. 2
      src/settings/modules/CoreSettings.cpp
  5. 3
      src/settings/modules/ModuleSettings.h
  6. 6
      src/utility/storm.h

14
src/models/sparse/StandardRewardModel.cpp

@ -145,15 +145,15 @@ namespace storm {
if (this->hasTransitionRewards()) { if (this->hasTransitionRewards()) {
if (this->hasStateActionRewards()) { if (this->hasStateActionRewards()) {
storm::utility::vector::addVectors<ValueType>(this->getStateActionRewardVector(), transitionMatrix.getPointwiseProductRowSumVector(this->getTransitionRewardMatrix()), this->getStateActionRewardVector()); storm::utility::vector::addVectors<ValueType>(this->getStateActionRewardVector(), transitionMatrix.getPointwiseProductRowSumVector(this->getTransitionRewardMatrix()), this->getStateActionRewardVector());
this->optionalStateActionRewardVector = boost::none;
this->optionalTransitionRewardMatrix = boost::none;
} else { } else {
this->optionalStateActionRewardVector = transitionMatrix.getPointwiseProductRowSumVector(this->getTransitionRewardMatrix()); this->optionalStateActionRewardVector = transitionMatrix.getPointwiseProductRowSumVector(this->getTransitionRewardMatrix());
} }
} }
if (reduceToStateRewards && this->hasStateActionRewards()) { if (reduceToStateRewards && this->hasStateActionRewards()) {
STORM_LOG_THROW(transitionMatrix.getRowGroupCount() == this->getStateActionRewardVector().size(), storm::exceptions::InvalidOperationException, "The reduction to state rewards is only possible if the size of the action reward vector equals the number of states.");
if (this->hasStateRewards()) { if (this->hasStateRewards()) {
STORM_LOG_THROW(this->getStateRewardVector().size() == this->getStateActionRewardVector().size(), storm::exceptions::InvalidOperationException, "The reduction to state rewards is only possible of both the state and the state-action rewards have the same dimension.");
storm::utility::vector::addVectors<ValueType>(this->getStateActionRewardVector(), this->getStateRewardVector(), this->getStateRewardVector()); storm::utility::vector::addVectors<ValueType>(this->getStateActionRewardVector(), this->getStateRewardVector(), this->getStateRewardVector());
} else { } else {
this->optionalStateRewardVector = std::move(this->optionalStateActionRewardVector); this->optionalStateRewardVector = std::move(this->optionalStateActionRewardVector);
@ -242,6 +242,14 @@ namespace storm {
bool StandardRewardModel<ValueType>::empty() const { bool StandardRewardModel<ValueType>::empty() const {
return !(static_cast<bool>(this->optionalStateRewardVector) || static_cast<bool>(this->optionalStateActionRewardVector) || static_cast<bool>(this->optionalTransitionRewardMatrix)); return !(static_cast<bool>(this->optionalStateRewardVector) || static_cast<bool>(this->optionalStateActionRewardVector) || static_cast<bool>(this->optionalTransitionRewardMatrix));
} }
template<typename ValueType>
bool StandardRewardModel<ValueType>::isAllZero() const {
if(hasStateRewards() && !std::all_of(getStateRewardVector().begin(), getStateRewardVector().end(), storm::utility::isZero<ValueType>)) {
return false;
}
return !(static_cast<bool>(this->optionalStateRewardVector) || static_cast<bool>(this->optionalStateActionRewardVector) || static_cast<bool>(this->optionalTransitionRewardMatrix));
}
@ -335,4 +343,4 @@ namespace storm {
} }
} }
}
}

9
src/models/sparse/StandardRewardModel.h

@ -253,6 +253,13 @@ namespace storm {
* @return True iff the reward model is empty. * @return True iff the reward model is empty.
*/ */
bool empty() const; bool empty() const;
/*!
* Retrieves whether every reward defined by this reward model is zero
*
* @return True iff every reward defined by this reward model is zero.
*/
bool isAllZero() const;
/*! /*!
* Checks whether the reward model is compatible with key model characteristics. * Checks whether the reward model is compatible with key model characteristics.
@ -293,4 +300,4 @@ namespace storm {
} }
} }
#endif /* STORM_MODELS_SPARSE_STANDARDREWARDMODEL_H_ */
#endif /* STORM_MODELS_SPARSE_STANDARDREWARDMODEL_H_ */

2
src/settings/SettingsManager.h

@ -260,7 +260,7 @@ namespace storm {
* @return The module. * @return The module.
*/ */
template<typename SettingsType> template<typename SettingsType>
SettingsType getModule() {
SettingsType const& getModule() {
static_assert(std::is_base_of<storm::settings::modules::ModuleSettings, SettingsType>::value, "Template argument must be derived from ModuleSettings"); static_assert(std::is_base_of<storm::settings::modules::ModuleSettings, SettingsType>::value, "Template argument must be derived from ModuleSettings");
return dynamic_cast<SettingsType const&>(manager().getModule(SettingsType::moduleName)); return dynamic_cast<SettingsType const&>(manager().getModule(SettingsType::moduleName));
} }

2
src/settings/modules/CoreSettings.cpp

@ -32,7 +32,7 @@ namespace storm {
const std::string CoreSettings::cudaOptionName = "cuda"; const std::string CoreSettings::cudaOptionName = "cuda";
const std::string CoreSettings::minMaxEquationSolvingTechniqueOptionName = "ndmethod"; const std::string CoreSettings::minMaxEquationSolvingTechniqueOptionName = "ndmethod";
CoreSettings::CoreSettings() : ModuleSettings(moduleName) {
CoreSettings::CoreSettings() : ModuleSettings(moduleName), engine(CoreSettings::Engine::Sparse) {
this->addOption(storm::settings::OptionBuilder(moduleName, counterexampleOptionName, false, "Generates a counterexample for the given PRCTL formulas if not satisfied by the model") this->addOption(storm::settings::OptionBuilder(moduleName, counterexampleOptionName, false, "Generates a counterexample for the given PRCTL formulas if not satisfied by the model")
.addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the file to which the counterexample is to be written.").setDefaultValueString("-").setIsOptional(true).build()).setShortName(counterexampleOptionShortName).build()); .addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "The name of the file to which the counterexample is to be written.").setDefaultValueString("-").setIsOptional(true).build()).setShortName(counterexampleOptionShortName).build());
this->addOption(storm::settings::OptionBuilder(moduleName, dontFixDeadlockOptionName, false, "If the model contains deadlock states, they need to be fixed by setting this option.").setShortName(dontFixDeadlockOptionShortName).build()); this->addOption(storm::settings::OptionBuilder(moduleName, dontFixDeadlockOptionName, false, "If the model contains deadlock states, they need to be fixed by setting this option.").setShortName(dontFixDeadlockOptionShortName).build());

3
src/settings/modules/ModuleSettings.h

@ -30,6 +30,7 @@ namespace storm {
* @param moduleName The name of the module for which to build the settings. * @param moduleName The name of the module for which to build the settings.
*/ */
ModuleSettings(std::string const& moduleName); ModuleSettings(std::string const& moduleName);
virtual ~ModuleSettings() {}
/*! /*!
* Checks whether the settings are consistent. If they are inconsistent, an exception is thrown. * Checks whether the settings are consistent. If they are inconsistent, an exception is thrown.
@ -140,4 +141,4 @@ namespace storm {
} // namespace settings } // namespace settings
} // namespace storm } // namespace storm
#endif /* STORM_SETTINGS_MODULES_MODULESETTINGS_H_ */
#endif /* STORM_SETTINGS_MODULES_MODULESETTINGS_H_ */

6
src/utility/storm.h

@ -115,10 +115,10 @@ namespace storm {
template<typename ValueType, storm::dd::DdType LibraryType = storm::dd::DdType::CUDD> template<typename ValueType, storm::dd::DdType LibraryType = storm::dd::DdType::CUDD>
std::shared_ptr<storm::models::symbolic::Model<LibraryType, ValueType>> buildSymbolicModel(storm::prism::Program const& program, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas) { std::shared_ptr<storm::models::symbolic::Model<LibraryType, ValueType>> buildSymbolicModel(storm::prism::Program const& program, std::vector<std::shared_ptr<storm::logic::Formula const>> const& formulas) {
typename storm::builder::DdPrismModelBuilder<LibraryType>::Options options;
options = typename storm::builder::DdPrismModelBuilder<LibraryType>::Options(formulas);
typename storm::builder::DdPrismModelBuilder<LibraryType, ValueType>::Options options;
options = typename storm::builder::DdPrismModelBuilder<LibraryType, ValueType>::Options(formulas);
storm::builder::DdPrismModelBuilder<LibraryType> builder;
storm::builder::DdPrismModelBuilder<LibraryType, ValueType> builder;
return builder.build(program, options); return builder.build(program, options);
} }

Loading…
Cancel
Save