53 std::vector<ValueType>
const& oneStepTargetProbabilities, std::function<uint64_t(uint64_t)>
const& stateToScc) {
64 auto const numStates = transitionMatrix.getRowGroupCount();
65 assert(transitionMatrix.getRowCount() == oneStepTargetProbabilities.size());
66 assert(backwardTransitions.getRowCount() == numStates);
67 assert(backwardTransitions.getColumnCount() == numStates);
68 auto const& rowGroupIndices = transitionMatrix.getRowGroupIndices();
74 for (uint64_t state = 0; state < numStates; ++state) {
75 auto const scc = stateToScc(state);
76 for (
auto rowIndex = rowGroupIndices[state], rowEnd = rowGroupIndices[state + 1]; rowIndex < rowEnd; ++rowIndex) {
77 auto const row = transitionMatrix.getRow(rowIndex);
78 if (std::any_of(row.begin(), row.end(), [&stateToScc, &scc](
auto const& entry) { return scc != stateToScc(entry.getColumn()); })) {
79 validChoices.set(rowIndex,
true);
91 auto isValidChoice = [&transitionMatrix, &validChoices, &processedStates](uint64_t
const& choice) {
92 if (validChoices.get(choice)) {
95 auto row = transitionMatrix.getRow(choice);
98 if (std::any_of(row.begin(), row.end(), [&processedStates](
auto const& entry) { return processedStates.get(entry.getColumn()); })) {
99 validChoices.set(choice,
true);
107 auto getChoiceValue = [&transitionMatrix, &oneStepTargetProbabilities, &processedStates, &stateToScc, &result](uint64_t
const& rowIndex,
108 uint64_t
const& sccIndex) {
109 ValueType rowValue = oneStepTargetProbabilities[rowIndex];
110 for (
auto const& entry : transitionMatrix.getRow(rowIndex)) {
111 if (
auto successorState = entry.getColumn(); sccIndex != stateToScc(successorState)) {
112 rowValue += entry.getValue();
113 }
else if (processedStates.
get(successorState)) {
114 rowValue += entry.getValue() * result[successorState];
126 uint64_t unprocessedEnd = numStates;
127 auto candidateStateIt = candidateStates.
rbegin();
128 auto const candidateStateItEnd = candidateStates.
rend();
133 uint64_t
const state = *candidateStateIt;
134 auto const group = transitionMatrix.getRowGroupIndices(state);
135 if (std::all_of(group.begin(), group.end(), [&isValidChoice](
auto const& choice) { return isValidChoice(choice); })) {
138 auto const scc = stateToScc(state);
139 for (
auto choice : group) {
140 minimalStateValue &= getChoiceValue(choice, scc);
142 result[state] = *minimalStateValue;
143 processedStates.
set(state);
144 if (state == unprocessedEnd - 1) {
146 if (unprocessedEnd == 0) {
152 for (
auto const& predEntry : backwardTransitions.getRow(state)) {
153 if (!processedStates.
get(predEntry.getColumn())) {
154 candidateStates.
set(predEntry.getColumn());
159 candidateStates.
set(state,
false);
162 if (candidateStateIt == candidateStateItEnd) {
164 candidateStateIt = candidateStates.
rbegin(unprocessedEnd);
166 STORM_LOG_THROW(candidateStateIt != candidateStateItEnd, storm::exceptions::InvalidOperationException,
167 "Unable to compute finite upper bounds for visiting times: No more candidates.");
178 std::vector<ValueType>
const& rewards) {
179 STORM_LOG_TRACE(
"Computing upper reward bounds using variant-2 of Baier et al.");
183 if (!backwardTransitions) {
184 computedBackwardTransitions = transitionMatrix.
transpose(
true);
186 auto const& backwardTransRef = backwardTransitions ? *backwardTransitions : computedBackwardTransitions;
189 std::vector<uint64_t> computedStateToSccVec;
190 std::function<uint64_t(uint64_t)> stateToSccFct;
191 if (this->stateToScc) {
192 stateToSccFct = this->stateToScc;
195 computedStateToSccVec =
197 stateToSccFct = [&computedStateToSccVec](uint64_t s) {
return computedStateToSccVec[s]; };
203 for (uint64_t state = 0; state < expVisits.size(); ++state) {
207 auto const currScc = stateToSccFct(state);
211 for (
auto rowIndex : transitionMatrix.getRowGroupIndices(state)) {
212 auto const row = transitionMatrix.getRow(rowIndex);
213 bool const exitingChoice =
214 std::all_of(row.begin(), row.end(), [&stateToSccFct, &currScc](
auto const& entry) { return currScc != stateToSccFct(entry.getColumn()); });
216 maxReward &= rewards[rowIndex];
217 minReward &= rewards[rowIndex];
219 maxRewardStay &= rewards[rowIndex];
220 minRewardStay &= rewards[rowIndex];
223 if (!maxRewardStay.
empty()) {
224 maxReward &= (*maxRewardStay * expVisits[state]);
226 result.
upper += *maxReward;
227 if (!minRewardStay.
empty()) {
228 minReward &= (*minRewardStay * expVisits[state]);
230 result.
lower += *minReward;
233 STORM_LOG_TRACE(
"Baier algorithm for reward bound computation (variant 2) computed bounds [" << result.
lower <<
", " << result.
upper <<
"].");