12namespace modelchecker {
13namespace multiobjective {
15template<
class SparseMdpModelType>
22template<
class SparseMdpModelType>
25 this->actionRewards.resize(this->objectives.size());
26 for (uint_fast64_t objIndex = 0; objIndex < this->objectives.size(); ++objIndex) {
27 auto const& formula = *this->objectives[objIndex].formula;
28 STORM_LOG_THROW(formula.isRewardOperatorFormula() && formula.asRewardOperatorFormula().hasRewardModelName(), storm::exceptions::UnexpectedException,
29 "Unexpected type of operator formula: " << formula);
30 if (formula.getSubformula().isCumulativeRewardFormula()) {
31 auto const& cumulativeRewardFormula = formula.getSubformula().asCumulativeRewardFormula();
32 STORM_LOG_THROW(!cumulativeRewardFormula.isMultiDimensional() && !cumulativeRewardFormula.getTimeBoundReference().isRewardBound(),
33 storm::exceptions::UnexpectedException,
"Unexpected type of sub-formula: " << formula.getSubformula());
35 STORM_LOG_THROW(formula.getSubformula().isTotalRewardFormula() || formula.getSubformula().isLongRunAverageRewardFormula(),
36 storm::exceptions::UnexpectedException,
"Unexpected type of sub-formula: " << formula.getSubformula());
38 typename SparseMdpModelType::RewardModelType
const& rewModel = model.getRewardModel(formula.asRewardOperatorFormula().getRewardModelName());
39 STORM_LOG_THROW(!rewModel.hasTransitionRewards(), storm::exceptions::NotSupportedException,
40 "Reward model has transition rewards which is not expected.");
41 this->actionRewards[objIndex] = rewModel.getTotalRewardVector(model.getTransitionMatrix());
45template<
class SparseMdpModelType>
52template<
class SparseMdpModelType>
59template<
class SparseMdpModelType>
61 std::vector<ValueType>& weightedRewardVector) {
63 std::vector<uint_fast64_t> optimalChoicesInCurrentEpoch(this->transitionMatrix.getRowGroupCount());
64 std::vector<ValueType> choiceValues(weightedRewardVector.size());
65 std::vector<ValueType> temporaryResult(this->transitionMatrix.getRowGroupCount());
67 std::map<uint_fast64_t, storm::storage::BitVector, std::greater<uint_fast64_t>> stepBounds;
68 for (uint_fast64_t objIndex = 0; objIndex < this->objectives.size(); ++objIndex) {
69 if (this->objectives[objIndex].formula->getSubformula().isCumulativeRewardFormula()) {
70 auto const& subformula = this->objectives[objIndex].formula->getSubformula().asCumulativeRewardFormula();
71 uint_fast64_t stepBound = subformula.template getBound<uint_fast64_t>();
72 if (subformula.isBoundStrict()) {
75 auto stepBoundIt = stepBounds.insert(std::make_pair(stepBound,
storm::storage::BitVector(this->objectives.size(),
false))).first;
76 stepBoundIt->second.set(objIndex);
79 this->offsetsToAchievablePoint[objIndex] = storm::utility::zero<ValueType>();
86 auto stepBoundIt = stepBounds.
begin();
87 uint_fast64_t currentEpoch = stepBounds.empty() ? 0 : stepBoundIt->first;
89 while (currentEpoch > 0) {
90 if (stepBoundIt != stepBounds.end() && currentEpoch == stepBoundIt->first) {
91 consideredObjectives |= stepBoundIt->second;
92 for (
auto objIndex : stepBoundIt->second) {
95 storm::solver::minimize(this->objectives[objIndex].formula->getOptimalityType()) ? -weightVector[objIndex] : weightVector[objIndex];
102 this->transitionMatrix.multiplyWithVector(this->weightedResult, choiceValues);
107 for (
auto objIndex : consideredObjectives) {
108 std::vector<ValueType>& objectiveResult = this->objectiveResults[objIndex];
109 std::vector<ValueType>
const& objectiveRewards = this->actionRewards[objIndex];
110 auto rowGroupIndexIt = this->transitionMatrix.getRowGroupIndices().begin();
111 auto optimalChoiceIt = optimalChoicesInCurrentEpoch.begin();
112 for (ValueType& stateValue : temporaryResult) {
113 uint_fast64_t row = (*rowGroupIndexIt) + (*optimalChoiceIt);
116 stateValue = objectiveRewards[row];
117 for (
auto const& entry : this->transitionMatrix.getRow(row)) {
118 stateValue += entry.getValue() * objectiveResult[entry.getColumn()];
121 objectiveResult.swap(temporaryResult);
127template<
class SparseMdpModelType>
129 return this->getWeightedPrecision();
132template<
class SparseMdpModelType>
134 return storm::utility::zero<ValueType>();
Helper class for model checking queries that depend on the long run behavior of the (nondeterministic...
Helper class for model checking queries that depend on the long run behavior of the (nondeterministic...
Helper Class that takes preprocessed Pcaa data and a weight vector and ...
virtual storm::modelchecker::helper::SparseNondeterministicInfiniteHorizonHelper< ValueType > createNondetInfiniteHorizonHelper(storm::storage::SparseMatrix< ValueType > const &transitions) const override
StandardMdpPcaaWeightVectorChecker(preprocessing::SparseMultiObjectivePreprocessorResult< SparseMdpModelType > const &preprocessorResult)
virtual ValueType getWeightedPrecisionUnboundedPhase() const override
virtual void initializeModelTypeSpecificData(SparseMdpModelType const &model) override
virtual storm::modelchecker::helper::SparseDeterministicInfiniteHorizonHelper< ValueType > createDetInfiniteHorizonHelper(storm::storage::SparseMatrix< ValueType > const &transitions) const override
virtual ValueType getWeightedPrecisionBoundedPhase() const override
Helper Class that takes preprocessed Pcaa data and a weight vector and ...
void initialize(preprocessing::SparseMultiObjectivePreprocessorResult< SparseMdpModelType > const &preprocessorResult)
A bit vector that is internally represented as a vector of 64-bit values.
const_iterator begin() const
Returns an iterator to the indices of the set bits in the bit vector.
A class that holds a possibly non-square matrix in the compressed row storage format.
index_type getRowGroupCount() const
Returns the number of row groups in the matrix.
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
bool constexpr minimize(OptimizationDirection d)
void addVectors(std::vector< InValueType1 > const &firstOperand, std::vector< InValueType2 > const &secondOperand, std::vector< OutValueType > &target)
Adds the two given vectors and writes the result to the target vector.
void addScaledVector(std::vector< InValueType1 > &firstOperand, std::vector< InValueType2 > const &secondOperand, InValueType3 const &factor)
Computes x:= x + a*y, i.e., adds each element of the first vector and (the corresponding element of t...
void reduceVectorMax(std::vector< T > const &source, std::vector< T > &target, std::vector< uint_fast64_t > const &rowGrouping, std::vector< uint_fast64_t > *choices=nullptr)
Reduces the given source vector by selecting the largest element out of each row group.