#ifndef PERMISSIVESCHEDULERS_H #define PERMISSIVESCHEDULERS_H #include #include "../logic/ProbabilityOperatorFormula.h" #include "../models/sparse/Mdp.h" #include "../models/sparse/StandardRewardModel.h" namespace storm { namespace ps { class PermissiveScheduler { public: virtual ~PermissiveScheduler() = default; }; template> class SubMDPPermissiveScheduler : public PermissiveScheduler { storm::models::sparse::Mdp const &mdp; storm::storage::BitVector enabledChoices; public: virtual ~SubMDPPermissiveScheduler() = default; SubMDPPermissiveScheduler(SubMDPPermissiveScheduler &&) = default; SubMDPPermissiveScheduler(SubMDPPermissiveScheduler const &) = delete; SubMDPPermissiveScheduler(storm::models::sparse::Mdp const &refmdp, bool allEnabled) : PermissiveScheduler(), mdp(refmdp), enabledChoices(refmdp.getNumberOfChoices(), allEnabled) { // Intentionally left empty. } void disable(uint_fast64_t choiceIndex) { STORM_LOG_ASSERT(choiceIndex < enabledChoices.size(), "Invalid choiceIndex."); enabledChoices.set(choiceIndex, false); } storm::models::sparse::Mdp apply() const { storm::transformer::ChoiceSelector cs(mdp); return *(cs.transform(enabledChoices)->template as>()); } template std::map remapChoiceIndices(std::map const& in) const { std::map res; uint_fast64_t last = 0; uint_fast64_t curr = 0; storm::storage::BitVector::const_iterator it = enabledChoices.begin(); for(auto const& entry : in) { curr = entry.first; uint_fast64_t diff = last - curr; it += diff; res[*it] = entry.second; last = curr; } return res; } template std::map remapChoiceIndices(std::map const& in) const { std::map res; uint_fast64_t last = 0; uint_fast64_t curr = 0; storm::storage::BitVector::const_iterator it = enabledChoices.begin(); for(auto const& entry : in) { curr = mdp.getChoiceIndex(entry.first); uint_fast64_t diff = curr-last; it += diff; res[*it] = entry.second; last = curr; } return res; } }; template> boost::optional> computePermissiveSchedulerViaMILP(storm::models::sparse::Mdp const& mdp, storm::logic::ProbabilityOperatorFormula const &safeProp); template boost::optional> computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp const& mdp, storm::logic::ProbabilityOperatorFormula const& safeProp); } } #endif /* PERMISSIVESCHEDULERS_H */