60 std::vector<ValueType>
const& oneStepTargetProbabilities, std::function<uint64_t(uint64_t)>
const& stateToScc) {
72 assert(transitionMatrix.
getRowCount() == oneStepTargetProbabilities.size());
73 assert(backwardTransitions.
getRowCount() == numStates);
81 for (uint64_t state = 0; state < numStates; ++state) {
82 auto const scc = stateToScc(state);
83 for (
auto rowIndex = rowGroupIndices[state], rowEnd = rowGroupIndices[state + 1]; rowIndex < rowEnd; ++rowIndex) {
84 auto const row = transitionMatrix.
getRow(rowIndex);
85 if (std::any_of(row.begin(), row.end(), [&stateToScc, &scc](
auto const& entry) { return scc != stateToScc(entry.getColumn()); })) {
86 validChoices.set(rowIndex,
true);
92 std::vector<ValueType> result(numStates, storm::utility::one<ValueType>());
98 auto isValidChoice = [&transitionMatrix, &validChoices, &processedStates](uint64_t
const& choice) {
99 if (validChoices.get(choice)) {
102 auto row = transitionMatrix.
getRow(choice);
105 if (std::any_of(row.begin(), row.end(), [&processedStates](
auto const& entry) { return processedStates.get(entry.getColumn()); })) {
106 validChoices.set(choice,
true);
114 auto getChoiceValue = [&transitionMatrix, &oneStepTargetProbabilities, &processedStates, &stateToScc, &result](uint64_t
const& rowIndex,
115 uint64_t
const& sccIndex) {
116 ValueType rowValue = oneStepTargetProbabilities[rowIndex];
117 for (
auto const& entry : transitionMatrix.
getRow(rowIndex)) {
118 if (
auto successorState = entry.getColumn(); sccIndex != stateToScc(successorState)) {
119 rowValue += entry.getValue();
120 }
else if (processedStates.
get(successorState)) {
121 rowValue += entry.getValue() * result[successorState];
133 uint64_t unprocessedEnd = numStates;
134 auto candidateStateIt = candidateStates.
rbegin();
135 auto const candidateStateItEnd = candidateStates.
rend();
140 uint64_t
const state = *candidateStateIt;
142 if (std::all_of(group.begin(), group.end(), [&isValidChoice](
auto const& choice) { return isValidChoice(choice); })) {
145 auto const scc = stateToScc(state);
146 for (
auto choice : group) {
147 minimalStateValue &= getChoiceValue(choice, scc);
149 result[state] = *minimalStateValue;
150 processedStates.
set(state);
151 if (state == unprocessedEnd - 1) {
153 if (unprocessedEnd == 0) {
159 for (
auto const& predEntry : backwardTransitions.
getRow(state)) {
160 if (!processedStates.
get(predEntry.getColumn())) {
161 candidateStates.
set(predEntry.getColumn());
166 candidateStates.
set(state,
false);
169 if (candidateStateIt == candidateStateItEnd) {
171 candidateStateIt = candidateStates.
rbegin(unprocessedEnd);
173 STORM_LOG_THROW(candidateStateIt != candidateStateItEnd, storm::exceptions::InvalidOperationException,
174 "Unable to compute finite upper bounds for visiting times: No more candidates.");
185 STORM_LOG_TRACE(
"Computing upper reward bounds using variant-2 of Baier et al.");
189 if (!backwardTransitions) {
190 computedBackwardTransitions = transitionMatrix.
transpose(
true);
192 auto const& backwardTransRef = backwardTransitions ? *backwardTransitions : computedBackwardTransitions;
195 std::vector<uint64_t> computedStateToSccVec;
196 std::function<uint64_t(uint64_t)> stateToSccFct;
197 if (this->stateToScc) {
198 stateToSccFct = this->stateToScc;
201 computedStateToSccVec =
203 stateToSccFct = [&computedStateToSccVec](uint64_t s) {
return computedStateToSccVec[s]; };
206 auto expVisits = computeUpperBoundOnExpectedVisitingTimes(transitionMatrix, backwardTransRef, oneStepTargetProbabilities, stateToSccFct);
208 ValueType upperBound = storm::utility::zero<ValueType>();
209 for (uint64_t state = 0; state < expVisits.size(); ++state) {
213 auto const currScc = stateToSccFct(state);
214 auto maxRewardExit = storm::utility::zero<ValueType>();
215 auto maxRewardStay = storm::utility::zero<ValueType>();
218 auto const row = transitionMatrix.
getRow(rowIndex);
219 bool const exitingChoice =
220 std::all_of(row.begin(), row.end(), [&stateToSccFct, &currScc](
auto const& entry) { return currScc != stateToSccFct(entry.getColumn()); });
222 maxRewardExit = std::max(maxRewardExit, rewards[rowIndex]);
224 maxRewardStay = std::max(maxRewardStay, rewards[rowIndex]);
227 upperBound += std::max<ValueType>(expVisits[state] * maxRewardStay, maxRewardExit);
230 STORM_LOG_TRACE(
"Baier algorithm for reward bound computation (variant 2) computed bound " << upperBound <<
".");
void applyPointwise(std::vector< InValueType1 > const &firstOperand, std::vector< InValueType2 > const &secondOperand, std::vector< OutValueType > &target, Operation f=Operation())
Applies the given operation pointwise on the two given vectors and writes the result to the third vec...