Sebastian Junges
4 years ago
6 changed files with 120 additions and 45 deletions
-
86src/storm/modelchecker/helper/finitehorizon/SparseNondeterministicStepBoundedHorizonHelper.cpp
-
25src/storm/modelchecker/helper/finitehorizon/SparseNondeterministicStepBoundedHorizonHelper.h
-
5src/storm/modelchecker/prctl/SparseDtmcPrctlModelChecker.cpp
-
7src/storm/modelchecker/prctl/SparseMdpPrctlModelChecker.cpp
-
40src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.cpp
-
2src/storm/modelchecker/prctl/helper/SparseMdpPrctlHelper.h
@ -0,0 +1,86 @@ |
|||
#include "storm/modelchecker/helper/finitehorizon/SparseNondeterministicStepBoundedHorizonHelper.h"
|
|||
#include "storm/modelchecker/hints/ExplicitModelCheckerHint.h"
|
|||
#include "storm/modelchecker/prctl/helper/SparseMdpEndComponentInformation.h"
|
|||
|
|||
#include "storm/models/sparse/StandardRewardModel.h"
|
|||
|
|||
#include "storm/utility/macros.h"
|
|||
#include "storm/utility/vector.h"
|
|||
#include "storm/utility/graph.h"
|
|||
|
|||
#include "storm/storage/expressions/Expression.h"
|
|||
#include "storm/solver/Multiplier.h"
|
|||
#include "storm/utility/SignalHandler.h"
|
|||
#include "storm/environment/solver/MinMaxSolverEnvironment.h"
|
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace helper { |
|||
|
|||
template<typename ValueType> |
|||
SparseNondeterministicStepBoundedHorizonHelper<ValueType>::SparseNondeterministicStepBoundedHorizonHelper(/*storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::SparseMatrix<ValueType> const& backwardTransitions*/) |
|||
//transitionMatrix(transitionMatrix), backwardTransitions(backwardTransitions)
|
|||
{ |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
template<typename ValueType> |
|||
std::vector<ValueType> SparseNondeterministicStepBoundedHorizonHelper<ValueType>::compute(Environment const& env, storm::solver::SolveGoal<ValueType>&& goal, storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::SparseMatrix<ValueType> const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, uint64_t lowerBound, uint64_t upperBound, ModelCheckerHint const& hint) |
|||
{ |
|||
std::vector<ValueType> result(transitionMatrix.getRowGroupCount(), storm::utility::zero<ValueType>()); |
|||
storm::storage::BitVector makeZeroColumns; |
|||
|
|||
|
|||
// Determine the states that have 0 probability of reaching the target states.
|
|||
storm::storage::BitVector maybeStates; |
|||
if (hint.isExplicitModelCheckerHint() && hint.template asExplicitModelCheckerHint<ValueType>().getComputeOnlyMaybeStates()) { |
|||
maybeStates = hint.template asExplicitModelCheckerHint<ValueType>().getMaybeStates(); |
|||
} else { |
|||
if (goal.minimize()) { |
|||
maybeStates = storm::utility::graph::performProbGreater0A(transitionMatrix, transitionMatrix.getRowGroupIndices(), backwardTransitions, phiStates, psiStates, true, upperBound); |
|||
} else { |
|||
maybeStates = storm::utility::graph::performProbGreater0E(backwardTransitions, phiStates, psiStates, true, upperBound); |
|||
} |
|||
if (lowerBound == 0) { |
|||
maybeStates &= ~psiStates; |
|||
} else { |
|||
makeZeroColumns = psiStates; |
|||
} |
|||
|
|||
} |
|||
|
|||
STORM_LOG_INFO("Preprocessing: " << maybeStates.getNumberOfSetBits() << " non-target states with probability greater 0."); |
|||
|
|||
if (!maybeStates.empty()) { |
|||
// We can eliminate the rows and columns from the original transition probability matrix that have probability 0.
|
|||
storm::storage::SparseMatrix<ValueType> submatrix = transitionMatrix.getSubmatrix(true, maybeStates, maybeStates, false, makeZeroColumns); |
|||
std::vector<ValueType> b = transitionMatrix.getConstrainedRowGroupSumVector(maybeStates, psiStates); |
|||
|
|||
// Create the vector with which to multiply.
|
|||
std::vector<ValueType> subresult(maybeStates.getNumberOfSetBits()); |
|||
|
|||
auto multiplier = storm::solver::MultiplierFactory<ValueType>().create(env, submatrix); |
|||
if (lowerBound == 0) { |
|||
multiplier->repeatedMultiplyAndReduce(env, goal.direction(), subresult, &b, upperBound); |
|||
} else { |
|||
multiplier->repeatedMultiplyAndReduce(env, goal.direction(), subresult, &b, upperBound - lowerBound + 1); |
|||
storm::storage::SparseMatrix<ValueType> submatrix = transitionMatrix.getSubmatrix(true, maybeStates, maybeStates, false); |
|||
auto multiplier = storm::solver::MultiplierFactory<ValueType>().create(env, submatrix); |
|||
b = std::vector<ValueType>(b.size(), storm::utility::zero<ValueType>()); |
|||
multiplier->repeatedMultiplyAndReduce(env, goal.direction(), subresult, &b, lowerBound - 1); |
|||
} |
|||
// Set the values of the resulting vector accordingly.
|
|||
storm::utility::vector::setVectorValues(result, maybeStates, subresult); |
|||
} |
|||
if (lowerBound == 0) { |
|||
storm::utility::vector::setVectorValues(result, psiStates, storm::utility::one<ValueType>()); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
|
|||
template class SparseNondeterministicStepBoundedHorizonHelper<double>; |
|||
template class SparseNondeterministicStepBoundedHorizonHelper<storm::RationalNumber>; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
#pragma once |
|||
|
|||
|
|||
#include "storm/modelchecker/hints/ModelCheckerHint.h" |
|||
#include "storm/modelchecker/prctl/helper/SolutionType.h" |
|||
#include "storm/storage/SparseMatrix.h" |
|||
#include "storm/utility/solver.h" |
|||
#include "storm/solver/SolveGoal.h" |
|||
|
|||
namespace storm { |
|||
namespace modelchecker { |
|||
namespace helper { |
|||
|
|||
template<typename ValueType> |
|||
class SparseNondeterministicStepBoundedHorizonHelper { |
|||
public: |
|||
SparseNondeterministicStepBoundedHorizonHelper(); |
|||
std::vector<ValueType> compute(Environment const& env, storm::solver::SolveGoal<ValueType>&& goal, storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::SparseMatrix<ValueType> const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates, uint64_t lowerBound, uint64_t upperBound, ModelCheckerHint const& hint = ModelCheckerHint()); |
|||
private: |
|||
}; |
|||
|
|||
|
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue