|
@ -1,22 +1,45 @@ |
|
|
#include "storm/shields/PreSafetyShield.h"
|
|
|
#include "storm/shields/PreSafetyShield.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
namespace tempest { |
|
|
namespace tempest { |
|
|
namespace shields { |
|
|
namespace shields { |
|
|
|
|
|
|
|
|
template<typename ValueType, typename IndexType> |
|
|
template<typename ValueType, typename IndexType> |
|
|
PreSafetyShield<ValueType, IndexType>::PreSafetyShield(std::vector<IndexType> const& rowGroupIndices, std::vector<ValueType> const& choiceValues, std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression, boost::optional<storm::storage::BitVector> coalitionStates) : AbstractShield<ValueType, IndexType>(rowGroupIndices, choiceValues, shieldingExpression, coalitionStates) { |
|
|
|
|
|
|
|
|
PreSafetyShield<ValueType, IndexType>::PreSafetyShield(std::vector<IndexType> const& rowGroupIndices, std::vector<ValueType> const& choiceValues, std::shared_ptr<storm::logic::ShieldExpression const> const& shieldingExpression, storm::storage::BitVector relevantStates, boost::optional<storm::storage::BitVector> coalitionStates) : AbstractShield<ValueType, IndexType>(rowGroupIndices, choiceValues, shieldingExpression, relevantStates, coalitionStates) { |
|
|
// Intentionally left empty.
|
|
|
// Intentionally left empty.
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename ValueType, typename IndexType> |
|
|
template<typename ValueType, typename IndexType> |
|
|
storm::storage::Scheduler<ValueType> PreSafetyShield<ValueType, IndexType>::construct() { |
|
|
storm::storage::Scheduler<ValueType> PreSafetyShield<ValueType, IndexType>::construct() { |
|
|
for(auto const& x: this->rowGroupIndices) { |
|
|
|
|
|
STORM_LOG_DEBUG(x << ", "); |
|
|
|
|
|
|
|
|
storm::storage::Scheduler<ValueType> shield(this->rowGroupIndices.size()); |
|
|
|
|
|
STORM_LOG_DEBUG(this->rowGroupIndices.size()); |
|
|
|
|
|
STORM_LOG_DEBUG(this->relevantStates); |
|
|
|
|
|
for(auto const& x : this->choiceValues) { |
|
|
|
|
|
STORM_LOG_DEBUG(x << ","); |
|
|
} |
|
|
} |
|
|
for(auto const& x: this->choiceValues) { |
|
|
|
|
|
STORM_LOG_DEBUG(x << ", "); |
|
|
|
|
|
|
|
|
auto choice_it = this->choiceValues.begin(); |
|
|
|
|
|
for(uint state = 0; state < this->rowGroupIndices.size() - 1; state++) { |
|
|
|
|
|
if(this->relevantStates.get(state)) { |
|
|
|
|
|
uint rowGroupSize = this->rowGroupIndices[state + 1] - this->rowGroupIndices[state]; |
|
|
|
|
|
STORM_LOG_DEBUG("rowGroupSize: " << rowGroupSize); |
|
|
|
|
|
storm::storage::Distribution<ValueType, IndexType> actionDistribution; |
|
|
|
|
|
ValueType maxProbability = *std::max_element(this->choiceValues.begin(), this->choiceValues.begin() + rowGroupSize); |
|
|
|
|
|
for(uint choice = 0; choice < rowGroupSize; choice++, choice_it++) { |
|
|
|
|
|
if(allowedValue<ValueType, IndexType>(maxProbability, *choice_it, this->shieldingExpression)) { |
|
|
|
|
|
actionDistribution.addProbability(choice, *choice_it); |
|
|
|
|
|
STORM_LOG_DEBUG("Adding " << *choice_it << " to dist"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
actionDistribution.normalize(); |
|
|
|
|
|
shield.setChoice(storm::storage::SchedulerChoice<ValueType>(actionDistribution), state); |
|
|
|
|
|
STORM_LOG_DEBUG("SchedulerChoice: " << storm::storage::SchedulerChoice<ValueType>(actionDistribution)); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
shield.setChoice(storm::storage::Distribution<ValueType, IndexType>(), state); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
STORM_LOG_ASSERT(false, "construct NYI"); |
|
|
|
|
|
|
|
|
return shield; |
|
|
} |
|
|
} |
|
|
// Explicitly instantiate appropriate
|
|
|
// Explicitly instantiate appropriate
|
|
|
template class PreSafetyShield<double, typename storm::storage::SparseMatrix<double>::index_type>; |
|
|
template class PreSafetyShield<double, typename storm::storage::SparseMatrix<double>::index_type>; |
|
|