|
|
@ -275,15 +275,15 @@ namespace storm { |
|
|
|
template<typename ValueType> |
|
|
|
std::vector<ValueType> SparseMdpPrctlHelper<ValueType>::computeReachabilityRewardsHelper(OptimizationDirection dir, storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::SparseMatrix<ValueType> const& backwardTransitions, std::function<std::vector<ValueType>(uint_fast64_t, storm::storage::SparseMatrix<ValueType> const&, storm::storage::BitVector const&)> const& totalStateRewardVectorGetter, storm::storage::BitVector const& targetStates, bool qualitative, storm::utility::solver::MinMaxLinearEquationSolverFactory<ValueType> const& minMaxLinearEquationSolverFactory) { |
|
|
|
|
|
|
|
std::vector<uint_fast64_t> nondeterminsticChoiceIndices = transitionMatrix.getRowGroupIndices(); |
|
|
|
std::vector<uint_fast64_t> const& nondeterministicChoiceIndices = transitionMatrix.getRowGroupIndices(); |
|
|
|
|
|
|
|
// Determine which states have a reward of infinity by definition.
|
|
|
|
storm::storage::BitVector infinityStates; |
|
|
|
storm::storage::BitVector trueStates(transitionMatrix.getRowGroupCount(), true); |
|
|
|
if (dir == OptimizationDirection::Minimize) { |
|
|
|
infinityStates = storm::utility::graph::performProb1E(transitionMatrix, nondeterminsticChoiceIndices, backwardTransitions, trueStates, targetStates); |
|
|
|
infinityStates = storm::utility::graph::performProb1E(transitionMatrix, nondeterministicChoiceIndices, backwardTransitions, trueStates, targetStates); |
|
|
|
} else { |
|
|
|
infinityStates = storm::utility::graph::performProb1A(transitionMatrix, nondeterminsticChoiceIndices, backwardTransitions, trueStates, targetStates); |
|
|
|
infinityStates = storm::utility::graph::performProb1A(transitionMatrix, nondeterministicChoiceIndices, backwardTransitions, trueStates, targetStates); |
|
|
|
} |
|
|
|
infinityStates.complement(); |
|
|
|
storm::storage::BitVector maybeStates = ~targetStates & ~infinityStates; |
|
|
@ -310,13 +310,12 @@ namespace storm { |
|
|
|
|
|
|
|
// Prepare the right-hand side of the equation system.
|
|
|
|
std::vector<ValueType> b = totalStateRewardVectorGetter(submatrix.getRowCount(), transitionMatrix, maybeStates); |
|
|
|
|
|
|
|
// This also means that -- when minimizing -- we have to set the entries to infinity that have
|
|
|
|
// any successor that is an "infinity state". This prevents the action from "being taken" and
|
|
|
|
// forces the choice that leads to a reward less than infinity.
|
|
|
|
|
|
|
|
// Since we are cutting away target and infinity states, we need to account for this by giving
|
|
|
|
// choices the value infinity that have some successor contained in the infinity states.
|
|
|
|
uint_fast64_t currentRow = 0; |
|
|
|
for (auto state : maybeStates) { |
|
|
|
for (uint_fast64_t row = nondeterminsticChoiceIndices[state]; row < nondeterminsticChoiceIndices[state + 1]; ++row, ++currentRow) { |
|
|
|
for (uint_fast64_t row = nondeterministicChoiceIndices[state]; row < nondeterministicChoiceIndices[state + 1]; ++row, ++currentRow) { |
|
|
|
for (auto const& element : transitionMatrix.getRow(row)) { |
|
|
|
if (infinityStates.get(element.getColumn())) { |
|
|
|
b[currentRow] = storm::utility::infinity<ValueType>(); |
|
|
@ -327,7 +326,7 @@ namespace storm { |
|
|
|
} |
|
|
|
|
|
|
|
// Create vector for results for maybe states.
|
|
|
|
std::vector<ValueType> x(maybeStates.getNumberOfSetBits()); |
|
|
|
std::vector<ValueType> x(maybeStates.getNumberOfSetBits(), storm::utility::zero<ValueType>()); |
|
|
|
|
|
|
|
// Solve the corresponding system of equations.
|
|
|
|
std::unique_ptr<storm::solver::MinMaxLinearEquationSolver<ValueType>> solver = minMaxLinearEquationSolverFactory.create(submatrix); |
|
|
|