|
|
@ -23,34 +23,18 @@ namespace storm { |
|
|
|
|
|
|
|
// Initialize the solution vector.
|
|
|
|
std::vector<ValueType> x = std::vector<ValueType>(transitionMatrix.getRowGroupCount() - psiStates.getNumberOfSetBits(), storm::utility::zero<ValueType>()); |
|
|
|
std::vector<ValueType> b = transitionMatrix.getConstrainedRowGroupSumVector(~psiStates, psiStates); |
|
|
|
|
|
|
|
// Reduce matrix to ~Prob1 states-
|
|
|
|
//STORM_LOG_DEBUG("\n" << transitionMatrix);
|
|
|
|
storm::storage::SparseMatrix<ValueType> submatrix = transitionMatrix.getSubmatrix(true, ~psiStates, ~psiStates, false); |
|
|
|
//STORM_LOG_DEBUG("\n" << submatrix);
|
|
|
|
// Relevant states are those states which are phiStates and not PsiStates.
|
|
|
|
storm::storage::BitVector relevantStates = phiStates & ~psiStates; |
|
|
|
|
|
|
|
std::vector<ValueType> b = transitionMatrix.getConstrainedRowGroupSumVector(relevantStates, psiStates); |
|
|
|
|
|
|
|
//STORM_LOG_DEBUG("x = " << storm::utility::vector::toString(x));
|
|
|
|
//STORM_LOG_DEBUG("b = " << storm::utility::vector::toString(b));
|
|
|
|
// Reduce the matrix to relevant states
|
|
|
|
storm::storage::SparseMatrix<ValueType> submatrix = transitionMatrix.getSubmatrix(true, relevantStates, relevantStates, false); |
|
|
|
|
|
|
|
storm::storage::BitVector clippedStatesOfCoalition(statesOfCoalition.size() - psiStates.getNumberOfSetBits()); |
|
|
|
//STORM_LOG_DEBUG(psiStates);
|
|
|
|
//STORM_LOG_DEBUG(statesOfCoalition);
|
|
|
|
//STORM_LOG_DEBUG(clippedStatesOfCoalition);
|
|
|
|
|
|
|
|
// TODO move this to BitVector-class
|
|
|
|
auto clippedStatesCounter = 0; |
|
|
|
for(uint i = 0; i < psiStates.size(); i++) { |
|
|
|
std::cout << i << " : " << psiStates.get(i) << " -> " << statesOfCoalition[i] << std::endl; |
|
|
|
if(!psiStates.get(i)) { |
|
|
|
clippedStatesOfCoalition.set(clippedStatesCounter, statesOfCoalition[i]); |
|
|
|
clippedStatesCounter++; |
|
|
|
} |
|
|
|
} |
|
|
|
//STORM_LOG_DEBUG(clippedStatesOfCoalition);
|
|
|
|
storm::storage::BitVector clippedStatesOfCoalition(relevantStates.getNumberOfSetBits()); |
|
|
|
clippedStatesOfCoalition.setClippedStatesOfCoalition(relevantStates, statesOfCoalition); |
|
|
|
clippedStatesOfCoalition.complement(); |
|
|
|
//STORM_LOG_DEBUG(clippedStatesOfCoalition);
|
|
|
|
|
|
|
|
storm::modelchecker::helper::internal::GameViHelper<ValueType> viHelper(submatrix, clippedStatesOfCoalition); |
|
|
|
std::unique_ptr<storm::storage::Scheduler<ValueType>> scheduler; |
|
|
@ -59,27 +43,26 @@ namespace storm { |
|
|
|
} |
|
|
|
|
|
|
|
viHelper.performValueIteration(env, x, b, goal.direction()); |
|
|
|
viHelper.fillResultVector(x, relevantStates, psiStates); |
|
|
|
|
|
|
|
STORM_LOG_DEBUG(storm::utility::vector::toString(x)); |
|
|
|
if (produceScheduler) { |
|
|
|
scheduler = std::make_unique<storm::storage::Scheduler<ValueType>>(expandScheduler(viHelper.extractScheduler(), psiStates)); |
|
|
|
STORM_LOG_DEBUG("IsPartial?" << scheduler->isPartialScheduler()); |
|
|
|
scheduler = std::make_unique<storm::storage::Scheduler<ValueType>>(expandScheduler(viHelper.extractScheduler(), psiStates, ~phiStates)); |
|
|
|
} |
|
|
|
return MDPSparseModelCheckingHelperReturnType<ValueType>(std::move(x), std::move(scheduler)); |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ValueType> |
|
|
|
storm::storage::Scheduler<ValueType> SparseSmgRpatlHelper<ValueType>::expandScheduler(storm::storage::Scheduler<ValueType> scheduler, storm::storage::BitVector psiStates) { |
|
|
|
//STORM_LOG_DEBUG(psiStates.size());
|
|
|
|
for(uint i = 0; i < 2; i++) { |
|
|
|
//STORM_LOG_DEBUG(scheduler.getChoice(i));
|
|
|
|
} |
|
|
|
storm::storage::Scheduler<ValueType> SparseSmgRpatlHelper<ValueType>::expandScheduler(storm::storage::Scheduler<ValueType> scheduler, storm::storage::BitVector psiStates, storm::storage::BitVector notPhiStates) { |
|
|
|
storm::storage::Scheduler<ValueType> completeScheduler(psiStates.size()); |
|
|
|
uint_fast64_t maybeStatesCounter = 0; |
|
|
|
for(uint stateCounter = 0; stateCounter < psiStates.size(); stateCounter++) { |
|
|
|
//STORM_LOG_DEBUG(stateCounter << " : " << psiStates.get(stateCounter));
|
|
|
|
uint schedulerSize = psiStates.size(); |
|
|
|
for(uint stateCounter = 0; stateCounter < schedulerSize; stateCounter++) { |
|
|
|
// psiStates already fulfill formulae so we can set an arbitrary action
|
|
|
|
if(psiStates.get(stateCounter)) { |
|
|
|
completeScheduler.setChoice(0, stateCounter); |
|
|
|
// ~phiStates do not fulfill formulae so we can set an arbitrary action
|
|
|
|
} else if(notPhiStates.get(stateCounter)) { |
|
|
|
completeScheduler.setChoice(0, stateCounter); |
|
|
|
} else { |
|
|
|
completeScheduler.setChoice(scheduler.getChoice(maybeStatesCounter), stateCounter); |
|
|
|
maybeStatesCounter++; |
|
|
|