|
@ -127,12 +127,12 @@ namespace storm { |
|
|
|
|
|
|
|
|
template<typename ValueType, typename RewardModelType> |
|
|
template<typename ValueType, typename RewardModelType> |
|
|
std::vector<ValueType> SparseDtmcPrctlHelper<ValueType, RewardModelType>::computeCumulativeRewards(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, RewardModelType const& rewardModel, uint_fast64_t stepBound, storm::utility::solver::LinearEquationSolverFactory<ValueType> const& linearEquationSolverFactory) { |
|
|
std::vector<ValueType> SparseDtmcPrctlHelper<ValueType, RewardModelType>::computeCumulativeRewards(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, RewardModelType const& rewardModel, uint_fast64_t stepBound, storm::utility::solver::LinearEquationSolverFactory<ValueType> const& linearEquationSolverFactory) { |
|
|
|
|
|
// Initialize result to the null vector.
|
|
|
|
|
|
std::vector<ValueType> result(transitionMatrix.getRowCount()); |
|
|
|
|
|
|
|
|
// Compute the reward vector to add in each step based on the available reward models.
|
|
|
// Compute the reward vector to add in each step based on the available reward models.
|
|
|
std::vector<ValueType> totalRewardVector = rewardModel.getTotalRewardVector(transitionMatrix); |
|
|
std::vector<ValueType> totalRewardVector = rewardModel.getTotalRewardVector(transitionMatrix); |
|
|
|
|
|
|
|
|
// Initialize result to either the state rewards of the model or the null vector.
|
|
|
|
|
|
std::vector<ValueType> result = rewardModel.getTotalStateActionRewardVector(transitionMatrix.getRowCount(), transitionMatrix.getRowGroupIndices()); |
|
|
|
|
|
|
|
|
|
|
|
// Perform the matrix vector multiplication as often as required by the formula bound.
|
|
|
// Perform the matrix vector multiplication as often as required by the formula bound.
|
|
|
std::unique_ptr<storm::solver::LinearEquationSolver<ValueType>> solver = linearEquationSolverFactory.create(transitionMatrix); |
|
|
std::unique_ptr<storm::solver::LinearEquationSolver<ValueType>> solver = linearEquationSolverFactory.create(transitionMatrix); |
|
|
solver->performMatrixVectorMultiplication(result, &totalRewardVector, stepBound); |
|
|
solver->performMatrixVectorMultiplication(result, &totalRewardVector, stepBound); |
|
|