Browse Source

reduced the calculation part to a call to multiplyAndReduce in SparseSmgRpatlHelper.cpp

tempestpy_adaptions
Lukas Posch 4 years ago
parent
commit
2f39eab91e
  1. 12
      src/storm/modelchecker/rpatl/helper/SparseSmgRpatlHelper.cpp
  2. 10
      src/storm/modelchecker/rpatl/helper/internal/GameViHelper.cpp
  3. 2
      src/storm/modelchecker/rpatl/helper/internal/GameViHelper.h

12
src/storm/modelchecker/rpatl/helper/SparseSmgRpatlHelper.cpp

@ -87,22 +87,26 @@ namespace storm {
template<typename ValueType>
MDPSparseModelCheckingHelperReturnType<ValueType> SparseSmgRpatlHelper<ValueType>::computeNextProbabilities(Environment const& env, storm::solver::SolveGoal<ValueType>&& goal, storm::storage::SparseMatrix<ValueType> const& transitionMatrix, storm::storage::SparseMatrix<ValueType> const& backwardTransitions, storm::storage::BitVector const& psiStates, bool qualitative, storm::storage::BitVector statesOfCoalition, bool produceScheduler, ModelCheckerHint const& hint) {
// create vector x for result, bitvector allStates with a true for each state and a vector b for the probability to get to state psi
std::vector<ValueType> x = std::vector<ValueType>(transitionMatrix.getRowGroupCount(), storm::utility::zero<ValueType>());
storm::storage::BitVector allStates = storm::storage::BitVector(transitionMatrix.getRowGroupCount(), true);
std::vector<ValueType> b = transitionMatrix.getConstrainedRowGroupSumVector(allStates, psiStates);
// coalition handling for all states
storm::storage::BitVector clippedStatesOfCoalition(transitionMatrix.getRowGroupCount());
clippedStatesOfCoalition.setClippedStatesOfCoalition(allStates, statesOfCoalition);
clippedStatesOfCoalition.complement();
storm::modelchecker::helper::internal::GameViHelper<ValueType> viHelper(transitionMatrix, clippedStatesOfCoalition);
std::unique_ptr<storm::storage::Scheduler<ValueType>> scheduler;
if (produceScheduler) {
STORM_LOG_WARN("Next formula does not expect that produceScheduler is set to true.");
}
viHelper.performNextIteration(env, x, b, goal.direction());
return MDPSparseModelCheckingHelperReturnType<ValueType>(std::move(x), std::move(scheduler));
// create multiplier and execute the calculation for 1 step
auto multiplier = storm::solver::MultiplierFactory<ValueType>().create(env, transitionMatrix);
multiplier->multiplyAndReduce(env, goal.direction(), x, &b, x, nullptr, &statesOfCoalition);
//STORM_LOG_DEBUG("x = " << storm::utility::vector::toString(x));
return MDPSparseModelCheckingHelperReturnType<ValueType>(std::move(x));
}
template class SparseSmgRpatlHelper<double>;

10
src/storm/modelchecker/rpatl/helper/internal/GameViHelper.cpp

@ -151,16 +151,6 @@ namespace storm {
}
template <typename ValueType>
void GameViHelper<ValueType>::performNextIteration(Environment const& env, std::vector<ValueType>& x, std::vector<ValueType> b, storm::solver::OptimizationDirection const dir) {
prepareSolversAndMultipliersReachability(env);
_b = b;
_x1.assign(_transitionMatrix.getRowGroupCount(), storm::utility::zero<ValueType>());
_x2 = _x1;
performIterationStep(env, dir);
x = xNew();
}
template <typename ValueType>
void GameViHelper<ValueType>::setProduceScheduler(bool value) {
_produceScheduler = value;
}

2
src/storm/modelchecker/rpatl/helper/internal/GameViHelper.h

@ -30,8 +30,6 @@ namespace storm {
*/
void fillResultVector(std::vector<ValueType>& result, storm::storage::BitVector relevantStates, storm::storage::BitVector psiStates);
void performNextIteration(Environment const& env, std::vector<ValueType>& x, std::vector<ValueType> b, storm::solver::OptimizationDirection const dir);
/*h
* Sets whether an optimal scheduler shall be constructed during the computation
*/

Loading…
Cancel
Save