Storm 1.13.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseMarkovAutomatonCslHelper.cpp
Go to the documentation of this file.
2
23#include "storm/utility/graph.h"
26
27namespace storm {
28namespace modelchecker {
29namespace helper {
30
31template<typename ValueType>
32std::unique_ptr<storm::solver::MinMaxLinearEquationSolver<ValueType>> setUpProbabilisticStatesSolver(
34 std::unique_ptr<storm::solver::MinMaxLinearEquationSolver<ValueType>> solver;
35 // The min-max system has no end components as we assume non-zeno MAs.
36 if (transitions.getNonzeroEntryCount() > 0) {
38 bool isAcyclic = !storm::utility::graph::hasCycle(transitions);
39 if (isAcyclic) {
40 env.solver().minMax().setMethod(storm::solver::MinMaxMethod::Acyclic);
41 }
42 solver = factory.create(env, transitions);
43 solver->setHasUniqueSolution(true); // Assume non-zeno MA
44 solver->setHasNoEndComponents(true); // assume non-zeno MA
46 solver->setUpperBound(storm::utility::one<ValueType>());
47 solver->setCachingEnabled(true);
48 solver->setRequirementsChecked(true);
49 auto req = solver->getRequirements(env, dir);
50 req.clearBounds();
51 req.clearUniqueSolution();
52 if (isAcyclic) {
53 req.clearAcyclic();
54 }
55 STORM_LOG_THROW(!req.hasEnabledCriticalRequirement(), storm::exceptions::UncheckedRequirementException,
56 "The solver requirement " << req.getEnabledRequirementsAsString() << " has not been checked.");
57 }
58 return solver;
59}
60
61template<typename ValueType>
63 public:
64 UnifPlusHelper(storm::storage::SparseMatrix<ValueType> const& transitionMatrix, std::vector<ValueType> const& exitRateVector,
65 storm::storage::BitVector const& markovianStates)
66 : transitionMatrix(transitionMatrix), exitRateVector(exitRateVector), markovianStates(markovianStates) {
67 // Intentionally left empty
68 }
69
71 storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates,
72 ValueType const& upperTimeBound,
73 boost::optional<storm::storage::BitVector> const& relevantStates = boost::none) {
74 // Since there is no lower time bound, we can treat the psiStates as if they are absorbing.
75
76 // Compute some important subsets of states
77 storm::storage::BitVector maybeStates = ~(getProb0States(dir, phiStates, psiStates) | psiStates);
78 storm::storage::BitVector markovianMaybeStates = markovianStates & maybeStates;
79 storm::storage::BitVector probabilisticMaybeStates = ~markovianStates & maybeStates;
80 storm::storage::BitVector markovianStatesModMaybeStates = markovianMaybeStates % maybeStates;
81 storm::storage::BitVector probabilisticStatesModMaybeStates = probabilisticMaybeStates % maybeStates;
82 // Catch the case where this query can be solved by solving the untimed variant instead.
83 // This is the case if there is no Markovian maybe state (e.g. if the initial state is already a psi state) of if the time bound is infinity.
84 if (markovianMaybeStates.empty() || storm::utility::isInfinity(upperTimeBound)) {
85 return SparseMarkovAutomatonCslHelper::computeUntilProbabilities<ValueType>(env, dir, transitionMatrix, transitionMatrix.transpose(true), phiStates,
86 psiStates, false, false)
87 .values;
88 }
89
90 boost::optional<storm::storage::BitVector> relevantMaybeStates;
91 storm::storage::BitVector relevantMarkovianMaybeStates;
92 if (relevantStates) {
93 if (!relevantStates->isSubsetOf(markovianStates)) {
94 // Enhance the relevant states to also include Markovian states that are reachable in zero time from relevant probabilistic states
95 auto const enhancedRelevantStates =
96 storm::utility::graph::getReachableStates(transitionMatrix, *relevantStates, ~markovianStates, markovianStates);
97 relevantMaybeStates = enhancedRelevantStates % maybeStates;
98 } else {
99 relevantMaybeStates = relevantStates.get() % maybeStates;
100 }
101 relevantMarkovianMaybeStates = relevantMaybeStates.get() & markovianStatesModMaybeStates;
102 } else {
103 relevantMarkovianMaybeStates = markovianStatesModMaybeStates;
104 }
105 // Store the best solution known so far (useful in cases where the computation gets aborted)
106 std::vector<ValueType> bestKnownSolution;
107 if (relevantMaybeStates) {
108 bestKnownSolution.resize(relevantMaybeStates->getNumberOfSetBits());
109 }
110
111 // Get the exit rates restricted to only markovian maybe states.
112 std::vector<ValueType> markovianExitRates = storm::utility::vector::filterVector(exitRateVector, markovianMaybeStates);
113
114 // Obtain parameters of the algorithm
116 // Truncation error
118 // Precision to be achieved
119 ValueType epsilon = two * storm::utility::convertNumber<ValueType>(env.solver().timeBounded().getPrecision());
120 bool relativePrecision = env.solver().timeBounded().getRelativeTerminationCriterion();
121 // Uniformization rate
122 ValueType lambda = *std::max_element(markovianExitRates.begin(), markovianExitRates.end());
123 STORM_LOG_DEBUG("Initial lambda is " << lambda << ".");
124
125 // Split the transitions into various part
126 // The (uniformized) probabilities to go from a Markovian state to a psi state in one step
127 std::vector<std::pair<uint64_t, ValueType>> markovianToPsiProbabilities = getSparseOneStepProbabilities(markovianMaybeStates, psiStates);
128 for (auto& entry : markovianToPsiProbabilities) {
129 entry.second *= markovianExitRates[entry.first] / lambda;
130 }
131 // Uniformized transitions from Markovian maybe states to all other maybe states. Inserts selfloop entries.
132 storm::storage::SparseMatrix<ValueType> markovianToMaybeTransitions =
133 getUniformizedMarkovianTransitions(markovianExitRates, lambda, maybeStates, markovianMaybeStates);
134 // Transitions from probabilistic maybe states to probabilistic maybe states.
135 storm::storage::SparseMatrix<ValueType> probabilisticToProbabilisticTransitions =
136 transitionMatrix.getSubmatrix(true, probabilisticMaybeStates, probabilisticMaybeStates, false);
137 // Transitions from probabilistic maybe states to Markovian maybe states.
138 storm::storage::SparseMatrix<ValueType> probabilisticToMarkovianTransitions =
139 transitionMatrix.getSubmatrix(true, probabilisticMaybeStates, markovianMaybeStates, false);
140 // The probabilities to go from a probabilistic state to a psi state in one step
141 std::vector<std::pair<uint64_t, ValueType>> probabilisticToPsiProbabilities = getSparseOneStepProbabilities(probabilisticMaybeStates, psiStates);
142
143 // Set up a solver for the transitions between probabilistic states (if there are some)
144 Environment solverEnv = env;
145 solverEnv.solver().setForceExact(true); // Errors within the inner iterations can propagate significantly
146 auto solver = setUpProbabilisticStatesSolver(solverEnv, dir, probabilisticToProbabilisticTransitions);
147
148 // Allocate auxiliary memory that can be used during the iterations
149 std::vector<ValueType> maybeStatesValuesLower(maybeStates.getNumberOfSetBits(), storm::utility::zero<ValueType>()); // should be zero initially
150 std::vector<ValueType> maybeStatesValuesWeightedUpper(maybeStates.getNumberOfSetBits(), storm::utility::zero<ValueType>()); // should be zero initially
151 std::vector<ValueType> maybeStatesValuesUpper(maybeStates.getNumberOfSetBits(), storm::utility::zero<ValueType>()); // should be zero initially
152 std::vector<ValueType> nextMarkovianStateValues = std::move(
153 markovianExitRates); // At this point, the markovianExitRates are no longer needed, so we 'move' them away instead of allocating new memory
154 std::vector<ValueType> nextProbabilisticStateValues(probabilisticToProbabilisticTransitions.getRowGroupCount());
155 std::vector<ValueType> eqSysRhs(probabilisticToProbabilisticTransitions.getRowCount());
156
157 // Start the outer iterations which increase the uniformization rate until lower and upper bound on the result vector is sufficiently small
158 storm::utility::ProgressMeasurement progressIterations("iterations");
159 uint64_t iteration = 0;
160 progressIterations.startNewMeasurement(iteration);
161 bool converged = false;
162 bool abortedInnerIterations = false;
163 while (!converged) {
164 // Maximal step size
165 uint64_t N = storm::utility::ceil(lambda * upperTimeBound * std::exp(2) - storm::utility::log(kappa * epsilon));
166 // Compute poisson distribution.
167 // The division by 8 is similar to what is done for CTMCs (probably to reduce numerical impacts?)
168 auto foxGlynnResult = storm::utility::numerical::foxGlynn(lambda * upperTimeBound, epsilon * kappa / storm::utility::convertNumber<ValueType>(8.0));
169 // Scale the weights so they sum to one.
170 // storm::utility::vector::scaleVectorInPlace(foxGlynnResult.weights, storm::utility::one<ValueType>() / foxGlynnResult.totalWeight);
171
172 // Set up multiplier
173 auto markovianToMaybeMultiplier = storm::solver::MultiplierFactory<ValueType>().create(env, markovianToMaybeTransitions);
174 auto probabilisticToMarkovianMultiplier = storm::solver::MultiplierFactory<ValueType>().create(env, probabilisticToMarkovianTransitions);
175
176 // Perform inner iterations first for upper, then for lower bound
177 STORM_LOG_ASSERT(!storm::utility::vector::hasNonZeroEntry(maybeStatesValuesUpper), "Current values need to be initialized with zero.");
178 for (bool computeLowerBound : {false, true}) {
179 auto& maybeStatesValues = computeLowerBound ? maybeStatesValuesLower : maybeStatesValuesWeightedUpper;
180 ValueType targetValue = computeLowerBound ? storm::utility::zero<ValueType>() : storm::utility::one<ValueType>();
181 storm::utility::ProgressMeasurement progressSteps("steps in iteration " + std::to_string(iteration) + " for " +
182 std::string(computeLowerBound ? "lower" : "upper") + " bounds.");
183 progressSteps.setMaxCount(N);
184 progressSteps.startNewMeasurement(0);
185 bool firstIteration = true; // The first iterations can be irrelevant, because they will only produce zeroes anyway.
186 int64_t k = N;
187 // Iteration k = N is always non-relevant
188 for (--k; k >= 0; --k) {
189 // Check whether the iteration is relevant, that is, whether it will contribute non-zero values to the overall result
190 if (computeLowerBound) {
191 // Check whether the value for visiting a target state will be zero.
192 if (static_cast<uint64_t>(k) > foxGlynnResult.right) {
193 // Reaching this point means that we are in one of the earlier iterations where fox glynn told us to cut off
194 continue;
195 }
196 } else {
197 uint64_t i = N - 1 - k;
198 if (i > foxGlynnResult.right) {
199 // Reaching this point means that we are in a later iteration which will not contribute to the upper bound
200 // Since i will only get larger in subsequent iterations, we can directly break here.
201 break;
202 }
203 }
204
205 // Compute the values at Markovian maybe states.
206 if (firstIteration) {
207 firstIteration = false;
208 // Reaching this point means that this is the very first relevant iteration.
209 // If we are in the very first relevant iteration, we know that all states from the previous iteration have value zero.
210 // It is therefore valid (and necessary) to just set the values of Markovian states to zero.
211 std::fill(nextMarkovianStateValues.begin(), nextMarkovianStateValues.end(), storm::utility::zero<ValueType>());
212 } else {
213 // Compute the values at Markovian maybe states.
214 markovianToMaybeMultiplier->multiply(env, maybeStatesValues, nullptr, nextMarkovianStateValues);
215 for (auto const& oneStepProb : markovianToPsiProbabilities) {
216 nextMarkovianStateValues[oneStepProb.first] += oneStepProb.second * targetValue;
217 }
218 }
219
220 // Update the value when reaching a psi state.
221 // This has to be done after updating the Markovian state values since we needed the 'old' target value above.
222 if (computeLowerBound && static_cast<uint64_t>(k) >= foxGlynnResult.left) {
223 assert(static_cast<uint64_t>(k) <= foxGlynnResult.right); // has to hold since this iteration is relevant
224 targetValue += foxGlynnResult.weights[k - foxGlynnResult.left];
225 }
226
227 // Compute the values at probabilistic states.
228 probabilisticToMarkovianMultiplier->multiply(env, nextMarkovianStateValues, nullptr, eqSysRhs);
229 for (auto const& oneStepProb : probabilisticToPsiProbabilities) {
230 eqSysRhs[oneStepProb.first] += oneStepProb.second * targetValue;
231 }
232 if (solver) {
233 solver->solveEquations(solverEnv, dir, nextProbabilisticStateValues, eqSysRhs);
234 } else {
235 storm::utility::vector::reduceVectorMinOrMax(dir, eqSysRhs, nextProbabilisticStateValues,
236 probabilisticToProbabilisticTransitions.getRowGroupIndices());
237 }
238
239 // Create the new values for the maybestates
240 // Fuse the results together
241 storm::utility::vector::setVectorValues(maybeStatesValues, markovianStatesModMaybeStates, nextMarkovianStateValues);
242 storm::utility::vector::setVectorValues(maybeStatesValues, probabilisticStatesModMaybeStates, nextProbabilisticStateValues);
243 if (!computeLowerBound) {
244 // Add the scaled values to the actual result vector
245 uint64_t i = N - 1 - k;
246 if (i >= foxGlynnResult.left) {
247 assert(i <= foxGlynnResult.right); // has to hold since this iteration is considered relevant.
248 ValueType const& weight = foxGlynnResult.weights[i - foxGlynnResult.left];
249 storm::utility::vector::addScaledVector(maybeStatesValuesUpper, maybeStatesValuesWeightedUpper, weight);
250 }
251 }
252
253 progressSteps.updateProgress(N - k);
255 abortedInnerIterations = true;
256 break;
257 }
258 }
259
260 if (computeLowerBound) {
261 storm::utility::vector::scaleVectorInPlace(maybeStatesValuesLower, storm::utility::one<ValueType>() / foxGlynnResult.totalWeight);
262 } else {
263 storm::utility::vector::scaleVectorInPlace(maybeStatesValuesUpper, storm::utility::one<ValueType>() / foxGlynnResult.totalWeight);
264 }
265
266 if (abortedInnerIterations || storm::utility::resources::isTerminate()) {
267 break;
268 }
269
270 // Check if the lower and upper bound are sufficiently close to each other
271 converged = checkConvergence(maybeStatesValuesLower, maybeStatesValuesUpper, relevantMarkovianMaybeStates, epsilon, relativePrecision, kappa);
272 if (converged) {
273 break;
274 }
275
276 // Store the best solution we have found so far.
277 if (relevantMaybeStates) {
278 auto currentSolIt = bestKnownSolution.begin();
279 for (auto state : relevantMaybeStates.get()) {
280 // We take the average of the lower and upper bounds
281 *currentSolIt = (maybeStatesValuesLower[state] + maybeStatesValuesUpper[state]) / two;
282 ++currentSolIt;
283 }
284 }
285 }
286
287 if (!converged) {
288 // Increase the uniformization rate and prepare the next run
289
290 // Double lambda.
291 ValueType oldLambda = lambda;
292 lambda *= two;
293 STORM_LOG_DEBUG("Increased lambda to " << lambda << ".");
294
295 if (relativePrecision) {
296 // Reduce kappa a bit
297 ValueType minValue;
298 if (relevantMaybeStates) {
299 minValue = storm::utility::vector::min_if(maybeStatesValuesUpper, relevantMaybeStates.get());
300 } else {
301 minValue = *std::min_element(maybeStatesValuesUpper.begin(), maybeStatesValuesUpper.end());
302 }
304 kappa = std::min(kappa, minValue);
305 STORM_LOG_DEBUG("Decreased kappa to " << kappa << ".");
306 }
307
308 // Apply uniformization with new rate
309 uniformize(markovianToMaybeTransitions, markovianToPsiProbabilities, oldLambda, lambda, markovianStatesModMaybeStates);
310
311 // Reset the values of the maybe states to zero.
312 std::fill(maybeStatesValuesUpper.begin(), maybeStatesValuesUpper.end(), storm::utility::zero<ValueType>());
313 }
314 progressIterations.updateProgress(++iteration);
316 STORM_LOG_WARN("Aborted unif+ in iteration " << iteration << ".");
317 break;
318 }
319 }
320
321 // Prepare the result vector
322 std::vector<ValueType> result(transitionMatrix.getRowGroupCount(), storm::utility::zero<ValueType>());
323 // Set values of target states to 1
325
326 if (abortedInnerIterations && iteration > 1 && relevantMaybeStates && relevantStates) {
327 // We should take the stored solution instead of the current (probably more incorrect) lower/upper values
328 storm::utility::vector::setVectorValues(result, relevantMaybeStates.get(), bestKnownSolution);
329 } else {
330 // Set the values for Markovian "maybe" states
331 STORM_LOG_ASSERT(markovianMaybeStates.getNumberOfSetBits() == markovianStatesModMaybeStates.getNumberOfSetBits(),
332 "Unexpected number of Markovian maybe states");
333 auto subStateIt = markovianStatesModMaybeStates.begin();
334 for (auto const markovianState : markovianMaybeStates) {
335 result[markovianState] = (maybeStatesValuesLower[*subStateIt] + maybeStatesValuesUpper[*subStateIt]) / two;
336 ++subStateIt;
337 }
338 // At this point, we only need to set the values for probabilistic "maybe" states.
339 // We derive the values from the values of the other states, which are reached in zero time.
340 uint64_t probSubState = 0;
341 for (auto const probabilisticState : probabilisticMaybeStates) {
342 for (auto const probStateRow : transitionMatrix.getRowGroupIndices(probabilisticState)) {
343 eqSysRhs[probSubState] = transitionMatrix.multiplyRowWithVector(probStateRow, result);
344 ++probSubState;
345 }
346 }
347 if (solver) {
348 solver->solveEquations(solverEnv, dir, nextProbabilisticStateValues, eqSysRhs);
349 } else {
350 storm::utility::vector::reduceVectorMinOrMax(dir, eqSysRhs, nextProbabilisticStateValues,
351 probabilisticToProbabilisticTransitions.getRowGroupIndices());
352 }
353 storm::utility::vector::setVectorValues(result, probabilisticMaybeStates, nextProbabilisticStateValues);
354 }
355 return result;
356 }
357
358 private:
359 bool checkConvergence(std::vector<ValueType> const& lower, std::vector<ValueType> const& upper, storm::storage::BitVector const& relevantValues,
360 ValueType const& epsilon, bool relative, ValueType& kappa) {
361 STORM_LOG_ASSERT(relevantValues.size() == lower.size(), "Relevant values size mismatch.");
362 if (!relative) {
363 return storm::utility::vector::equalModuloPrecision(lower, upper, relevantValues, epsilon * (storm::utility::one<ValueType>() - kappa), false);
364 }
365 ValueType truncationError = epsilon * kappa;
366 for (uint64_t const i : relevantValues) {
367 if (lower[i] == upper[i]) {
368 continue;
369 }
370 if (lower[i] <= truncationError) {
371 return false;
372 }
373 ValueType absDiff = upper[i] - lower[i] + truncationError;
374 ValueType relDiff = absDiff / lower[i];
375 if (relDiff > epsilon) {
376 return false;
377 }
378 STORM_LOG_ASSERT(absDiff > storm::utility::zero<ValueType>(), "Upper bound " << upper[i] << " is smaller than lower bound " << lower[i] << ".");
379 }
380 return true;
381 }
382
383 storm::storage::SparseMatrix<ValueType> getUniformizedMarkovianTransitions(std::vector<ValueType> const& oldRates, ValueType uniformizationRate,
384 storm::storage::BitVector const& maybeStates,
385 storm::storage::BitVector const& markovianMaybeStates) {
386 // We need a submatrix whose rows correspond to the markovian states and columns correpsond to the maybestates.
387 // In addition, we need 'selfloop' entries for the markovian maybe states.
388
389 // First build a submatrix without selfloop entries
390 auto submatrix = transitionMatrix.getSubmatrix(true, markovianMaybeStates, maybeStates);
391 assert(submatrix.getRowCount() == submatrix.getRowGroupCount());
392
393 // Now add selfloop entries at the correct positions and apply uniformization
394 storm::storage::SparseMatrixBuilder<ValueType> builder(submatrix.getRowCount(), submatrix.getColumnCount());
395 auto markovianStateColumns = markovianMaybeStates % maybeStates;
396 uint64_t row = 0;
397 for (auto selfloopColumn : markovianStateColumns) {
398 ValueType const& oldExitRate = oldRates[row];
399 bool foundSelfoop = false;
400 for (auto const& entry : submatrix.getRow(row)) {
401 if (entry.getColumn() == selfloopColumn) {
402 foundSelfoop = true;
403 ValueType newSelfLoop = uniformizationRate - oldExitRate + entry.getValue() * oldExitRate;
404 builder.addNextValue(row, entry.getColumn(), newSelfLoop / uniformizationRate);
405 } else {
406 builder.addNextValue(row, entry.getColumn(), entry.getValue() * oldExitRate / uniformizationRate);
407 }
408 }
409 if (!foundSelfoop) {
410 ValueType newSelfLoop = uniformizationRate - oldExitRate;
411 builder.addNextValue(row, selfloopColumn, newSelfLoop / uniformizationRate);
412 }
413 ++row;
414 }
415 assert(row == submatrix.getRowCount());
416
417 return builder.build();
418 }
419
420 void uniformize(storm::storage::SparseMatrix<ValueType>& matrix, std::vector<std::pair<uint64_t, ValueType>>& oneSteps,
421 std::vector<ValueType> const& oldRates, ValueType uniformizationRate, storm::storage::BitVector const& selfloopColumns) {
422 uint64_t row = 0;
423 for (auto selfloopColumn : selfloopColumns) {
424 ValueType const& oldExitRate = oldRates[row];
425 if (oldExitRate == uniformizationRate) {
426 // Already uniformized.
427 ++row;
428 continue;
429 }
430 for (auto& v : matrix.getRow(row)) {
431 if (v.getColumn() == selfloopColumn) {
432 ValueType newSelfLoop = uniformizationRate - oldExitRate + v.getValue() * oldExitRate;
433 v.setValue(newSelfLoop / uniformizationRate);
434 } else {
435 v.setValue(v.getValue() * oldExitRate / uniformizationRate);
436 }
437 }
438 ++row;
439 }
440 assert(row == matrix.getRowCount());
441 for (auto& oneStep : oneSteps) {
442 oneStep.second *= oldRates[oneStep.first] / uniformizationRate;
443 }
444 }
445
448 void uniformize(storm::storage::SparseMatrix<ValueType>& matrix, std::vector<std::pair<uint64_t, ValueType>>& oneSteps, ValueType oldUniformizationRate,
449 ValueType newUniformizationRate, storm::storage::BitVector const& selfloopColumns) {
450 if (oldUniformizationRate != newUniformizationRate) {
451 assert(oldUniformizationRate < newUniformizationRate);
452 ValueType rateDiff = newUniformizationRate - oldUniformizationRate;
453 ValueType rateFraction = oldUniformizationRate / newUniformizationRate;
454 uint64_t row = 0;
455 for (auto selfloopColumn : selfloopColumns) {
456 for (auto& v : matrix.getRow(row)) {
457 if (v.getColumn() == selfloopColumn) {
458 ValueType newSelfLoop = rateDiff + v.getValue() * oldUniformizationRate;
459 v.setValue(newSelfLoop / newUniformizationRate);
460 } else {
461 v.setValue(v.getValue() * rateFraction);
462 }
463 }
464 ++row;
465 }
466 assert(row == matrix.getRowCount());
467 for (auto& oneStep : oneSteps) {
468 oneStep.second *= rateFraction;
469 }
470 }
471 }
472
473 storm::storage::BitVector getProb0States(OptimizationDirection dir, storm::storage::BitVector const& phiStates,
474 storm::storage::BitVector const& psiStates) const {
475 if (dir == storm::solver::OptimizationDirection::Maximize) {
476 return storm::utility::graph::performProb0A(transitionMatrix.transpose(true), phiStates, psiStates);
477 } else {
478 return storm::utility::graph::performProb0E(transitionMatrix, transitionMatrix.getRowGroupIndices(), transitionMatrix.transpose(true), phiStates,
479 psiStates);
480 }
481 }
482
488 std::vector<std::pair<uint64_t, ValueType>> getSparseOneStepProbabilities(storm::storage::BitVector const& sourceStateConstraint,
489 storm::storage::BitVector const& targetStateConstraint) const {
490 auto denseResult = transitionMatrix.getConstrainedRowGroupSumVector(sourceStateConstraint, targetStateConstraint);
491 std::vector<std::pair<uint64_t, ValueType>> sparseResult;
492 for (uint64_t i = 0; i < denseResult.size(); ++i) {
493 auto const& val = denseResult[i];
494 if (!storm::utility::isZero(val)) {
495 sparseResult.emplace_back(i, val);
496 }
497 }
498 return sparseResult;
499 }
500
501 storm::storage::SparseMatrix<ValueType> const& transitionMatrix;
502 std::vector<ValueType> const& exitRateVector;
503 storm::storage::BitVector const& markovianStates;
504};
505
506template<typename ValueType>
508 storm::storage::SparseMatrix<ValueType> const& transitionMatrix, std::vector<ValueType> const& exitRates,
509 storm::storage::BitVector const& goalStates, storm::storage::BitVector const& markovianNonGoalStates,
510 storm::storage::BitVector const& probabilisticNonGoalStates, std::vector<ValueType>& markovianNonGoalValues,
511 std::vector<ValueType>& probabilisticNonGoalValues, ValueType delta, uint64_t numberOfSteps) {
512 // Start by computing four sparse matrices:
513 // * a matrix aMarkovian with all (discretized) transitions from Markovian non-goal states to all Markovian non-goal states.
514 // * a matrix aMarkovianToProbabilistic with all (discretized) transitions from Markovian non-goal states to all probabilistic non-goal states.
515 // * a matrix aProbabilistic with all (non-discretized) transitions from probabilistic non-goal states to other probabilistic non-goal states.
516 // * a matrix aProbabilisticToMarkovian with all (non-discretized) transitions from probabilistic non-goal states to all Markovian non-goal states.
517 typename storm::storage::SparseMatrix<ValueType> aMarkovian = transitionMatrix.getSubmatrix(true, markovianNonGoalStates, markovianNonGoalStates, true);
518
519 bool existProbabilisticStates = !probabilisticNonGoalStates.empty();
520 typename storm::storage::SparseMatrix<ValueType> aMarkovianToProbabilistic;
521 typename storm::storage::SparseMatrix<ValueType> aProbabilistic;
522 typename storm::storage::SparseMatrix<ValueType> aProbabilisticToMarkovian;
523 if (existProbabilisticStates) {
524 aMarkovianToProbabilistic = transitionMatrix.getSubmatrix(true, markovianNonGoalStates, probabilisticNonGoalStates);
525 aProbabilistic = transitionMatrix.getSubmatrix(true, probabilisticNonGoalStates, probabilisticNonGoalStates);
526 aProbabilisticToMarkovian = transitionMatrix.getSubmatrix(true, probabilisticNonGoalStates, markovianNonGoalStates);
527 }
528
529 // The matrices with transitions from Markovian states need to be digitized.
530 // Digitize aMarkovian. Based on whether the transition is a self-loop or not, we apply the two digitization rules.
531 uint64_t rowIndex = 0;
532 for (auto state : markovianNonGoalStates) {
533 for (auto& element : aMarkovian.getRow(rowIndex)) {
534 ValueType eTerm = std::exp(-exitRates[state] * delta);
535 if (element.getColumn() == rowIndex) {
536 element.setValue((storm::utility::one<ValueType>() - eTerm) * element.getValue() + eTerm);
537 } else {
538 element.setValue((storm::utility::one<ValueType>() - eTerm) * element.getValue());
539 }
540 }
541 ++rowIndex;
542 }
543
544 // Digitize aMarkovianToProbabilistic. As there are no self-loops in this case, we only need to apply the digitization formula for regular successors.
545 if (existProbabilisticStates) {
546 rowIndex = 0;
547 for (auto state : markovianNonGoalStates) {
548 for (auto& element : aMarkovianToProbabilistic.getRow(rowIndex)) {
549 element.setValue((1 - std::exp(-exitRates[state] * delta)) * element.getValue());
550 }
551 ++rowIndex;
552 }
553 }
554
555 // Initialize the two vectors that hold the variable one-step probabilities to all target states for probabilistic and Markovian (non-goal) states.
556 std::vector<ValueType> bProbabilistic(existProbabilisticStates ? aProbabilistic.getRowCount() : 0);
557 std::vector<ValueType> bMarkovian(markovianNonGoalStates.getNumberOfSetBits());
558
559 // Compute the two fixed right-hand side vectors, one for Markovian states and one for the probabilistic ones.
560 std::vector<ValueType> bProbabilisticFixed;
561 if (existProbabilisticStates) {
562 bProbabilisticFixed = transitionMatrix.getConstrainedRowGroupSumVector(probabilisticNonGoalStates, goalStates);
563 }
564 std::vector<ValueType> bMarkovianFixed;
565 bMarkovianFixed.reserve(markovianNonGoalStates.getNumberOfSetBits());
566 for (auto state : markovianNonGoalStates) {
567 bMarkovianFixed.push_back(storm::utility::zero<ValueType>());
568
569 for (auto& element : transitionMatrix.getRowGroup(state)) {
570 if (goalStates.get(element.getColumn())) {
571 bMarkovianFixed.back() += (1 - std::exp(-exitRates[state] * delta)) * element.getValue();
572 }
573 }
574 }
575
576 // Create a solver object (only if there are actually transitions between probabilistic states)
577 auto solverEnv = env;
578 solverEnv.solver().setForceExact(true);
579 auto solver = setUpProbabilisticStatesSolver(solverEnv, dir, aProbabilistic);
580
581 // Perform the actual value iteration
582 // * loop until the step bound has been reached
583 // * in the loop:
584 // * perform value iteration using A_PSwG, v_PS and the vector b where b = (A * 1_G)|PS + A_PStoMS * v_MS
585 // and 1_G being the characteristic vector for all goal states.
586 // * perform one timed-step using v_MS := A_MSwG * v_MS + A_MStoPS * v_PS + (A * 1_G)|MS
587 std::vector<ValueType> markovianNonGoalValuesSwap(markovianNonGoalValues);
588 for (uint64_t currentStep = 0; currentStep < numberOfSteps; ++currentStep) {
589 if (existProbabilisticStates) {
590 // Start by (re-)computing bProbabilistic = bProbabilisticFixed + aProbabilisticToMarkovian * vMarkovian.
591 aProbabilisticToMarkovian.multiplyWithVector(markovianNonGoalValues, bProbabilistic);
592 storm::utility::vector::addVectors(bProbabilistic, bProbabilisticFixed, bProbabilistic);
593
594 // Now perform the inner value iteration for probabilistic states.
595 if (solver) {
596 solver->solveEquations(solverEnv, dir, probabilisticNonGoalValues, bProbabilistic);
597 } else {
598 storm::utility::vector::reduceVectorMinOrMax(dir, bProbabilistic, probabilisticNonGoalValues, aProbabilistic.getRowGroupIndices());
599 }
600
601 // (Re-)compute bMarkovian = bMarkovianFixed + aMarkovianToProbabilistic * vProbabilistic.
602 aMarkovianToProbabilistic.multiplyWithVector(probabilisticNonGoalValues, bMarkovian);
603 storm::utility::vector::addVectors(bMarkovian, bMarkovianFixed, bMarkovian);
604 }
605
606 aMarkovian.multiplyWithVector(markovianNonGoalValues, markovianNonGoalValuesSwap);
607 std::swap(markovianNonGoalValues, markovianNonGoalValuesSwap);
608 if (existProbabilisticStates) {
609 storm::utility::vector::addVectors(markovianNonGoalValues, bMarkovian, markovianNonGoalValues);
610 } else {
611 storm::utility::vector::addVectors(markovianNonGoalValues, bMarkovianFixed, markovianNonGoalValues);
612 }
614 break;
615 }
616 }
617
618 if (existProbabilisticStates) {
619 // After the loop, perform one more step of the value iteration for PS states.
620 aProbabilisticToMarkovian.multiplyWithVector(markovianNonGoalValues, bProbabilistic);
621 storm::utility::vector::addVectors(bProbabilistic, bProbabilisticFixed, bProbabilistic);
622 if (solver) {
623 solver->solveEquations(solverEnv, dir, probabilisticNonGoalValues, bProbabilistic);
624 } else {
625 storm::utility::vector::reduceVectorMinOrMax(dir, bProbabilistic, probabilisticNonGoalValues, aProbabilistic.getRowGroupIndices());
626 }
627 }
628}
629
630template<typename ValueType>
632 storm::storage::SparseMatrix<ValueType> const& transitionMatrix,
633 std::vector<ValueType> const& exitRateVector, storm::storage::BitVector const& markovianStates,
634 storm::storage::BitVector const& psiStates, std::pair<double, double> const& boundsPair) {
635 STORM_LOG_TRACE("Using IMCA's technique to compute bounded until probabilities.");
636
637 uint64_t numberOfStates = transitionMatrix.getRowGroupCount();
638
639 // 'Unpack' the bounds to make them more easily accessible.
640 double lowerBound = boundsPair.first;
641 double upperBound = boundsPair.second;
642
643 // (1) Compute the accuracy we need to achieve the required error bound.
644 ValueType maxExitRate = 0;
645 for (auto value : exitRateVector) {
646 maxExitRate = std::max(maxExitRate, value);
647 }
648 ValueType delta = (2.0 * storm::utility::convertNumber<ValueType>(env.solver().timeBounded().getPrecision())) / (upperBound * maxExitRate * maxExitRate);
649
650 // (2) Compute the number of steps we need to make for the interval.
651 uint64_t numberOfSteps = static_cast<uint64_t>(std::ceil((upperBound - lowerBound) / delta));
652 STORM_LOG_INFO("Performing " << numberOfSteps << " iterations (delta=" << delta << ") for interval [" << lowerBound << ", " << upperBound << "].\n");
653
654 // (3) Compute the non-goal states and initialize two vectors
655 // * vProbabilistic holds the probability values of probabilistic non-goal states.
656 // * vMarkovian holds the probability values of Markovian non-goal states.
657 storm::storage::BitVector const& markovianNonGoalStates = markovianStates & ~psiStates;
658 storm::storage::BitVector const& probabilisticNonGoalStates = ~markovianStates & ~psiStates;
659 std::vector<ValueType> vProbabilistic(probabilisticNonGoalStates.getNumberOfSetBits());
660 std::vector<ValueType> vMarkovian(markovianNonGoalStates.getNumberOfSetBits());
661
662 computeBoundedReachabilityProbabilitiesImca(env, dir, transitionMatrix, exitRateVector, psiStates, markovianNonGoalStates, probabilisticNonGoalStates,
663 vMarkovian, vProbabilistic, delta, numberOfSteps);
664
665 // (4) If the lower bound of interval was non-zero, we need to take the current values as the starting values for a subsequent value iteration.
666 if (lowerBound != storm::utility::zero<ValueType>()) {
667 std::vector<ValueType> vAllProbabilistic((~markovianStates).getNumberOfSetBits());
668 std::vector<ValueType> vAllMarkovian(markovianStates.getNumberOfSetBits());
669
670 // Create the starting value vectors for the next value iteration based on the results of the previous one.
671 storm::utility::vector::setVectorValues<ValueType>(vAllProbabilistic, psiStates % ~markovianStates, storm::utility::one<ValueType>());
672 storm::utility::vector::setVectorValues<ValueType>(vAllProbabilistic, ~psiStates % ~markovianStates, vProbabilistic);
673 storm::utility::vector::setVectorValues<ValueType>(vAllMarkovian, psiStates % markovianStates, storm::utility::one<ValueType>());
674 storm::utility::vector::setVectorValues<ValueType>(vAllMarkovian, ~psiStates % markovianStates, vMarkovian);
675
676 // Compute the number of steps to reach the target interval.
677 numberOfSteps = static_cast<uint64_t>(std::ceil(lowerBound / delta));
678 STORM_LOG_INFO("Performing " << numberOfSteps << " iterations (delta=" << delta << ") for interval [0, " << lowerBound << "].\n");
679
680 // Compute the bounded reachability for interval [0, b-a].
681 computeBoundedReachabilityProbabilitiesImca(env, dir, transitionMatrix, exitRateVector, storm::storage::BitVector(numberOfStates), markovianStates,
682 ~markovianStates, vAllMarkovian, vAllProbabilistic, delta, numberOfSteps);
683
684 // Create the result vector out of vAllProbabilistic and vAllMarkovian and return it.
685 std::vector<ValueType> result(numberOfStates, storm::utility::zero<ValueType>());
686 storm::utility::vector::setVectorValues(result, ~markovianStates, vAllProbabilistic);
687 storm::utility::vector::setVectorValues(result, markovianStates, vAllMarkovian);
688
689 return result;
690 } else {
691 // Create the result vector out of 1_G, vProbabilistic and vMarkovian and return it.
692 std::vector<ValueType> result(numberOfStates);
694 storm::utility::vector::setVectorValues(result, probabilisticNonGoalStates, vProbabilistic);
695 storm::utility::vector::setVectorValues(result, markovianNonGoalStates, vMarkovian);
696 return result;
697 }
698}
699
700template<typename ValueType, typename std::enable_if<storm::NumberTraits<ValueType>::SupportsExponential, int>::type>
703 std::vector<ValueType> const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& phiStates,
704 storm::storage::BitVector const& psiStates, std::pair<double, double> const& boundsPair) {
705 STORM_LOG_THROW(!env.solver().isForceExact(), storm::exceptions::InvalidOperationException,
706 "Exact computations not possible for bounded until probabilities.");
707
708 // Choose the applicable method
709 auto method = env.solver().timeBounded().getMaMethod();
710 if (method == storm::solver::MaBoundedReachabilityMethod::Imca) {
711 if (!phiStates.full()) {
712 STORM_LOG_WARN("Using Unif+ method because IMCA method does not support (phi Until psi) for non-trivial phi");
713 method = storm::solver::MaBoundedReachabilityMethod::UnifPlus;
714 }
715 } else {
716 STORM_LOG_ASSERT(method == storm::solver::MaBoundedReachabilityMethod::UnifPlus, "Unknown solution method.");
717 if (!storm::utility::isZero(boundsPair.first)) {
718 STORM_LOG_WARN("Using IMCA method because Unif+ does not support a lower bound > 0.");
719 method = storm::solver::MaBoundedReachabilityMethod::Imca;
720 }
721 }
722
723 if (method == storm::solver::MaBoundedReachabilityMethod::Imca) {
724 return computeBoundedUntilProbabilitiesImca(env, goal.direction(), transitionMatrix, exitRateVector, markovianStates, psiStates, boundsPair);
725 } else {
726 UnifPlusHelper<ValueType> helper(transitionMatrix, exitRateVector, markovianStates);
727 boost::optional<storm::storage::BitVector> relevantValues;
728 if (goal.hasRelevantValues()) {
729 relevantValues = std::move(goal.relevantValues());
730 }
731 return helper.computeBoundedUntilProbabilities(env, goal.direction(), phiStates, psiStates, boundsPair.second, relevantValues);
732 }
733}
734
735template<typename ValueType, typename std::enable_if<!storm::NumberTraits<ValueType>::SupportsExponential, int>::type>
738 std::vector<ValueType> const&, storm::storage::BitVector const&,
740 std::pair<double, double> const&) {
741 STORM_LOG_THROW(false, storm::exceptions::InvalidOperationException, "Computing bounded until probabilities is unsupported for this value type.");
742}
743
744template<typename ValueType>
746 Environment const& env, OptimizationDirection dir, storm::storage::SparseMatrix<ValueType> const& transitionMatrix,
747 storm::storage::SparseMatrix<ValueType> const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates,
748 bool qualitative, bool produceScheduler) {
749 return storm::modelchecker::helper::SparseMdpPrctlHelper<ValueType>::computeUntilProbabilities(env, dir, transitionMatrix, backwardTransitions, phiStates,
750 psiStates, qualitative, produceScheduler);
751}
752
753template<typename ValueType, typename RewardModelType>
755 Environment const& env, OptimizationDirection dir, storm::storage::SparseMatrix<ValueType> const& transitionMatrix,
756 storm::storage::SparseMatrix<ValueType> const& backwardTransitions, std::vector<ValueType> const& exitRateVector,
757 storm::storage::BitVector const& markovianStates, RewardModelType const& rewardModel, bool produceScheduler) {
758 // Get a reward model where the state rewards are scaled accordingly
759 std::vector<ValueType> stateRewardWeights(transitionMatrix.getRowGroupCount(), storm::utility::zero<ValueType>());
760 for (auto const markovianState : markovianStates) {
761 stateRewardWeights[markovianState] = storm::utility::one<ValueType>() / exitRateVector[markovianState];
762 }
763 std::vector<ValueType> totalRewardVector = rewardModel.getTotalActionRewardVector(transitionMatrix, stateRewardWeights);
764 RewardModelType scaledRewardModel(std::nullopt, std::move(totalRewardVector));
765
766 return SparseMdpPrctlHelper<ValueType>::computeTotalRewards(env, dir, transitionMatrix, backwardTransitions, scaledRewardModel, false, produceScheduler);
767}
768
769template<typename ValueType, typename RewardModelType>
771 Environment const& env, OptimizationDirection dir, storm::storage::SparseMatrix<ValueType> const& transitionMatrix,
772 storm::storage::SparseMatrix<ValueType> const& backwardTransitions, std::vector<ValueType> const& exitRateVector,
773 storm::storage::BitVector const& markovianStates, RewardModelType const& rewardModel, storm::storage::BitVector const& psiStates, bool produceScheduler) {
774 // Get a reward model where the state rewards are scaled accordingly
775 std::vector<ValueType> stateRewardWeights(transitionMatrix.getRowGroupCount(), storm::utility::zero<ValueType>());
776 for (auto const markovianState : markovianStates) {
777 stateRewardWeights[markovianState] = storm::utility::one<ValueType>() / exitRateVector[markovianState];
778 }
779 std::vector<ValueType> totalRewardVector = rewardModel.getTotalActionRewardVector(transitionMatrix, stateRewardWeights);
780 RewardModelType scaledRewardModel(std::nullopt, std::move(totalRewardVector));
781
782 return SparseMdpPrctlHelper<ValueType>::computeReachabilityRewards(env, dir, transitionMatrix, backwardTransitions, scaledRewardModel, psiStates, false,
783 produceScheduler);
784}
785
786template<typename ValueType>
788 Environment const& env, OptimizationDirection dir, storm::storage::SparseMatrix<ValueType> const& transitionMatrix,
789 storm::storage::SparseMatrix<ValueType> const& backwardTransitions, std::vector<ValueType> const& exitRateVector,
790 storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, bool produceScheduler) {
791 // Get a reward model representing expected sojourn times
792 std::vector<ValueType> rewardValues(transitionMatrix.getRowCount(), storm::utility::zero<ValueType>());
793 for (auto const markovianState : markovianStates) {
794 rewardValues[transitionMatrix.getRowGroupIndices()[markovianState]] = storm::utility::one<ValueType>() / exitRateVector[markovianState];
795 }
796 storm::models::sparse::StandardRewardModel<ValueType> rewardModel(std::nullopt, std::move(rewardValues));
797
798 return SparseMdpPrctlHelper<ValueType>::computeReachabilityRewards(env, dir, transitionMatrix, backwardTransitions, rewardModel, psiStates, false,
799 produceScheduler);
800}
801
804 std::vector<double> const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& phiStates,
805 storm::storage::BitVector const& psiStates, std::pair<double, double> const& boundsPair);
806
808 Environment const& env, OptimizationDirection dir, storm::storage::SparseMatrix<double> const& transitionMatrix,
809 storm::storage::SparseMatrix<double> const& backwardTransitions, storm::storage::BitVector const& phiStates, storm::storage::BitVector const& psiStates,
810 bool qualitative, bool produceScheduler);
811
813 Environment const& env, OptimizationDirection dir, storm::storage::SparseMatrix<double> const& transitionMatrix,
814 storm::storage::SparseMatrix<double> const& backwardTransitions, std::vector<double> const& exitRateVector,
815 storm::storage::BitVector const& markovianStates, storm::models::sparse::StandardRewardModel<double> const& rewardModel,
816 storm::storage::BitVector const& psiStates, bool produceScheduler);
817
819 Environment const& env, OptimizationDirection dir, storm::storage::SparseMatrix<double> const& transitionMatrix,
820 storm::storage::SparseMatrix<double> const& backwardTransitions, std::vector<double> const& exitRateVector,
821 storm::storage::BitVector const& markovianStates, storm::models::sparse::StandardRewardModel<double> const& rewardModel, bool produceScheduler);
822
824 Environment const& env, OptimizationDirection dir, storm::storage::SparseMatrix<double> const& transitionMatrix,
825 storm::storage::SparseMatrix<double> const& backwardTransitions, std::vector<double> const& exitRateVector,
826 storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, bool produceScheduler);
827
828template std::vector<storm::RationalNumber> SparseMarkovAutomatonCslHelper::computeBoundedUntilProbabilities(
830 std::vector<storm::RationalNumber> const& exitRateVector, storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& phiStates,
831 storm::storage::BitVector const& psiStates, std::pair<double, double> const& boundsPair);
832
835 storm::storage::SparseMatrix<storm::RationalNumber> const& backwardTransitions, storm::storage::BitVector const& phiStates,
836 storm::storage::BitVector const& psiStates, bool qualitative, bool produceScheduler);
837
840 storm::storage::SparseMatrix<storm::RationalNumber> const& backwardTransitions, std::vector<storm::RationalNumber> const& exitRateVector,
842 storm::storage::BitVector const& psiStates, bool produceScheduler);
843
846 storm::storage::SparseMatrix<storm::RationalNumber> const& backwardTransitions, std::vector<storm::RationalNumber> const& exitRateVector,
848 bool produceScheduler);
849
852 storm::storage::SparseMatrix<storm::RationalNumber> const& backwardTransitions, std::vector<storm::RationalNumber> const& exitRateVector,
853 storm::storage::BitVector const& markovianStates, storm::storage::BitVector const& psiStates, bool produceScheduler);
854} // namespace helper
855} // namespace modelchecker
856} // namespace storm
SolverEnvironment & solver()
void setMethod(storm::solver::MinMaxMethod value, bool isSetFromDefault=false)
MinMaxSolverEnvironment & minMax()
TimeBoundedSolverEnvironment & timeBounded()
storm::RationalNumber const & getPrecision() const
storm::RationalNumber const & getUnifPlusKappa() const
storm::solver::MaBoundedReachabilityMethod const & getMaMethod() const
static MDPSparseModelCheckingHelperReturnType< ValueType > computeTotalRewards(Environment const &env, OptimizationDirection dir, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, std::vector< ValueType > const &exitRateVector, storm::storage::BitVector const &markovianStates, RewardModelType const &rewardModel, bool produceScheduler)
static MDPSparseModelCheckingHelperReturnType< ValueType > computeReachabilityRewards(Environment const &env, OptimizationDirection dir, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, std::vector< ValueType > const &exitRateVector, storm::storage::BitVector const &markovianStates, RewardModelType const &rewardModel, storm::storage::BitVector const &psiStates, bool produceScheduler)
static MDPSparseModelCheckingHelperReturnType< ValueType > computeUntilProbabilities(Environment const &env, OptimizationDirection dir, 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)
static MDPSparseModelCheckingHelperReturnType< ValueType > computeReachabilityTimes(Environment const &env, OptimizationDirection dir, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, storm::storage::SparseMatrix< ValueType > const &backwardTransitions, std::vector< ValueType > const &exitRateVector, storm::storage::BitVector const &markovianStates, storm::storage::BitVector const &psiStates, bool produceScheduler)
static std::vector< ValueType > computeBoundedUntilProbabilities(Environment const &env, storm::solver::SolveGoal< ValueType > &&goal, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, std::vector< ValueType > const &exitRateVector, storm::storage::BitVector const &markovianStates, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, std::pair< double, double > const &boundsPair)
static MDPSparseModelCheckingHelperReturnType< SolutionType > 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 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 MDPSparseModelCheckingHelperReturnType< SolutionType > 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())
std::vector< ValueType > computeBoundedUntilProbabilities(storm::Environment const &env, OptimizationDirection dir, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates, ValueType const &upperTimeBound, boost::optional< storm::storage::BitVector > const &relevantStates=boost::none)
UnifPlusHelper(storm::storage::SparseMatrix< ValueType > const &transitionMatrix, std::vector< ValueType > const &exitRateVector, storm::storage::BitVector const &markovianStates)
virtual std::unique_ptr< MinMaxLinearEquationSolver< ValueType, SolutionType > > create(Environment const &env) const override
std::unique_ptr< Multiplier< ValueType, SolutionType > > create(Environment const &env, storm::storage::SparseMatrix< ValueType > const &matrix)
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
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.
const_iterator begin() const
Returns an iterator to the indices of the set bits in the bit vector.
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.
A class that holds a possibly non-square matrix in the compressed row storage format.
const_rows getRow(index_type row) const
Returns an object representing the given row.
void multiplyWithVector(std::vector< value_type > const &vector, std::vector< value_type > &result, std::vector< value_type > const *summand=nullptr) const
Multiplies the matrix with the given vector and writes the result to the given result vector.
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 ...
const_rows getRowGroup(index_type rowGroup) const
Returns an object representing the given row group.
index_type getRowGroupCount() const
Returns the number of row groups in the matrix.
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.
index_type getNonzeroEntryCount() const
Returns the cached number of nonzero entries in the matrix.
A class that provides convenience operations to display run times.
bool updateProgress(uint64_t count)
Updates the progress to the current count and prints it if the delay passed.
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.
#define STORM_LOG_INFO(message)
Definition logging.h:24
#define STORM_LOG_WARN(message)
Definition logging.h:25
#define STORM_LOG_DEBUG(message)
Definition logging.h:18
#define STORM_LOG_TRACE(message)
Definition logging.h:12
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
SFTBDDChecker::ValueType ValueType
void computeBoundedReachabilityProbabilitiesImca(Environment const &env, OptimizationDirection dir, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, std::vector< ValueType > const &exitRates, storm::storage::BitVector const &goalStates, storm::storage::BitVector const &markovianNonGoalStates, storm::storage::BitVector const &probabilisticNonGoalStates, std::vector< ValueType > &markovianNonGoalValues, std::vector< ValueType > &probabilisticNonGoalValues, ValueType delta, uint64_t numberOfSteps)
std::unique_ptr< storm::solver::MinMaxLinearEquationSolver< ValueType > > setUpProbabilisticStatesSolver(storm::Environment &env, OptimizationDirection dir, storm::storage::SparseMatrix< ValueType > const &transitions)
std::vector< ValueType > computeBoundedUntilProbabilitiesImca(Environment const &env, OptimizationDirection dir, storm::storage::SparseMatrix< ValueType > const &transitionMatrix, std::vector< ValueType > const &exitRateVector, storm::storage::BitVector const &markovianStates, storm::storage::BitVector const &psiStates, std::pair< double, double > const &boundsPair)
storm::storage::BitVector getReachableStates(storm::storage::SparseMatrix< T > const &transitionMatrix, storm::storage::BitVector const &initialStates, storm::storage::BitVector const &constraintStates, storm::storage::BitVector const &targetStates, bool useStepBound, uint_fast64_t maximalSteps, boost::optional< storm::storage::BitVector > const &choiceFilter)
Performs a forward depth-first search through the underlying graph structure to identify the states t...
Definition graph.cpp:41
bool hasCycle(storm::storage::SparseMatrix< T > const &transitionMatrix, boost::optional< storm::storage::BitVector > const &subsystem)
Returns true if the graph represented by the given matrix has a cycle.
Definition graph.cpp:136
storm::storage::BitVector performProb0A(storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
Definition graph.cpp:733
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...
Definition graph.cpp:960
FoxGlynnResult< ValueType > foxGlynn(ValueType lambda, ValueType epsilon)
bool isTerminate()
Check whether the program should terminate (due to some abort signal).
VT min_if(std::vector< VT > const &values, storm::storage::BitVector const &filter)
Computes the minimum of the entries from the values that are selected by the (non-empty) filter.
Definition vector.h:591
void addVectors(std::vector< InValueType1 > const &firstOperand, std::vector< InValueType2 > const &secondOperand, std::vector< OutValueType > &target)
Adds the two given vectors and writes the result to the target vector.
Definition vector.h:399
void setVectorValues(std::vector< T > &vector, storm::storage::BitVector const &positions, std::vector< T > const &values)
Sets the provided values at the provided positions in the given vector.
Definition vector.h:78
bool equalModuloPrecision(T const &val1, T const &val2, T const &precision, bool relativeError=true)
Compares the given elements and determines whether they are equal modulo the given precision.
Definition vector.h:731
void reduceVectorMinOrMax(storm::solver::OptimizationDirection dir, std::vector< T > const &source, std::vector< T > &target, std::vector< uint_fast64_t > const &rowGrouping, std::vector< uint_fast64_t > *choices=nullptr)
Reduces the given source vector by selecting either the smallest or the largest out of each row group...
Definition vector.h:711
void addScaledVector(std::vector< InValueType1 > &firstOperand, std::vector< InValueType2 > const &secondOperand, InValueType3 const &factor)
Computes x:= x + a*y, i.e., adds each element of the first vector and (the corresponding element of t...
Definition vector.h:460
void scaleVectorInPlace(std::vector< ValueType1 > &target, ValueType2 const &factor)
Multiplies each element of the given vector with the given factor and writes the result into the vect...
Definition vector.h:447
bool hasNonZeroEntry(std::vector< T > const &v)
Definition vector.h:1133
std::vector< Type > filterVector(std::vector< Type > const &in, storm::storage::BitVector const &filter)
Definition vector.h:1060
bool isZero(ValueType const &a)
Definition constants.cpp:39
ValueType ceil(ValueType const &number)
ValueType zero()
Definition constants.cpp:24
ValueType one()
Definition constants.cpp:19
ValueType log(ValueType const &number)
bool isInfinity(ValueType const &a)
TargetType convertNumber(SourceType const &number)
solver::OptimizationDirection OptimizationDirection