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