37template<
typename ValueType,
typename SolutionType>
42 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We do not support computing reward bounded values with interval models.");
55 std::vector<ValueType> x, b;
56 std::unique_ptr<storm::solver::MinMaxLinearEquationSolver<ValueType>> minMaxSolver;
65 std::vector<std::vector<ValueType>> cdfData;
70 uint64_t numCheckedEpochs = 0;
71 for (
auto const& epoch : epochOrder) {
76 rewardUnfolding.
setSolutionForCurrentEpoch(epochModel.analyzeSingleObjective(preciseEnv, dir, x, b, minMaxSolver, lowerBound, upperBound));
79 std::vector<ValueType> cdfEntry;
80 for (uint64_t i = 0; i < rewardUnfolding.
getEpochManager().getDimensionCount(); ++i) {
86 cdfData.push_back(std::move(cdfEntry));
95 std::vector<ValueType> result;
97 for (uint64_t initState : initialStates) {
104 std::vector<std::string> headers;
105 for (uint64_t i = 0; i < rewardUnfolding.
getEpochManager().getDimensionCount(); ++i) {
106 headers.push_back(rewardUnfolding.
getDimension(i).formula->toString());
108 headers.push_back(
"Result");
125template<
typename ValueType,
typename SolutionType>
134 multiplier->multiplyAndReduce(env, dir, result,
nullptr, result, uncertaintyResolutionMode);
139template<
typename ValueType,
typename SolutionType = ValueType>
145 boost::optional<storm::storage::BitVector>
const& selectedChoices) {
153 validScheduler, selectedChoices);
159 std::vector<uint64_t> schedulerHint;
161 if (selectedChoices) {
163 for (uint64_t maybeState : maybeStates) {
164 auto choice = validScheduler.
getChoice(maybeState).getDeterministicChoice();
166 auto const origGlobalChoiceIndex = groupStart + choice;
167 STORM_LOG_ASSERT(selectedChoices->get(origGlobalChoiceIndex),
"The computed scheduler selects an illegal choice.");
169 for (
auto pos = selectedChoices->getNextUnsetIndex(groupStart); pos < origGlobalChoiceIndex; pos = selectedChoices->getNextUnsetIndex(pos + 1)) {
172 schedulerHint.push_back(choice);
175 for (uint64_t maybeState : maybeStates) {
176 schedulerHint.push_back(validScheduler.
getChoice(maybeState).getDeterministicChoice());
179 return schedulerHint;
182template<
typename ValueType>
259template<
typename ValueType,
typename SolutionType>
262 boost::optional<storm::storage::BitVector>
const& selectedChoices,
ModelCheckerHint const& hint,
263 bool skipECWithinMaybeStatesCheck) {
267 STORM_LOG_WARN(
"A scheduler hint was provided, but the solver requires a specific one. The provided scheduler hint will be ignored.");
269 auto const& schedulerHint = hint.template asExplicitModelCheckerHint<ValueType>().getSchedulerHint();
270 std::vector<uint64_t> hintChoices;
274 if (!skipECWithinMaybeStatesCheck) {
275 hintChoices.reserve(maybeStates.
size());
276 for (uint_fast64_t state = 0; state < maybeStates.
size(); ++state) {
277 hintChoices.push_back(schedulerHint.getChoice(state).getDeterministicChoice());
282 hintApplicable =
true;
285 if (hintApplicable) {
289 for (uint64_t state : maybeStates) {
290 uint_fast64_t hintChoice = schedulerHint.getChoice(state).getDeterministicChoice();
291 if (selectedChoices) {
293 uint_fast64_t lastChoice = firstChoice + hintChoice;
295 for (uint_fast64_t choice = selectedChoices->getNextSetIndex(firstChoice); choice < lastChoice;
296 choice = selectedChoices->getNextSetIndex(choice + 1)) {
300 hintChoices.push_back(hintChoice);
318template<
typename ValueType,
typename SolutionType>
323 boost::optional<storm::storage::BitVector>
const& selectedChoices = boost::none,
bool hasUniqueSolution =
false) {
337 bool hasSchedulerHint = hint.
isExplicitModelCheckerHint() && hint.template asExplicitModelCheckerHint<ValueType>().hasSchedulerHint();
345 "The solver requires to eliminate the end components although the solution is already assumed to be unique.");
346 STORM_LOG_DEBUG(
"Scheduling EC elimination, because the solver requires a unique solution.");
358 STORM_LOG_DEBUG(
"Computing valid scheduler, because the solver requires it.");
360 targetStates, selectedChoices);
386 STORM_LOG_TRACE(
"Warn A non-empty hint was provided, but its information will be disregarded.");
406template<
typename ValueType>
430template<
typename ValueType,
typename SolutionType>
435 std::vector<SolutionType> x =
437 : std::vector<SolutionType>(submatrix.getRowGroupCount(),
441 auto const uncertaintyResolutionMode = goal.getUncertaintyResolutionMode();
444 std::unique_ptr<storm::solver::MinMaxLinearEquationSolver<ValueType, SolutionType>>
solver =
446 solver->setRequirementsChecked();
447 solver->setUncertaintyResolutionMode(uncertaintyResolutionMode);
462 solver->setTrackScheduler(produceScheduler);
465 solver->solveEquations(env, x, b);
470 uint64_t relevantState =
solver->hasRelevantValues() ?
solver->getRelevantValues().getNextSetIndex(0ull) : 0ull;
471 std::function<void()> getNextRelevantStateIndex;
472 if (
solver->hasRelevantValues()) {
474 getNextRelevantStateIndex = [&relevantState, &relevantValues]() { relevantState = relevantValues.
getNextSetIndex(++relevantState); };
476 getNextRelevantStateIndex = [&relevantState]() { ++relevantState; };
478 for (; relevantState <
solver->getUpperBounds().size(); getNextRelevantStateIndex()) {
481 "Expecting result value for state " << relevantState <<
" to be <= " <<
solver->getUpperBounds().at(relevantState) <<
", but got "
482 << x.at(relevantState) <<
".");
489 if (
solver->hasSolutionLowerBounds()) {
492 if (
solver->hasSolutionUpperBounds()) {
497 if (produceScheduler) {
509template<
typename ValueType>
512 result.
maybeStates = hint.template asExplicitModelCheckerHint<ValueType>().getMaybeStates();
515 std::vector<storm::utility::ExtendedValueType<ValueType>>
const& resultsForNonMaybeStates =
516 hint.template asExplicitModelCheckerHint<ValueType>().getResultHint();
520 for (uint64_t state : nonMaybeStates) {
525 "Expected that the result hint specifies probabilities in {0,1} for non-maybe states.");
533template<
typename ValueType,
typename SolutionType>
542 std::pair<storm::storage::BitVector, storm::storage::BitVector> statesWithProbability01;
544 statesWithProbability01 =
547 statesWithProbability01 =
557template<
typename ValueType,
typename SolutionType>
570template<
typename SolutionType,
bool subChoicesCoverOnlyMaybeStates = true>
573 if constexpr (subChoicesCoverOnlyMaybeStates) {
574 auto subChoiceIt = subChoices.begin();
575 for (uint64_t maybeState : maybeStates) {
576 scheduler.
setChoice(*subChoiceIt, maybeState);
579 STORM_LOG_ASSERT(subChoiceIt == subChoices.end(),
"Subchoice iterator not at end.");
584 for (uint64_t maybeState : maybeStates) {
585 scheduler.
setChoice(subChoices[maybeState], maybeState);
590template<
typename ValueType,
typename SolutionType>
611template<
typename ValueType,
typename SolutionType>
643template<
typename ValueType,
typename SolutionType>
652 bool doDecomposition = !candidateStates.
empty();
655 if (doDecomposition) {
662 if (doDecomposition && !endComponentDecomposition.
empty()) {
666 submatrix, &b,
nullptr, produceScheduler);
676 if (!newRelevantValues.
empty()) {
690template<
typename ValueType,
typename SolutionType>
695 STORM_LOG_THROW(!qualitative || !produceScheduler, storm::exceptions::InvalidSettingsException,
696 "Cannot produce scheduler when performing qualitative model checking only.");
716 bool maybeStatesNotRelevant = goal.hasRelevantValues() && goal.relevantValues().isDisjointFrom(qualitativeStateSets.
maybeStates);
719 bool const minimize = goal.minimize();
721 std::unique_ptr<storm::storage::Scheduler<SolutionType>> scheduler;
722 if (produceScheduler) {
723 scheduler = std::make_unique<storm::storage::Scheduler<SolutionType>>(transitionMatrix.
getRowGroupCount());
725 if (maybeStatesNotRelevant) {
726 for (uint64_t state : qualitativeStateSets.
maybeStates) {
727 scheduler->setDontCare(state);
733 if (qualitative || maybeStatesNotRelevant) {
747 std::vector<ValueType> b;
750 boost::optional<SparseMdpEndComponentInformation<ValueType>> ecInformation;
753 qualitativeStateSets, submatrix, b, produceScheduler);
764 if (ecInformation && ecInformation.get().getEliminatedEndComponents()) {
766 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We do not support this end component with interval models.");
769 auto liftBound = [&result, &qualitativeStateSets, &ecInformation](std::vector<SolutionType>
const& boundInEcQuotient) {
770 std::vector<SolutionType> bound(result);
771 ecInformation.get().setValues(bound, qualitativeStateSets.maybeStates, boundInEcQuotient);
774 resultBounds = resultForMaybeStates.
solutionBounds.transform(liftBound);
775 ecInformation.get().setValues(result, qualitativeStateSets.maybeStates, resultForMaybeStates.
getValues());
776 if (produceScheduler) {
777 ecInformation.get().setScheduler(*scheduler, qualitativeStateSets.maybeStates, transitionMatrix, backwardTransitions,
786 auto embedBound = [&result, &qualitativeStateSets](std::vector<SolutionType>
const& boundForMaybeStates) {
787 std::vector<SolutionType> bound(result);
791 resultBounds = resultForMaybeStates.
solutionBounds.transform(embedBound);
796 result = resultForMaybeStates.
getValues();
799 if (produceScheduler) {
813 if (produceScheduler) {
814 extendScheduler(*scheduler, minimize, qualitativeStateSets, transitionMatrix, backwardTransitions, phiStates, psiStates);
818 STORM_LOG_ASSERT(!produceScheduler || scheduler,
"Expected that a scheduler was obtained.");
819 STORM_LOG_ASSERT((!produceScheduler && !scheduler) || !scheduler->isPartialScheduler(),
"Expected a fully defined scheduler.");
820 STORM_LOG_ASSERT((!produceScheduler && !scheduler) || scheduler->isDeterministicScheduler(),
"Expected a deterministic scheduler.");
821 STORM_LOG_ASSERT((!produceScheduler && !scheduler) || scheduler->isMemorylessScheduler(),
"Expected a memoryless scheduler.");
829template<
typename ValueType,
typename SolutionType>
833 bool useMecBasedTechnique) {
834 if (useMecBasedTechnique) {
838 for (
auto const& mec : mecDecomposition) {
839 for (
auto const& stateActionsPair : mec) {
840 statesInPsiMecs.
set(stateActionsPair.first,
true);
844 return computeUntilProbabilities(env, std::move(goal), transitionMatrix, backwardTransitions, psiStates, statesInPsiMecs, qualitative,
851 for (
auto& element : result.values) {
854 result.solutionBounds.invertProbabilityBounds();
859template<
typename ValueType,
typename SolutionType>
860template<
typename RewardModelType>
863 RewardModelType
const& rewardModel, uint_fast64_t stepCount) {
865 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We do not support instantenous rewards with interval models.");
868 STORM_LOG_THROW(rewardModel.hasStateRewards(), storm::exceptions::InvalidPropertyException,
869 "Computing instantaneous rewards for a reward model that does not define any state-rewards. The result is trivially 0.");
871 std::vector<SolutionType> result(rewardModel.getStateRewardVector());
874 multiplier->repeatedMultiplyAndReduce(env, goal.direction(), result,
nullptr, stepCount, goal.getUncertaintyResolutionMode());
880template<
typename ValueType,
typename SolutionType>
881template<
typename RewardModelType>
884 RewardModelType
const& rewardModel, uint_fast64_t stepBound) {
886 STORM_LOG_THROW(!rewardModel.empty(), storm::exceptions::InvalidPropertyException,
"Missing reward model for formula. Skipping formula.");
889 STORM_LOG_THROW(!rewardModel.hasTransitionRewards(), storm::exceptions::NotSupportedException,
890 "Cumulative rewards on interval models do not support transition rewards.");
895 std::vector<ValueType> totalRewardVector = rewardModel.getTotalRewardVector(transitionMatrix);
901 multiplier->repeatedMultiplyAndReduce(env, goal.direction(), result, &totalRewardVector, stepBound, goal.getUncertaintyResolutionMode());
906template<
typename ValueType,
typename SolutionType>
907template<
typename RewardModelType>
912 STORM_LOG_THROW(!rewardModel.hasNegativeRewards(), storm::exceptions::NotImplementedException,
913 "The reward model contains negative rewards. This is not implemented by the total rewards computation.");
915 if (goal.minimize()) {
919 for (uint64_t state = 0; state < transitionMatrix.
getRowGroupCount(); ++state) {
921 statesWithZeroRewardChoice.
set(state);
926 statesWithZeroRewardChoice, ~statesWithZeroRewardChoice,
false, 0, choicesWithoutReward);
928 auto result =
computeReachabilityRewards(env, std::move(goal), transitionMatrix, backwardTransitions, rewardModel, rew0EStates, qualitative,
929 produceScheduler, hint);
930 if (result.scheduler) {
945 return computeReachabilityRewards(env, std::move(goal), transitionMatrix, backwardTransitions, rewardModel, rew0AStates, qualitative,
946 produceScheduler, hint);
949 STORM_LOG_ERROR_COND(!produceScheduler,
"Can not produce scheduler for this property (functionality not implemented");
954 for (uint64_t oldRew0AState : rew0AStates) {
955 newRew0AStates.
set(ecElimResult.oldToNewStateMapping[oldRew0AState]);
958 if (goal.hasRelevantValues()) {
960 for (
auto oldRelevantState : goal.relevantValues()) {
961 newRelevantValues.
set(ecElimResult.oldToNewStateMapping[oldRelevantState]);
963 goal.relevantValues() = std::move(newRelevantValues);
967 env, std::move(goal), ecElimResult.matrix, ecElimResult.matrix.transpose(
true),
969 std::vector<ValueType> result;
970 std::vector<ValueType> oldChoiceRewards = rewardModel.getTotalRewardVector(transitionMatrix);
971 result.reserve(rowCount);
972 for (uint64_t newState : maybeStates) {
973 for (auto newChoice : newTransitionMatrix.getRowGroupIndices(newState)) {
974 uint64_t oldChoice = ecElimResult.newToOldRowMapping[newChoice];
975 result.push_back(oldChoiceRewards[oldChoice]);
978 STORM_LOG_ASSERT(result.size() == rowCount,
"Unexpected size of reward vector.");
981 newRew0AStates, qualitative,
false,
984 for (uint64_t oldStateWithoutRew : statesWithoutReward) {
985 newStatesWithoutReward.
set(ecElimResult.oldToNewStateMapping[oldStateWithoutRew]);
987 return newStatesWithoutReward;
991 for (uint64_t newChoice = 0; newChoice < ecElimResult.matrix.getRowCount(); ++newChoice) {
992 if (choicesWithoutReward.get(ecElimResult.newToOldRowMapping[newChoice])) {
993 newChoicesWithoutReward.
set(newChoice);
996 return newChoicesWithoutReward;
1000 auto liftFromEcQuotient = [&ecElimResult](std::vector<ExtendedSolutionType>
const& valuesInEcQuotient) {
1001 std::vector<ExtendedSolutionType> lifted(ecElimResult.oldToNewStateMapping.size());
1005 result.solutionBounds = result.solutionBounds.transform(liftFromEcQuotient);
1006 result.values = liftFromEcQuotient(result.values);
1012template<
typename ValueType,
typename SolutionType>
1013template<
typename RewardModelType>
1016 RewardModelType
const& rewardModel, uint_fast64_t stepBound, ValueType discountFactor) {
1018 STORM_LOG_THROW(!rewardModel.empty(), storm::exceptions::InvalidPropertyException,
"Missing reward model for formula. Skipping formula.");
1021 std::vector<SolutionType> totalRewardVector = rewardModel.getTotalRewardVector(transitionMatrix);
1027 multiplier->repeatedMultiplyAndReduceWithFactor(env, goal.direction(), result, &totalRewardVector, stepBound, discountFactor,
1028 goal.getUncertaintyResolutionMode());
1033template<
typename ValueType,
typename SolutionType>
1034template<
typename RewardModelType>
1041 "Exact solving of discounted total reward objectives is currently not supported.");
1043 std::vector<ValueType> b;
1046 b = rewardModel.getTotalRewardVector(transitionMatrix);
1051 std::unique_ptr<storm::storage::Scheduler<SolutionType>> scheduler;
1052 if (produceScheduler) {
1053 scheduler = std::make_unique<storm::storage::Scheduler<ValueType>>(discountingHelper.
computeScheduler());
1055 STORM_LOG_ASSERT(!produceScheduler || scheduler,
"Expected that a scheduler was obtained.");
1056 STORM_LOG_ASSERT((!produceScheduler && !scheduler) || !scheduler->isPartialScheduler(),
"Expected a fully defined scheduler.");
1057 STORM_LOG_ASSERT((!produceScheduler && !scheduler) || scheduler->isDeterministicScheduler(),
"Expected a deterministic scheduler.");
1058 STORM_LOG_ASSERT((!produceScheduler && !scheduler) || scheduler->isMemorylessScheduler(),
"Expected a memoryless scheduler.");
1062template<
typename ValueType,
typename SolutionType>
1063template<
typename RewardModelType>
1069 STORM_LOG_THROW(!rewardModel.empty(), storm::exceptions::InvalidPropertyException,
"Reward model for formula is empty. Skipping formula.");
1070 return computeReachabilityRewardsHelper(
1071 env, std::move(goal), transitionMatrix, backwardTransitions,
1073 return rewardModel.getTotalRewardVector(rowCount, transMatrix, maybeStates);
1075 targetStates, qualitative, produceScheduler, [&]() {
return rewardModel.getStatesWithZeroReward(transitionMatrix); },
1076 [&]() {
return rewardModel.getChoicesWithZeroReward(transitionMatrix); }, hint);
1079template<
typename ValueType,
typename SolutionType>
1084 return computeReachabilityRewardsHelper(
1085 env, std::move(goal), transitionMatrix, backwardTransitions,
1093template<
typename ValueType,
typename SolutionType>
1094template<
typename IntervalRewardType>
1095std::vector<typename SparseMdpPrctlHelper<ValueType, SolutionType>::ExtendedSolutionType>
1102 STORM_LOG_THROW(!intervalRewardModel.
empty(), storm::exceptions::InvalidPropertyException,
"Missing reward model for formula. Skipping formula.");
1104 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We do not support a valuetype and reward type having different base types.");
1106 return computeReachabilityRewardsHelper(
1107 env, std::move(goal), transitionMatrix, backwardTransitions,
1109 std::vector<ValueType> result;
1110 result.reserve(rowCount);
1111 std::vector<IntervalRewardType> subIntervalVector = intervalRewardModel.
getTotalRewardVector(rowCount, transitionMatrix, maybeStates);
1112 for (
auto const& interval : subIntervalVector) {
1113 result.push_back(lowerBoundOfIntervals ? interval.lower() : interval.upper());
1117 targetStates, qualitative,
false,
1119 return intervalRewardModel.
getStatesWithFilter(transitionMatrix, [&](IntervalRewardType
const& i) {
1124 return intervalRewardModel.
getChoicesWithFilter(transitionMatrix, [&](IntervalRewardType
const& i) {
1138template<
typename ValueType>
1142 result.
maybeStates = hint.template asExplicitModelCheckerHint<ValueType>().getMaybeStates();
1145 std::vector<storm::utility::ExtendedValueType<ValueType>>
const& resultsForNonMaybeStates =
1146 hint.template asExplicitModelCheckerHint<ValueType>().getResultHint();
1150 for (uint64_t state : nonMaybeStates) {
1155 "Expected that the result hint specifies probabilities in {0,infinity} for non-maybe states.");
1162template<
typename ValueType,
typename SolutionType>
1181 trueStates, targetStates, zeroRewardChoicesGetter());
1184 zeroRewardStatesGetter(), targetStates);
1193template<
typename ValueType,
typename SolutionType>
1198 if (hint.
isExplicitModelCheckerHint() && hint.template asExplicitModelCheckerHint<ValueType>().getComputeOnlyMaybeStates()) {
1202 zeroRewardChoicesGetter);
1206template<
typename ValueType,
typename SolutionType>
1214 qualitativeStateSets.
rewardZeroStates, targetStates, scheduler, zeroRewardChoicesGetter());
1226template<
typename ValueType,
typename SolutionType>
1229 boost::optional<storm::storage::BitVector>
const& selectedChoices) {
1230 auto subChoiceIt = subChoices.begin();
1231 if (selectedChoices) {
1232 for (uint64_t maybeState : maybeStates) {
1235 uint_fast64_t selectedRowIndex = selectedChoices->getNextSetIndex(firstRowIndex);
1236 for (uint_fast64_t choice = 0; choice < *subChoiceIt; ++choice) {
1237 selectedRowIndex = selectedChoices->getNextSetIndex(selectedRowIndex + 1);
1239 scheduler.
setChoice(selectedRowIndex - firstRowIndex, maybeState);
1243 for (uint64_t maybeState : maybeStates) {
1244 scheduler.
setChoice(*subChoiceIt, maybeState);
1248 STORM_LOG_ASSERT(subChoiceIt == subChoices.end(),
"Subchoice iterator not at end.");
1251template<
typename ValueType,
typename SolutionType>
1256 totalStateRewardVectorGetter,
1267 b = totalStateRewardVectorGetter(transitionMatrix.
getRowCount(), transitionMatrix,
1276 if (oneStepTargetProbabilities) {
1278 (*oneStepTargetProbabilities) =
1291 b = totalStateRewardVectorGetter(submatrix.
getRowCount(), transitionMatrix, qualitativeStateSets.
maybeStates);
1292 if (oneStepTargetProbabilities) {
1293 (*oneStepTargetProbabilities) =
1298 b = totalStateRewardVectorGetter(transitionMatrix.
getRowCount(), transitionMatrix,
1301 if (oneStepTargetProbabilities) {
1310template<
typename ValueType,
typename SolutionType>
1314 boost::optional<storm::storage::BitVector>
const& selectedChoices,
1316 totalStateRewardVectorGetter,
1318 bool produceScheduler) {
1323 std::vector<ValueType> rewardVector =
1327 for (
auto const& e : rewardVector) {
1329 zeroRewardChoices.
set(index);
1336 for (uint64_t state : qualitativeStateSets.
maybeStates) {
1337 bool keepState =
false;
1340 if (zeroRewardChoices.
get(row)) {
1347 candidateStates.
set(state,
false);
1355 bool doDecomposition = !candidateStates.
empty();
1358 if (doDecomposition) {
1360 endComponentDecomposition =
1366 if (doDecomposition && !endComponentDecomposition.
empty()) {
1369 endComponentDecomposition, transitionMatrix, qualitativeStateSets.
maybeStates,
1370 oneStepTargetProbabilities ? &qualitativeStateSets.
rewardZeroStates :
nullptr, selectedChoices ? &selectedChoices.
get() :
nullptr, &rewardVector,
1371 submatrix, oneStepTargetProbabilities ? &oneStepTargetProbabilities.get() :
nullptr, &b, produceScheduler);
1381 if (!newRelevantValues.
empty()) {
1390 oneStepTargetProbabilities ? &oneStepTargetProbabilities.get() :
nullptr);
1395template<
typename ValueType,
typename SolutionType>
1398 std::vector<ValueType>
const& oneStepTargetProbabilities) {
1400 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We do not support computing upper reward bounds with interval models.");
1403 if (direction == storm::OptimizationDirection::Minimize) {
1413template<
typename ValueType,
typename SolutionType>
1414typename SparseMdpPrctlHelper<ValueType, SolutionType>::ExtendedReturnType SparseMdpPrctlHelper<ValueType, SolutionType>::computeReachabilityRewardsHelper(
1418 totalStateRewardVectorGetter,
1427 QualitativeStateSetsReachabilityRewards qualitativeStateSets = getQualitativeStateSetsReachabilityRewards(
1428 env, goal, transitionMatrix, backwardTransitions, targetStates, hint, zeroRewardStatesGetter, zeroRewardChoicesGetter);
1430 STORM_LOG_INFO(
"Preprocessing: " << qualitativeStateSets.infinityStates.getNumberOfSetBits() <<
" states with reward infinity, "
1431 << qualitativeStateSets.rewardZeroStates.getNumberOfSetBits() <<
" states with reward zero ("
1432 << qualitativeStateSets.maybeStates.getNumberOfSetBits() <<
" states remaining).");
1437 std::unique_ptr<storm::storage::Scheduler<SolutionType>> scheduler;
1438 if (produceScheduler) {
1440 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We do not support producing schedulers in this function with interval models.");
1442 scheduler = std::make_unique<storm::storage::Scheduler<SolutionType>>(transitionMatrix.
getRowGroupCount());
1452 if (qualitative || maybeStatesNotRelevant) {
1453 STORM_LOG_INFO(
"The rewards for the initial states were determined in a preprocessing step. No exact rewards were computed.");
1458 if (!qualitativeStateSets.maybeStates.empty()) {
1462 boost::optional<storm::storage::BitVector> selectedChoices;
1463 if (!qualitativeStateSets.infinityStates.empty()) {
1464 selectedChoices = transitionMatrix.
getRowFilter(qualitativeStateSets.maybeStates, ~qualitativeStateSets.infinityStates);
1468 bool hasUniqueSolution = goal.
direction() == storm::solver::OptimizationDirection::Maximize;
1471 if (!hasUniqueSolution) {
1472 auto zeroRewardChoices = zeroRewardChoicesGetter();
1473 auto oneStepZeroRewardStates = qualitativeStateSets.maybeStates & transitionMatrix.
getRowGroupFilter(zeroRewardChoices,
false);
1478 oneStepZeroRewardStates, ~oneStepZeroRewardStates,
false, 0, std::move(zeroRewardChoices))
1482 SparseMdpHintType<SolutionType> hintInformation = computeHints<ValueType, SolutionType>(
1483 env, SemanticSolutionType::ExpectedRewards, hint, goal.
direction(), transitionMatrix, backwardTransitions, qualitativeStateSets.maybeStates,
1484 ~qualitativeStateSets.rewardZeroStates, qualitativeStateSets.rewardZeroStates, produceScheduler, selectedChoices, hasUniqueSolution);
1487 storm::storage::SparseMatrix<ValueType> submatrix;
1488 std::vector<ValueType> b;
1492 boost::optional<std::vector<ValueType>> oneStepTargetProbabilities;
1493 if (hintInformation.getComputeUpperBounds()) {
1494 oneStepTargetProbabilities = std::vector<ValueType>();
1498 boost::optional<SparseMdpEndComponentInformation<ValueType>> ecInformation;
1499 if (hintInformation.getEliminateEndComponents()) {
1501 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We do not support eliminating end components with interval models.");
1504 goal, transitionMatrix, backwardTransitions, qualitativeStateSets, selectedChoices, totalStateRewardVectorGetter, submatrix, b,
1505 oneStepTargetProbabilities, produceScheduler);
1510 submatrix, b, oneStepTargetProbabilities ? &oneStepTargetProbabilities.get() :
nullptr);
1514 if (hintInformation.getComputeUpperBounds()) {
1515 STORM_LOG_ASSERT(oneStepTargetProbabilities,
"Expecting one step target probability vector to be available.");
1520 MaybeStateResult<SolutionType> resultForMaybeStates =
1524 if (ecInformation && ecInformation.get().getEliminatedEndComponents()) {
1526 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We do not support eliminating end components with interval models.");
1529 ecInformation.get().setValues(result, qualitativeStateSets.maybeStates, maybeStateValues);
1530 if (produceScheduler) {
1531 ecInformation.get().setScheduler(*scheduler, qualitativeStateSets.maybeStates, transitionMatrix, backwardTransitions,
1532 resultForMaybeStates.getScheduler());
1537 auto embedBound = [&result, &qualitativeStateSets](std::vector<SolutionType>
const& boundForMaybeStates) {
1538 std::vector<ExtendedSolutionType> bound(result);
1542 resultBounds = resultForMaybeStates.solutionBounds.
transform(embedBound);
1548 result, qualitativeStateSets.maybeStates,
1553 if (produceScheduler) {
1554 extractSchedulerChoices(*scheduler, transitionMatrix, resultForMaybeStates.getScheduler(), qualitativeStateSets.maybeStates,
1562 if (produceScheduler) {
1563 extendScheduler(*scheduler, minimize, qualitativeStateSets, transitionMatrix, backwardTransitions, targetStates, zeroRewardChoicesGetter);
1567 STORM_LOG_ASSERT(!produceScheduler || scheduler,
"Expected that a scheduler was obtained.");
1568 STORM_LOG_ASSERT((!produceScheduler && !scheduler) || !scheduler->isPartialScheduler(),
"Expected a fully defined scheduler.");
1569 STORM_LOG_ASSERT((!produceScheduler && !scheduler) || scheduler->isDeterministicScheduler(),
"Expected a deterministic scheduler.");
1570 STORM_LOG_ASSERT((!produceScheduler && !scheduler) || scheduler->isMemorylessScheduler(),
"Expected a memoryless scheduler.");
1572 if (qualitativeStateSets.maybeStates.empty()) {
1578 ExtendedReturnType returnValue(std::move(result));
1579 returnValue.solutionBounds = std::move(resultBounds);
1582 ExtendedReturnType returnValue(std::move(result), std::move(scheduler));
1583 returnValue.solutionBounds = std::move(resultBounds);
1588template class SparseMdpPrctlHelper<double>;
1589template std::vector<double> SparseMdpPrctlHelper<double>::computeInstantaneousRewards(Environment
const& env, storm::solver::SolveGoal<double>&& goal,
1590 storm::storage::SparseMatrix<double>
const& transitionMatrix,
1591 storm::models::sparse::StandardRewardModel<double>
const& rewardModel,
1592 uint_fast64_t stepCount);
1593template std::vector<double> SparseMdpPrctlHelper<double>::computeCumulativeRewards(Environment
const& env, storm::solver::SolveGoal<double>&& goal,
1594 storm::storage::SparseMatrix<double>
const& transitionMatrix,
1595 storm::models::sparse::StandardRewardModel<double>
const& rewardModel,
1596 uint_fast64_t stepBound);
1597template std::vector<double> SparseMdpPrctlHelper<double>::computeDiscountedCumulativeRewards(
1598 Environment
const& env, storm::solver::SolveGoal<double>&& goal, storm::storage::SparseMatrix<double>
const& transitionMatrix,
1599 storm::models::sparse::StandardRewardModel<double>
const& rewardModel, uint_fast64_t stepBound,
double discountFactor);
1600template MDPSparseModelCheckingHelperReturnType<double, storm::utility::ExtendedValueType<double>> SparseMdpPrctlHelper<double>::computeReachabilityRewards(
1601 Environment
const& env, storm::solver::SolveGoal<double>&& goal, storm::storage::SparseMatrix<double>
const& transitionMatrix,
1602 storm::storage::SparseMatrix<double>
const& backwardTransitions, storm::models::sparse::StandardRewardModel<double>
const& rewardModel,
1603 storm::storage::BitVector
const& targetStates,
bool qualitative,
bool produceScheduler,
ModelCheckerHint const& hint);
1604template MDPSparseModelCheckingHelperReturnType<double, storm::utility::ExtendedValueType<double>> SparseMdpPrctlHelper<double>::computeTotalRewards(
1605 Environment
const& env, storm::solver::SolveGoal<double>&& goal, storm::storage::SparseMatrix<double>
const& transitionMatrix,
1606 storm::storage::SparseMatrix<double>
const& backwardTransitions, storm::models::sparse::StandardRewardModel<double>
const& rewardModel,
bool qualitative,
1608template MDPSparseModelCheckingHelperReturnType<double, storm::utility::ExtendedValueType<double>> SparseMdpPrctlHelper<double>::computeDiscountedTotalRewards(
1609 Environment
const& env, storm::solver::SolveGoal<double>&& goal, storm::storage::SparseMatrix<double>
const& transitionMatrix,
1610 storm::storage::SparseMatrix<double>
const& backwardTransitions, storm::models::sparse::StandardRewardModel<double>
const& rewardModel,
bool qualitative,
1611 bool produceScheduler,
double discountFactor,
ModelCheckerHint const& hint);
1613template class SparseMdpPrctlHelper<storm::RationalNumber>;
1614template std::vector<storm::RationalNumber> SparseMdpPrctlHelper<storm::RationalNumber>::computeInstantaneousRewards(
1615 Environment
const& env, storm::solver::SolveGoal<storm::RationalNumber>&& goal, storm::storage::SparseMatrix<storm::RationalNumber>
const& transitionMatrix,
1616 storm::models::sparse::StandardRewardModel<storm::RationalNumber>
const& rewardModel, uint_fast64_t stepCount);
1617template std::vector<storm::RationalNumber> SparseMdpPrctlHelper<storm::RationalNumber>::computeCumulativeRewards(
1618 Environment
const& env, storm::solver::SolveGoal<storm::RationalNumber>&& goal, storm::storage::SparseMatrix<storm::RationalNumber>
const& transitionMatrix,
1619 storm::models::sparse::StandardRewardModel<storm::RationalNumber>
const& rewardModel, uint_fast64_t stepBound);
1620template std::vector<storm::RationalNumber> SparseMdpPrctlHelper<storm::RationalNumber>::computeDiscountedCumulativeRewards(
1621 Environment
const& env, storm::solver::SolveGoal<storm::RationalNumber>&& goal, storm::storage::SparseMatrix<storm::RationalNumber>
const& transitionMatrix,
1622 storm::models::sparse::StandardRewardModel<storm::RationalNumber>
const& rewardModel, uint_fast64_t stepBound, storm::RationalNumber discountFactor);
1623template MDPSparseModelCheckingHelperReturnType<storm::RationalNumber, storm::ExtendedRationalNumber>
1624SparseMdpPrctlHelper<storm::RationalNumber>::computeReachabilityRewards(Environment
const& env, storm::solver::SolveGoal<storm::RationalNumber>&& goal,
1625 storm::storage::SparseMatrix<storm::RationalNumber>
const& transitionMatrix,
1626 storm::storage::SparseMatrix<storm::RationalNumber>
const& backwardTransitions,
1627 storm::models::sparse::StandardRewardModel<storm::RationalNumber>
const& rewardModel,
1628 storm::storage::BitVector
const& targetStates,
bool qualitative,
bool produceScheduler,
1630template MDPSparseModelCheckingHelperReturnType<storm::RationalNumber, storm::ExtendedRationalNumber>
1631SparseMdpPrctlHelper<storm::RationalNumber>::computeTotalRewards(Environment
const& env, storm::solver::SolveGoal<storm::RationalNumber>&& goal,
1632 storm::storage::SparseMatrix<storm::RationalNumber>
const& transitionMatrix,
1633 storm::storage::SparseMatrix<storm::RationalNumber>
const& backwardTransitions,
1634 storm::models::sparse::StandardRewardModel<storm::RationalNumber>
const& rewardModel,
1636template MDPSparseModelCheckingHelperReturnType<storm::RationalNumber, storm::ExtendedRationalNumber>
1637SparseMdpPrctlHelper<storm::RationalNumber>::computeDiscountedTotalRewards(Environment
const& env, storm::solver::SolveGoal<storm::RationalNumber>&& goal,
1638 storm::storage::SparseMatrix<storm::RationalNumber>
const& transitionMatrix,
1639 storm::storage::SparseMatrix<storm::RationalNumber>
const& backwardTransitions,
1640 storm::models::sparse::StandardRewardModel<storm::RationalNumber>
const& rewardModel,
1641 bool qualitative,
bool produceScheduler, storm::RationalNumber discountFactor,
1644template class SparseMdpPrctlHelper<storm::Interval, double>;
1645template std::vector<double> SparseMdpPrctlHelper<storm::Interval, double>::computeInstantaneousRewards(
1646 Environment
const& env, storm::solver::SolveGoal<storm::Interval, double>&& goal, storm::storage::SparseMatrix<storm::Interval>
const& transitionMatrix,
1647 storm::models::sparse::StandardRewardModel<storm::Interval>
const& rewardModel, uint_fast64_t stepCount);
1648template std::vector<double> SparseMdpPrctlHelper<storm::Interval, double>::computeCumulativeRewards(
1649 Environment
const& env, storm::solver::SolveGoal<storm::Interval, double>&& goal, storm::storage::SparseMatrix<storm::Interval>
const& transitionMatrix,
1650 storm::models::sparse::StandardRewardModel<storm::Interval>
const& rewardModel, uint_fast64_t stepBound);
1651template std::vector<double> SparseMdpPrctlHelper<storm::Interval, double>::computeReachabilityRewards<storm::Interval>(
1652 Environment
const& env, storm::solver::SolveGoal<storm::Interval, double>&& goal, storm::storage::SparseMatrix<storm::Interval>
const& transitionMatrix,
1653 storm::storage::SparseMatrix<storm::Interval>
const& backwardTransitions, storm::models::sparse::StandardRewardModel<storm::Interval>
const& rewardModel,
1654 bool lowerBoundOfIntervals, storm::storage::BitVector
const& targetStates,
bool qualitative);
1655template MDPSparseModelCheckingHelperReturnType<double, storm::utility::ExtendedValueType<double>>
1656SparseMdpPrctlHelper<storm::Interval, double>::computeTotalRewards(Environment
const& env, storm::solver::SolveGoal<storm::Interval, double>&& goal,
1657 storm::storage::SparseMatrix<storm::Interval>
const& transitionMatrix,
1658 storm::storage::SparseMatrix<storm::Interval>
const& backwardTransitions,
1659 storm::models::sparse::StandardRewardModel<storm::Interval>
const& rewardModel,
1662template class SparseMdpPrctlHelper<storm::RationalInterval, storm::RationalNumber>;
1663template std::vector<storm::RationalNumber> SparseMdpPrctlHelper<storm::RationalInterval, storm::RationalNumber>::computeInstantaneousRewards(
1664 Environment
const& env, storm::solver::SolveGoal<storm::RationalInterval, storm::RationalNumber>&& goal,
1665 storm::storage::SparseMatrix<storm::RationalInterval>
const& transitionMatrix,
1666 storm::models::sparse::StandardRewardModel<storm::RationalInterval>
const& rewardModel, uint_fast64_t stepCount);
1667template std::vector<storm::RationalNumber> SparseMdpPrctlHelper<storm::RationalInterval, storm::RationalNumber>::computeCumulativeRewards(
1668 Environment
const& env, storm::solver::SolveGoal<storm::RationalInterval, storm::RationalNumber>&& goal,
1669 storm::storage::SparseMatrix<storm::RationalInterval>
const& transitionMatrix,
1670 storm::models::sparse::StandardRewardModel<storm::RationalInterval>
const& rewardModel, uint_fast64_t stepBound);
1671template std::vector<storm::ExtendedRationalNumber> SparseMdpPrctlHelper<storm::RationalInterval, storm::RationalNumber>::computeReachabilityRewards<
1672 storm::RationalInterval>(Environment
const& env, storm::solver::SolveGoal<storm::RationalInterval, storm::RationalNumber>&& goal,
1673 storm::storage::SparseMatrix<storm::RationalInterval>
const& transitionMatrix,
1674 storm::storage::SparseMatrix<storm::RationalInterval>
const& backwardTransitions,
1675 storm::models::sparse::StandardRewardModel<storm::RationalInterval>
const& rewardModel,
bool lowerBoundOfIntervals,
1676 storm::storage::BitVector
const& targetStates,
bool qualitative);
1677template MDPSparseModelCheckingHelperReturnType<storm::RationalNumber, storm::ExtendedRationalNumber>
1678SparseMdpPrctlHelper<storm::RationalInterval, storm::RationalNumber>::computeTotalRewards(
1679 Environment
const& env, storm::solver::SolveGoal<storm::RationalInterval, storm::RationalNumber>&& goal,
1680 storm::storage::SparseMatrix<storm::RationalInterval>
const& transitionMatrix,
1681 storm::storage::SparseMatrix<storm::RationalInterval>
const& backwardTransitions,
1682 storm::models::sparse::StandardRewardModel<storm::RationalInterval>
const& rewardModel,
bool qualitative,
bool produceScheduler,
SolverEnvironment & solver()
ModelCheckerEnvironment & modelchecker()
storm::RationalNumber const & getPrecision() const
void setPrecision(storm::RationalNumber value)
std::string const & getExportCdfDirectory() const
bool isExportCdfSet() const
bool isFilterRewZeroSet() const
MinMaxSolverEnvironment & minMax()
uint64_t getShowProgressDelay() const
bool isForceExact() const
This class contains information that might accelerate the model checking process.
virtual bool isExplicitModelCheckerHint() const
virtual bool isEmpty() const
ExplicitModelCheckerHint< ValueType > & asExplicitModelCheckerHint()
Bounds computeTotalRewardBounds(std::vector< ValueType > const &rewards)
Computes a lower and an upper bound on the expected total rewards.
storm::storage::Scheduler< ValueType > computeScheduler() const
Retrieves the generated scheduler.
bool solveWithDiscountedValueIteration(Environment const &env, std::optional< OptimizationDirection > dir, std::vector< ValueType > &x, std::vector< ValueType > const &b) const
std::vector< ValueType > computeUpperBounds()
Computes upper bounds on the expected rewards.
static ExtendedReturnType computeDiscountedTotalRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, RewardModelType const &rewardModel, bool qualitative, bool produceScheduler, ValueType discountFactor, ModelCheckerHint const &hint=ModelCheckerHint())
static ExtendedReturnType computeReachabilityRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, RewardModelType const &rewardModel, storm::storage::BitVector const &targetStates, bool qualitative, bool produceScheduler, ModelCheckerHint const &hint=ModelCheckerHint())
static MDPSparseModelCheckingHelperReturnType< SolutionType > computeGloballyProbabilities(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &psiStates, bool qualitative, bool produceScheduler, bool useMecBasedTechnique=false)
static ExtendedReturnType computeTotalRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, RewardModelType const &rewardModel, bool qualitative, bool produceScheduler, ModelCheckerHint const &hint=ModelCheckerHint())
static std::vector< SolutionType > computeNextProbabilities(Environment const &env, OptimizationDirection dir, UncertaintyResolutionMode uncertaintyResolutionMode, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::BitVector const &nextStates)
static ExtendedReturnType computeReachabilityTimes(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &targetStates, bool qualitative, bool produceScheduler, ModelCheckerHint const &hint=ModelCheckerHint())
MDPSparseModelCheckingHelperReturnType< SolutionType, ExtendedSolutionType > ExtendedReturnType
static std::vector< SolutionType > computeInstantaneousRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, RewardModelType const &rewardModel, uint_fast64_t stepCount)
static MDPSparseModelCheckingHelperReturnType< SolutionType > computeUntilProbabilities(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, bool qualitative, bool produceScheduler, ModelCheckerHint const &hint=ModelCheckerHint())
static std::vector< SolutionType > computeRewardBoundedValues(Environment const &env, OptimizationDirection dir, rewardbounded::MultiDimensionalRewardUnfolding< ValueType, true > &rewardUnfolding, storm::storage::BitVector const &initialStates)
static std::vector< SolutionType > computeCumulativeRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, RewardModelType const &rewardModel, uint_fast64_t stepBound)
static std::vector< SolutionType > computeDiscountedCumulativeRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, RewardModelType const &rewardModel, uint_fast64_t stepBound, ValueType discountFactor)
bool hasBottomDimension(Epoch const &epoch) const
uint64_t getDimensionOfEpoch(Epoch const &epoch, uint64_t const &dimension) const
Epoch getStartEpoch(bool setUnknownDimsToBottom=false)
Retrieves the desired epoch that needs to be analyzed to compute the reward bounded values.
SolutionType getInitialStateResult(Epoch const &epoch)
Dimension< ValueType > const & getDimension(uint64_t dim) const
EpochManager const & getEpochManager() const
EpochModel< ValueType, SingleObjectiveMode > & setCurrentEpoch(Epoch const &epoch)
std::vector< Epoch > getEpochComputationOrder(Epoch const &startEpoch, bool stopAtComputedEpochs=false)
Computes a sequence of epochs that need to be analyzed to get a result at the start epoch.
ValueType getRequiredEpochModelPrecision(Epoch const &startEpoch, ValueType const &precision)
Returns the precision required for the analyzis of each epoch model in order to achieve the given ove...
boost::optional< ValueType > getLowerObjectiveBound(uint64_t objectiveIndex=0)
void setSolutionForCurrentEpoch(std::vector< SolutionType > &&inStateSolutions)
boost::optional< ValueType > getUpperObjectiveBound(uint64_t objectiveIndex=0)
Returns an upper/lower bound for the objective result in every state (if this bound could be computed...
bool empty() const
Retrieves whether the reward model is empty, i.e.
std::vector< ValueType > getTotalRewardVector(storm::storage::SparseMatrix< MatrixValueType > const &transitionMatrix) const
Creates a vector representing the complete reward vector based on the state-, state-action- and trans...
storm::storage::BitVector getChoicesWithFilter(storm::storage::SparseMatrix< MatrixValueType > const &transitionMatrix, std::function< bool(ValueType const &)> const &filter) const
Returns the set of choices for which all associated rewards (state, action or transition rewards) sat...
storm::storage::BitVector getStatesWithFilter(storm::storage::SparseMatrix< MatrixValueType > const &transitionMatrix, std::function< bool(ValueType const &)> const &filter) const
Returns the set of states for which all associated rewards (state, action or transition rewards) sati...
MinMaxLinearEquationSolverRequirements getRequirements(Environment const &env, bool hasUniqueSolution=false, bool hasNoEndComponents=false, boost::optional< storm::solver::OptimizationDirection > const &direction=boost::none, bool hasInitialScheduler=false, bool trackScheduler=false) const
Retrieves the requirements of the solver that would be created when calling create() right now.
SolverRequirement const & validInitialScheduler() const
void clearValidInitialScheduler()
void clearUniqueSolution()
bool hasEnabledRequirement() const
SolverRequirement const & uniqueSolution() const
bool hasEnabledCriticalRequirement() const
std::string getEnabledRequirementsAsString() const
Returns a string that enumerates the enabled requirements.
SolverRequirement const & upperBounds() const
std::unique_ptr< Multiplier< ValueType, SolutionType > > create(Environment const &env, storm::storage::SparseMatrix< ValueType > const &matrix)
bool hasRelevantValues() const
void restrictRelevantValues(storm::storage::BitVector const &filter)
storm::storage::BitVector & relevantValues()
void setRelevantValues(storm::storage::BitVector &&values)
OptimizationDirection direction() const
A bit vector that is internally represented as a vector of 64-bit values.
void complement()
Negates all bits in the bit vector.
uint64_t getNextSetIndex(uint64_t startingIndex) const
Retrieves the index of the bit that is the next bit set to true in the bit vector.
bool isDisjointFrom(BitVector const &other) const
Checks whether none of the bits that are set in the current bit vector are also set in the given bit ...
bool full() const
Retrieves whether all bits are set in this bit vector.
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
uint64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
void set(uint64_t index, bool value=true)
Sets the given truth value at the given index.
size_t size() const
Retrieves the number of bits this bit vector can store.
bool get(uint64_t index) const
Retrieves the truth value of the bit at the given index and performs a bound check.
bool empty() const
Checks if the decomposition is empty.
std::size_t size() const
Retrieves the number of blocks of this decomposition.
This class represents the decomposition of a nondeterministic model into its maximal end components.
std::string statistics(uint64_t totalNumberOfStates) const
Returns a string containing statistics about the MEC decomposition, e.g., the number of (trivial/non-...
This class defines which action is chosen in a particular state of a non-deterministic model.
SchedulerChoice< ValueType > const & getChoice(uint_fast64_t modelState, uint_fast64_t memoryState=0) const
Gets the choice defined by the scheduler for the given model and memory state.
void setChoice(SchedulerChoice< ValueType > const &choice, uint_fast64_t modelState, uint_fast64_t memoryState=0)
Sets the choice defined by the scheduler for the given state.
A class that holds a possibly non-square matrix in the compressed row storage format.
SparseMatrix getSubmatrix(bool useGroups, storm::storage::BitVector const &rowConstraint, storm::storage::BitVector const &columnConstraint, bool insertDiagonalEntries=false, storm::storage::BitVector const &makeZeroColumns=storm::storage::BitVector()) const
Creates a submatrix of the current matrix by dropping all rows and columns whose bits are not set to ...
std::vector< value_type > getConstrainedRowSumVector(storm::storage::BitVector const &rowConstraint, storm::storage::BitVector const &columnConstraint) const
Computes a vector whose i-th entry is the sum of the entries in the i-th selected row where only thos...
SparseMatrix restrictRows(storm::storage::BitVector const &rowsToKeep, bool allowEmptyRowGroups=false) const
Restrict rows in grouped rows matrix.
SparseMatrix< ValueType > transposeSelectedRowsFromRowGroups(std::vector< uint64_t > const &rowGroupChoices, bool keepZeros=false) const
Transposes the matrix w.r.t.
index_type getRowGroupCount() const
Returns the number of row groups in the matrix.
index_type getColumnCount() const
Returns the number of columns of the matrix.
storm::storage::BitVector getRowGroupFilter(storm::storage::BitVector const &rowConstraint, bool setIfForAllRowsInGroup) const
Returns the indices of all row groups selected by the row constraints.
std::vector< index_type > const & getRowGroupIndices() const
Returns the grouping of rows of this matrix.
std::vector< value_type > getConstrainedRowGroupSumVector(storm::storage::BitVector const &rowGroupConstraint, storm::storage::BitVector const &columnConstraint) const
Computes a vector whose entries represent the sums of selected columns for all rows in selected row g...
index_type getRowCount() const
Returns the number of rows of the matrix.
storm::storage::BitVector getRowFilter(storm::storage::BitVector const &groupConstraint) const
Returns a bitvector representing the set of rows, with all indices set that correspond to one of the ...
SparseMatrix filterEntries(storm::storage::BitVector const &rowFilter) const
Returns a copy of this matrix that only considers entries in the selected rows.
A class that provides convenience operations to display run times.
bool updateProgress(uint64_t count)
Updates the progress to the current count and logs it (on the progress log channel) if the delay pass...
void setMaxCount(uint64_t maxCount)
Sets the maximal possible count.
void startNewMeasurement(uint64_t startCount)
Starts a new measurement, dropping all progress information collected so far.
A class that provides convenience operations to display run times.
void start()
Start stopwatch (again) and start measuring time.
void stop()
Stop stopwatch and add measured time to total time.
#define STORM_LOG_INFO(message)
#define STORM_LOG_WARN(message)
#define STORM_LOG_DEBUG(message)
#define STORM_LOG_STATISTICS(message)
#define STORM_LOG_TRACE(message)
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_ERROR_COND(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
void exportDataToCSVFile(std::string filepath, std::vector< std::vector< DataType > > const &data, boost::optional< std::vector< Header1Type > > const &header1=boost::none, boost::optional< std::vector< Header2Type > > const &header2=boost::none)
SparseMdpHintType< SolutionType > computeHints(Environment const &env, SemanticSolutionType const &type, ModelCheckerHint const &hint, storm::OptimizationDirection const &dir, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &maybeStates, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &targetStates, bool produceScheduler, boost::optional< storm::storage::BitVector > const &selectedChoices=boost::none, bool hasUniqueSolution=false)
void extractSchedulerChoices(storm::storage::Scheduler< SolutionType > &scheduler, std::vector< uint64_t > const &subChoices, storm::storage::BitVector const &maybeStates)
boost::optional< SparseMdpEndComponentInformation< ValueType > > computeFixedPointSystemUntilProbabilitiesEliminateEndComponents(storm::solver::SolveGoal< ValueType, SolutionType > &goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, QualitativeStateSetsUntilProbabilities const &qualitativeStateSets, storm::storage::SparseMatrix< ValueType > &submatrix, std::vector< ValueType > &b, bool produceScheduler)
QualitativeStateSetsUntilProbabilities computeQualitativeStateSetsUntilProbabilities(storm::solver::SolveGoal< ValueType, SolutionType > const &goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
void extractValueAndSchedulerHint(SparseMdpHintType< SolutionType > &hintStorage, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &maybeStates, boost::optional< storm::storage::BitVector > const &selectedChoices, ModelCheckerHint const &hint, bool skipECWithinMaybeStatesCheck)
void extendScheduler(storm::storage::Scheduler< SolutionType > &scheduler, bool minimize, QualitativeStateSetsUntilProbabilities const &qualitativeStateSets, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
std::vector< uint_fast64_t > computeValidSchedulerHint(Environment const &env, SemanticSolutionType const &type, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &maybeStates, storm::storage::BitVector const &filterStates, storm::storage::BitVector const &targetStates, boost::optional< storm::storage::BitVector > const &selectedChoices)
QualitativeStateSetsUntilProbabilities getQualitativeStateSetsUntilProbabilitiesFromHint(ModelCheckerHint const &hint)
std::vector< ValueType > computeUpperRewardBounds(storm::storage::SparseMatrix< ValueType > const &transitionMatrix, std::vector< ValueType > const &rewards, std::vector< ValueType > const &oneStepTargetProbabilities)
QualitativeStateSetsReachabilityRewards getQualitativeStateSetsReachabilityRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > const &goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &targetStates, ModelCheckerHint const &hint, std::function< storm::storage::BitVector()> const &zeroRewardStatesGetter, std::function< storm::storage::BitVector()> const &zeroRewardChoicesGetter)
void computeFixedPointSystemUntilProbabilities(storm::solver::SolveGoal< ValueType, SolutionType > &goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, QualitativeStateSetsUntilProbabilities const &qualitativeStateSets, storm::storage::SparseMatrix< ValueType > &submatrix, std::vector< ValueType > &b)
MaybeStateResult< SolutionType > computeValuesForMaybeStates(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > &&goal, storm::storage::SparseMatrix< ValueType > &&submatrix, std::vector< ValueType > const &b, bool produceScheduler, SparseMdpHintType< SolutionType > &hint)
QualitativeStateSetsReachabilityRewards getQualitativeStateSetsReachabilityRewardsFromHint(ModelCheckerHint const &hint, storm::storage::BitVector const &targetStates)
boost::optional< SparseMdpEndComponentInformation< ValueType > > computeFixedPointSystemReachabilityRewardsEliminateEndComponents(storm::solver::SolveGoal< ValueType, SolutionType > &goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, QualitativeStateSetsReachabilityRewards const &qualitativeStateSets, boost::optional< storm::storage::BitVector > const &selectedChoices, std::function< std::vector< ValueType >(uint_fast64_t, storm::storage::SparseMatrix< ValueType > const &, storm::storage::BitVector const &)> const &totalStateRewardVectorGetter, storm::storage::SparseMatrix< ValueType > &submatrix, std::vector< ValueType > &b, boost::optional< std::vector< ValueType > > &oneStepTargetProbabilities, bool produceScheduler)
QualitativeStateSetsReachabilityRewards computeQualitativeStateSetsReachabilityRewards(Environment const &env, storm::solver::SolveGoal< ValueType, SolutionType > const &goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &targetStates, std::function< storm::storage::BitVector()> const &zeroRewardStatesGetter, std::function< storm::storage::BitVector()> const &zeroRewardChoicesGetter)
QualitativeStateSetsUntilProbabilities getQualitativeStateSetsUntilProbabilities(storm::solver::SolveGoal< ValueType, SolutionType > const &goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, ModelCheckerHint const &hint)
void computeFixedPointSystemReachabilityRewards(storm::solver::SolveGoal< ValueType, SolutionType > &goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, QualitativeStateSetsReachabilityRewards const &qualitativeStateSets, boost::optional< storm::storage::BitVector > const &selectedChoices, std::function< std::vector< ValueType >(uint_fast64_t, storm::storage::SparseMatrix< ValueType > const &, storm::storage::BitVector const &)> const &totalStateRewardVectorGetter, storm::storage::SparseMatrix< ValueType > &submatrix, std::vector< ValueType > &b, std::vector< ValueType > *oneStepTargetProbabilities=nullptr)
bool isSet(OptimizationDirectionSetting s)
std::unique_ptr< storm::solver::MinMaxLinearEquationSolver< ValueType, SolutionType > > configureMinMaxLinearEquationSolver(Environment const &env, SolveGoal< ValueType, SolutionType > &&goal, storm::solver::MinMaxLinearEquationSolverFactory< ValueType, SolutionType > const &factory, MatrixType &&matrix, OptimizationDirectionSetting optimizationDirectionSetting=OptimizationDirectionSetting::Unset)
bool constexpr minimize(OptimizationDirection d)
std::pair< storm::storage::BitVector, storm::storage::BitVector > performProb01Max(storm::storage::SparseMatrix< T > const &transitionMatrix, std::vector< uint_fast64_t > const &nondeterministicChoiceIndices, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
void computeSchedulerStayingInStates(storm::storage::BitVector const &states, storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::Scheduler< SchedulerValueType > &scheduler, boost::optional< storm::storage::BitVector > const &rowFilter)
Computes a scheduler for the given states that chooses an action that stays completely in the very sa...
void computeSchedulerProbGreater0E(storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, storm::storage::Scheduler< SchedulerValueType > &scheduler, boost::optional< storm::storage::BitVector > const &rowFilter)
Computes a scheduler for the ProbGreater0E-States such that in the induced system the given psiStates...
storm::storage::BitVector performProbGreater0A(storm::storage::SparseMatrix< T > const &transitionMatrix, std::vector< uint_fast64_t > const &nondeterministicChoiceIndices, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, bool useStepBound, uint_fast64_t maximalSteps, boost::optional< storm::storage::BitVector > const &choiceConstraint)
Computes the sets of states that have probability greater 0 of satisfying phi until psi under any pos...
void computeSchedulerProb1E(storm::storage::BitVector const &prob1EStates, storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, storm::storage::Scheduler< SchedulerValueType > &scheduler, boost::optional< storm::storage::BitVector > const &rowFilter)
Computes a scheduler for the given prob1EStates such that in the induced system the given psiStates a...
storm::storage::BitVector performProb1A(storm::models::sparse::NondeterministicModel< T, RM > const &model, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
Computes the sets of states that have probability 1 of satisfying phi until psi under all possible re...
storm::storage::BitVector performProbGreater0E(storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, bool useStepBound, uint_fast64_t maximalSteps)
Computes the sets of states that have probability greater 0 of satisfying phi until psi under at leas...
storm::storage::BitVector performProb1(storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &, storm::storage::BitVector const &psiStates, storm::storage::BitVector const &statesWithProbabilityGreater0)
Computes the set of states of the given model for which all paths lead to the given set of target sta...
storm::storage::BitVector performProb0E(storm::models::sparse::NondeterministicModel< T, RM > const &model, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
Computes the sets of states that have probability 0 of satisfying phi until psi under at least one po...
void computeSchedulerProb0E(storm::storage::BitVector const &prob0EStates, storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::Scheduler< SchedulerValueType > &scheduler)
Computes a scheduler for the given states that have a scheduler that has a probability 0.
std::pair< storm::storage::BitVector, storm::storage::BitVector > performProb01Min(storm::storage::SparseMatrix< T > const &transitionMatrix, std::vector< uint_fast64_t > const &nondeterministicChoiceIndices, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
storm::storage::BitVector performProb1E(storm::storage::SparseMatrix< T > const &transitionMatrix, std::vector< uint_fast64_t > const &nondeterministicChoiceIndices, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, boost::optional< storm::storage::BitVector > const &choiceConstraint)
Computes the sets of states that have probability 1 of satisfying phi until psi under at least one po...
void computeSchedulerRewInf(storm::storage::BitVector const &rewInfStates, storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::Scheduler< SchedulerValueType > &scheduler)
Computes a scheduler for the given states that have a scheduler that has a reward infinity.
bool isTerminate()
Check whether the program should terminate (due to some abort signal).
void setVectorValues(std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< S > const &values)
Sets the provided values at the provided positions in the given vector.
void setAllValues(std::vector< T > &vec, storm::storage::BitVector const &positions, T const &positiveValue=storm::utility::one< T >(), T const &negativeValue=storm::utility::zero< T >())
void selectVectorValues(std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< T > const &values)
Selects the elements from a vector at the specified positions and writes them consecutively into anot...
void filterVectorInPlace(std::vector< Type > &v, storm::storage::BitVector const &filter)
std::vector< Type > filterVector(std::vector< Type > const &in, storm::storage::BitVector const &filter)
ExtendedValueType< ValueType > positiveInfinity()
bool isOne(ValueType const &a)
std::vector< ExtendedValueType< ValueType > > widen(std::vector< ValueType > &&values)
Widens a vector of finite values into the extended value type.
bool isZero(ValueType const &a)
std::vector< ValueType > narrowFinite(std::vector< ExtendedValueType< ValueType > > &&values)
The counterpart of widen for a vector all of whose values are finite.
bool isInfinity(ValueType const &a)
TargetType convertNumber(SourceType const &number)
carl::Interval< storm::RationalNumber > RationalInterval
solver::UncertaintyResolutionMode UncertaintyResolutionMode
solver::OptimizationDirection OptimizationDirection
constexpr bool IsIntervalType
Helper to check if a type is an interval.
typename detail::IntervalMetaProgrammingHelper< ValueType >::BaseType IntervalBaseType
Helper to access the type in which interval boundaries are stored.
storm::solver::SolutionBounds< ValuesType > solutionBounds
bool hasScheduler() const
storm::solver::SolutionBounds< ValueType > solutionBounds
boost::optional< std::vector< uint64_t > > scheduler
MaybeStateResult(std::vector< ValueType > &&values)
std::vector< uint64_t > const & getScheduler() const
std::vector< ValueType > values
std::vector< ValueType > const & getValues() const
storm::storage::BitVector rewardZeroStates
storm::storage::BitVector infinityStates
storm::storage::BitVector maybeStates
storm::storage::BitVector statesWithProbability0
storm::storage::BitVector statesWithProbability1
storm::storage::BitVector maybeStates
ValueType const & getUpperResultBound() const
boost::optional< std::vector< uint64_t > > schedulerHint
std::vector< ValueType > & getValueHint()
bool hasNoEndComponents() const
boost::optional< ValueType > lowerResultBound
ValueType const & getLowerResultBound() const
boost::optional< ValueType > upperResultBound
bool hasValueHint() const
std::vector< uint64_t > & getSchedulerHint()
bool hasUniqueSolution() const
bool getEliminateEndComponents() const
boost::optional< std::vector< ValueType > > valueHint
bool getComputeUpperBounds()
bool hasUpperResultBound() const
std::vector< ValueType > const & getUpperResultBounds() const
std::vector< ValueType > & getUpperResultBounds()
boost::optional< std::vector< ValueType > > upperResultBounds
bool hasSchedulerHint() const
bool hasLowerResultBound() const
bool eliminateEndComponents
bool hasUpperResultBounds() const
Sound lower and upper bounds on a solution vector.
auto transform(Function const &function) const
Applies the given function to whichever of the bounds are set, e.g.
void setExact(std::vector< ValueType > const &values)
Sets both bounds to the given values, i.e.