diff --git a/src/storm/shields/OptimalShield.cpp b/src/storm/shields/OptimalShield.cpp new file mode 100644 index 000000000..0bd26908d --- /dev/null +++ b/src/storm/shields/OptimalShield.cpp @@ -0,0 +1,35 @@ +#include "storm/shields/OptimalShield.h" + +#include + +namespace tempest { + namespace shields { + + template + OptimalShield::OptimalShield(std::vector const& rowGroupIndices, std::vector const& precomputedChoices, std::shared_ptr const& shieldingExpression, storm::OptimizationDirection optimizationDirection, storm::storage::BitVector relevantStates, boost::optional coalitionStates) : AbstractShield(rowGroupIndices, shieldingExpression, optimizationDirection, relevantStates, coalitionStates), precomputedChoices(precomputedChoices) { + // Intentionally left empty. + } + + template + storm::storage::OptimalScheduler OptimalShield::construct() { + storm::storage::OptimalScheduler shield(this->rowGroupIndices.size() - 1); + // TODO Needs fixing as soon as we support MDPs + if(this->coalitionStates.is_initialized()) { + this->relevantStates = ~this->relevantStates; + } + for(uint state = 0; state < this->rowGroupIndices.size() - 1; state++) { + if(this->relevantStates.get(state)) { + shield.setChoice(precomputedChoices[state], state); + } else { + shield.setChoice(storm::storage::Distribution(), state); + } + } + return shield; + } + // Explicitly instantiate appropriate + template class OptimalShield::index_type>; +#ifdef STORM_HAVE_CARL + template class OptimalShield::index_type>; +#endif + } +} diff --git a/src/storm/shields/OptimalShield.h b/src/storm/shields/OptimalShield.h new file mode 100644 index 000000000..03bff3542 --- /dev/null +++ b/src/storm/shields/OptimalShield.h @@ -0,0 +1,19 @@ +#pragma once + +#include "storm/shields/AbstractShield.h" +#include "storm/storage/OptimalScheduler.h" + +namespace tempest { + namespace shields { + + template + class OptimalShield : public AbstractShield { + public: + OptimalShield(std::vector const& rowGroupIndices, std::vector const& precomputedChoices, std::shared_ptr const& shieldingExpression, storm::OptimizationDirection optimizationDirection, storm::storage::BitVector relevantStates, boost::optional coalitionStates); + + storm::storage::OptimalScheduler construct(); + private: + std::vector precomputedChoices; + }; + } +}