Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BigStep.cpp
Go to the documentation of this file.
2
3#include <algorithm>
4#include <functional>
5#include <map>
6#include <memory>
7#include <numeric>
8#include <queue>
9#include <set>
10#include <stack>
11#include <string>
12#include <unordered_map>
13#include <utility>
14#include <vector>
15
24#include "storm/utility/graph.h"
27
28#define WRITE_DTMCS 0
29
30namespace storm {
31namespace transformer {
32
34
36 auto multivariatePol = carl::MultivariatePolynomial<RationalFunctionCoefficient>(uniPoly);
37 auto multiNominator = carl::FactorizedPolynomial(multivariatePol, rawPolynomialCache);
38 return RationalFunction(multiNominator);
39}
40
41bool UniPolyCompare::operator()(const UniPoly& lhs, const UniPoly& rhs) const {
42 if (lhs.degree() != rhs.degree()) {
43 return lhs.degree() < rhs.degree();
44 }
45
46 for (uint64_t i = 0; i < lhs.coefficients().size(); i++) {
47 if (lhs.coefficients()[i] != rhs.coefficients()[i]) {
48 return lhs.coefficients()[i] < rhs.coefficients()[i];
49 }
50 }
51
52 return false;
53}
54
56 auto& container = (*this)[p];
57
58 auto it = container.first.find(f);
59 if (it != container.first.end()) {
60 return it->second;
61 }
62
63 // std::cout << f << std::endl;
64 uint64_t newIndex = container.second.size();
65 container.first[f] = newIndex;
66 container.second.push_back(f);
67
68 return newIndex;
69}
70
71UniPoly PolynomialCache::polynomialFromFactorization(std::vector<uint64_t> const& factorization, RationalFunctionVariable const& p) const {
72 static std::map<std::pair<std::vector<uint64_t>, RationalFunctionVariable>, UniPoly> localCache;
73 auto key = std::make_pair(factorization, p);
74 if (localCache.count(key)) {
75 return localCache.at(key);
76 }
77 UniPoly polynomial = UniPoly(p);
78 polynomial = polynomial.one();
79 for (uint64_t i = 0; i < factorization.size(); i++) {
80 for (uint64_t j = 0; j < factorization[i]; j++) {
81 polynomial *= this->at(p).second[i];
82 }
83 }
84 localCache.emplace(key, polynomial);
85 return polynomial;
86}
87
88Annotation::Annotation(RationalFunctionVariable parameter, std::shared_ptr<PolynomialCache> polynomialCache)
89 : parameter(parameter), polynomialCache(polynomialCache) {
90 // Intentionally left empty
91}
92
94 STORM_LOG_ASSERT(other.parameter == this->parameter, "Can only add annotations with equal parameters.");
95 for (auto const& [factors, number] : other) {
96 if (this->count(factors)) {
97 this->at(factors) += number;
98 } else {
99 this->emplace(factors, number);
100 }
101 }
102}
103
104void Annotation::operator*=(RationalFunctionCoefficient n) {
105 for (auto& [factors, number] : *this) {
106 number *= n;
107 }
108}
109
110Annotation Annotation::operator*(RationalFunctionCoefficient n) const {
111 Annotation annotationCopy(*this);
112 annotationCopy *= n;
113 return annotationCopy;
114}
115
116void Annotation::addAnnotationTimesConstant(Annotation const& other, RationalFunctionCoefficient timesConstant) {
117 for (auto const& [info, constant] : other) {
118 if (!this->count(info)) {
119 this->emplace(info, utility::zero<RationalFunctionCoefficient>());
120 }
121 this->at(info) += constant * timesConstant;
122 }
123}
124
126 for (auto const& [info, constant] : other) {
127 // Copy array
128 auto newCounter = info;
129
130 // Write new polynomial into array
131 auto const cacheNum = this->polynomialCache->lookUpInCache(polynomial, parameter);
132 while (newCounter.size() <= cacheNum) {
133 newCounter.push_back(0);
134 }
135 newCounter[cacheNum]++;
136
137 if (!this->count(newCounter)) {
138 this->emplace(newCounter, constant);
139 } else {
140 this->at(newCounter) += constant;
141 }
142 }
143}
144
146 for (auto const& [info1, constant1] : anno1) {
147 for (auto const& [info2, constant2] : anno2) {
148 std::vector<uint64_t> newCounter(std::max(info1.size(), info2.size()), 0);
149
150 for (uint64_t i = 0; i < newCounter.size(); i++) {
151 if (i < info1.size()) {
152 newCounter[i] += info1[i];
153 }
154 if (i < info2.size()) {
155 newCounter[i] += info2[i];
156 }
157 }
158
159 if (!this->count(newCounter)) {
160 this->emplace(newCounter, constant1 * constant2);
161 } else {
162 this->at(newCounter) += constant1 * constant2;
163 }
164 }
165 }
166}
167
169 UniPoly prob = UniPoly(parameter); // Creates a zero polynomial
170 for (auto const& [info, constant] : *this) {
171 prob += polynomialCache->polynomialFromFactorization(info, parameter) * constant;
172 }
173 return prob;
174}
175
176std::vector<UniPoly> Annotation::getTerms() const {
177 std::vector<UniPoly> terms;
178 for (auto const& [info, constant] : *this) {
179 terms.push_back(polynomialCache->polynomialFromFactorization(info, parameter) * constant);
180 }
181 return terms;
182}
183
185 if (!derivativeOfThis) {
186 return evaluate<Interval>(input);
187 } else {
188 Interval boundDerivative = derivativeOfThis->evaluateOnIntervalMidpointTheorem(input, higherOrderBounds);
189 double maxSlope = utility::max(utility::abs(boundDerivative.lower()), utility::abs(boundDerivative.upper()));
190 double fMid = evaluate<double>(input.center());
191 double fMin = fMid - (input.diameter() / 2) * maxSlope;
192 double fMax = fMid + (input.diameter() / 2) * maxSlope;
193 if (higherOrderBounds) {
194 Interval boundsHere = evaluate<Interval>(input);
195 return Interval(utility::max(fMin, boundsHere.lower()), utility::min(fMax, boundsHere.upper()));
196 } else {
197 return Interval(fMin, fMax);
198 }
199 }
200}
201
203 return parameter;
204}
205
207 if (nth == 0 || derivativeOfThis) {
208 return;
209 }
210 derivativeOfThis = std::make_shared<Annotation>(this->parameter, this->polynomialCache);
211 for (auto const& [info, constant] : *this) {
212 // Product rule
213 for (uint64_t i = 0; i < info.size(); i++) {
214 if (info[i] == 0) {
215 continue;
216 }
217
218 RationalFunctionCoefficient newConstant = constant * utility::convertNumber<RationalFunctionCoefficient>(info[i]);
219
220 std::vector<uint64_t> insert(info);
221 insert[i]--;
222 // Delete trailing zeroes from insert
223 while (!insert.empty() && insert.back() == 0) {
224 insert.pop_back();
225 }
226
227 auto polynomial = polynomialCache->at(parameter).second.at(i);
228 auto derivative = polynomial.derivative();
229 if (derivative.isConstant()) {
230 newConstant *= derivative.constantPart();
231 } else {
232 uint64_t derivativeIndex = this->polynomialCache->lookUpInCache(derivative, parameter);
233 while (insert.size() < derivativeIndex) {
234 insert.push_back(0);
235 }
236 insert[derivativeIndex]++;
237 }
238 if (derivativeOfThis->count(insert)) {
239 derivativeOfThis->at(insert) += newConstant;
240 } else {
241 derivativeOfThis->emplace(insert, newConstant);
242 }
243 }
244 }
245 derivativeOfThis->computeDerivative(nth - 1);
246}
247
248uint64_t Annotation::maxDegree() const {
249 uint64_t maxDegree = 0;
250 for (auto const& [info, constant] : *this) {
251 if (!info.empty()) {
252 maxDegree = std::max(maxDegree, *std::max_element(info.begin(), info.end()));
253 }
254 }
255 return maxDegree;
256}
257
258std::shared_ptr<Annotation> Annotation::derivative() {
260 return derivativeOfThis;
261}
262
263// Annotation operator<< implementation
264std::ostream& operator<<(std::ostream& os, const Annotation& annotation) {
265 auto iterator = annotation.begin();
266 while (iterator != annotation.end()) {
267 auto const& factors = iterator->first;
268 auto const& constant = iterator->second;
269 os << constant << " * (";
270 bool alreadyPrintedFactor = false;
271 for (uint64_t i = 0; i < factors.size(); i++) {
272 if (factors[i] > 0) {
273 if (alreadyPrintedFactor) {
274 os << "*";
275 } else {
276 alreadyPrintedFactor = true;
277 }
278 os << "(" << annotation.polynomialCache->at(annotation.parameter).second[i] << ")" << "^" << factors[i];
279 }
280 }
281 if (factors.empty()) {
282 os << "1";
283 }
284 os << ")";
285 iterator++;
286 if (iterator != annotation.end()) {
287 os << " + ";
288 }
289 }
290 return os;
291}
292
293std::pair<std::map<uint64_t, std::set<uint64_t>>, std::set<uint64_t>> findSubgraph(
294 const storm::storage::FlexibleSparseMatrix<RationalFunction>& transitionMatrix, const uint64_t root,
295 const std::map<RationalFunctionVariable, std::map<uint64_t, std::set<uint64_t>>>& treeStates,
296 const boost::optional<std::vector<RationalFunction>>& stateRewardVector, const RationalFunctionVariable parameter) {
297 std::map<uint64_t, std::set<uint64_t>> subgraph;
298 std::set<uint64_t> bottomStates;
299
300 std::set<uint64_t> acyclicStates;
301
302 std::vector<uint64_t> dfsStack = {root};
303 while (!dfsStack.empty()) {
304 uint64_t state = dfsStack.back();
305 // Is it a new state that we see for the first time or one we've already visited?
306 if (!subgraph.count(state)) {
307 subgraph[state] = {};
308
309 std::vector<uint64_t> tmpStack;
310 bool isAcyclic = true;
311
312 // First we find out whether the state is acyclic
313 for (auto const& entry : transitionMatrix.getRow(state)) {
314 if (!storm::utility::isZero(entry.getValue())) {
315 if (subgraph.count(entry.getColumn()) && !acyclicStates.count(entry.getColumn()) && !bottomStates.count(entry.getColumn())) {
316 // The state has been visited before but is not known to be acyclic.
317 isAcyclic = false;
318 break;
319 }
320 }
321 }
322
323 if (!isAcyclic) {
324 bottomStates.emplace(state);
325 continue;
326 }
327
328 for (auto const& entry : transitionMatrix.getRow(state)) {
329 if (!storm::utility::isZero(entry.getValue())) {
330 STORM_LOG_ASSERT(entry.getValue().isConstant() ||
331 (entry.getValue().gatherVariables().size() == 1 && *entry.getValue().gatherVariables().begin() == parameter),
332 "Called findSubgraph with incorrect parameter.");
333 // Add this edge to the subgraph
334 subgraph.at(state).emplace(entry.getColumn());
335 // If we haven't explored the node we are going to, we will need to figure out if it is a leaf or not
336 if (!subgraph.count(entry.getColumn())) {
337 bool continueSearching = treeStates.at(parameter).count(entry.getColumn()) && !treeStates.at(parameter).at(entry.getColumn()).empty();
338
339 if (!entry.getValue().isConstant()) {
340 // We are only interested in transitions that are constant or have the parameter
341 // We can skip transitions that have other parameters
342 continueSearching &= entry.getValue().gatherVariables().size() == 1 && *entry.getValue().gatherVariables().begin() == parameter;
343 }
344
345 // Also continue searching if there is only a transition with a one coming up, we can skip that
346 // This is nice because we can possibly combine more transitions later
347 bool onlyHasOne = transitionMatrix.getRow(entry.getColumn()).size() == 1 &&
348 transitionMatrix.getRow(entry.getColumn()).begin()->getValue() == utility::one<RationalFunction>();
349 continueSearching |= onlyHasOne;
350
351 // Don't mess with rewards
352 continueSearching &= !(stateRewardVector && !stateRewardVector->at(entry.getColumn()).isZero());
353
354 if (continueSearching) {
355 // We are setting this state to explored once we pop it from the stack, not yet
356 // Just push it to the stack
357 tmpStack.push_back(entry.getColumn());
358 } else {
359 // This state is a leaf
360 subgraph[entry.getColumn()] = {};
361 bottomStates.emplace(entry.getColumn());
362
363 acyclicStates.emplace(entry.getColumn());
364 }
365 }
366 }
367 }
368
369 for (auto const& entry : tmpStack) {
370 dfsStack.push_back(entry);
371 }
372 } else {
373 // Go back over the states backwards - we know these are not acyclic
374 acyclicStates.emplace(state);
375 dfsStack.pop_back();
376 }
377 }
378 return std::make_pair(subgraph, bottomStates);
379}
380
381std::pair<models::sparse::Dtmc<RationalFunction>, std::map<UniPoly, Annotation>> BigStep::bigStep(
385
386 STORM_LOG_ASSERT(transitionMatrix.isProbabilistic(storm::utility::zero<RationalFunction>()), "Gave big-step a nonprobabilistic transition matrix.");
387
388 uint64_t initialState = dtmc.getInitialStates().getNextSetIndex(0);
389
390 uint64_t originalNumStates = dtmc.getNumberOfStates();
391
392 auto allParameters = storm::models::sparse::getAllParameters(dtmc);
393
394 std::set<std::string> labelsInFormula;
395 for (auto const& atomicLabelFormula : checkTask.getFormula().getAtomicLabelFormulas()) {
396 labelsInFormula.emplace(atomicLabelFormula->getLabel());
397 }
398
399 models::sparse::StateLabeling runningLabeling(dtmc.getStateLabeling());
400 models::sparse::StateLabeling runningLabelingTreeStates(dtmc.getStateLabeling());
401 for (auto const& label : labelsInFormula) {
402 runningLabelingTreeStates.removeLabel(label);
403 }
404
405 // Check the reward model - do not touch states with rewards
406 boost::optional<std::vector<RationalFunction>> stateRewardVector;
407 boost::optional<std::string> stateRewardName;
408 if (checkTask.getFormula().isRewardOperatorFormula()) {
409 if (checkTask.isRewardModelSet()) {
411 stateRewardVector = dtmc.getRewardModel(checkTask.getRewardModel()).getStateRewardVector();
412 stateRewardName = checkTask.getRewardModel();
413 } else {
415 stateRewardVector = dtmc.getRewardModel("").getStateRewardVector();
416 stateRewardName = dtmc.getUniqueRewardModelName();
417 }
418 }
419
420 auto topologicalOrdering = utility::graph::getTopologicalSort<RationalFunction>(transitionMatrix, {initialState});
421
422 auto flexibleMatrix = storage::FlexibleSparseMatrix<RationalFunction>(transitionMatrix);
423 auto backwardsTransitions = storage::FlexibleSparseMatrix<RationalFunction>(transitionMatrix.transpose());
424
425 // Initialize counting
426 // Tree states: parameter p -> state s -> set of reachable states from s by constant transition that have a p-transition
427 std::map<RationalFunctionVariable, std::map<uint64_t, std::set<uint64_t>>> treeStates;
428 // Tree states need updating for these sets and variables
429 std::map<RationalFunctionVariable, std::set<uint64_t>> treeStatesNeedUpdate;
430
431 // Initialize treeStates and treeStatesNeedUpdate
432 for (uint64_t row = 0; row < flexibleMatrix.getRowCount(); row++) {
433 for (auto const& entry : flexibleMatrix.getRow(row)) {
434 if (!entry.getValue().isConstant()) {
435 if (!this->rawPolynomialCache) {
436 // So we can create new FactorizedPolynomials later
437 this->rawPolynomialCache = entry.getValue().nominator().pCache();
438 }
439 for (auto const& parameter : entry.getValue().gatherVariables()) {
440 treeStatesNeedUpdate[parameter].emplace(row);
441 treeStates[parameter][row].emplace(row);
442 }
443 }
444 }
445 }
446 updateTreeStates(treeStates, treeStatesNeedUpdate, flexibleMatrix, backwardsTransitions, allParameters, stateRewardVector, runningLabelingTreeStates);
447
448 // To prevent infinite unrolling of parametric loops:
449 // We have already reordered with these as leaves, don't reorder with these as leaves again
450 std::map<RationalFunctionVariable, std::set<std::set<uint64_t>>> alreadyTimeTravelledToThis;
451
452 // We will traverse the model according to the topological ordering
453 std::stack<uint64_t> topologicalOrderingStack;
454 topologicalOrdering = utility::graph::getTopologicalSort<RationalFunction>(transitionMatrix, {initialState});
455 for (auto rit = topologicalOrdering.begin(); rit != topologicalOrdering.end(); ++rit) {
456 topologicalOrderingStack.push(*rit);
457 }
458
459 // Identify reachable states - not reachable states do not have do be big-stepped
460 const storage::BitVector trueVector(transitionMatrix.getRowCount(), true);
461 const storage::BitVector falseVector(transitionMatrix.getRowCount(), false);
462 storage::BitVector initialStates(transitionMatrix.getRowCount(), false);
463 initialStates.set(initialState, true);
464
465 // We will compute the reachable states once in the beginning but update them dynamically
466 storage::BitVector reachableStates = storm::utility::graph::getReachableStates(transitionMatrix, initialStates, trueVector, falseVector);
467
468 // We will return these stored annotations to help find the zeroes
469 std::map<UniPoly, Annotation> storedAnnotations;
470
471 std::map<RationalFunctionVariable, std::set<uint64_t>> bottomStatesSeen;
472
473#if WRITE_DTMCS
474 uint64_t writeDtmcCounter = 0;
475#endif
476
477 while (!topologicalOrderingStack.empty()) {
478 auto state = topologicalOrderingStack.top();
479 topologicalOrderingStack.pop();
480
481 if (!reachableStates.get(state)) {
482 continue;
483 }
484
485 std::set<RationalFunctionVariable> parametersInState;
486 for (auto const& entry : flexibleMatrix.getRow(state)) {
487 for (auto const& parameter : entry.getValue().gatherVariables()) {
488 parametersInState.emplace(parameter);
489 }
490 }
491
492 std::set<RationalFunctionVariable> bigStepParameters;
493 for (auto const& parameter : allParameters) {
494 if (treeStates[parameter].count(state)) {
495 // Parallel parameters
496 if (treeStates.at(parameter).at(state).size() > 1) {
497 bigStepParameters.emplace(parameter);
498 continue;
499 }
500 // Sequential parameters
501 if (parametersInState.count(parameter)) {
502 for (auto const& treeState : treeStates[parameter][state]) {
503 for (auto const& successor : flexibleMatrix.getRow(treeState)) {
504 if (treeStates[parameter].count(successor.getColumn())) {
505 bigStepParameters.emplace(parameter);
506 break;
507 }
508 }
509 }
510 }
511 }
512 }
513
514 // Do big-step lifting from here
515 // Follow the treeStates and eliminate transitions
516 for (auto const& parameter : bigStepParameters) {
517 // Find the paths along which we eliminate the transitions into one transition along with their probabilities.
518 auto const [bottomAnnotations, visitedStatesAndSubtree] =
519 bigStepBFS(state, parameter, flexibleMatrix, backwardsTransitions, treeStates, stateRewardVector, storedAnnotations);
520 auto const [visitedStates, subtree] = visitedStatesAndSubtree;
521
522 // Check the following:
523 // There exists a state s in visitedStates s.t. all predecessors of s are in the subtree
524 // If not, we are not eliminating any states with this big-step which baaaad and leads to the world-famous "grid issue"
525 bool existsEliminableState = false;
526 for (auto const& s : visitedStates) {
527 bool allPredecessorsInVisitedStates = true;
528 for (auto const& predecessor : backwardsTransitions.getRow(s)) {
529 if (predecessor.getValue().isZero()) {
530 continue;
531 }
532 if (!reachableStates.get(predecessor.getColumn())) {
533 continue;
534 }
535 // is the predecessor not in the subtree? then this state won't get eliminated
536 // is the predcessor in the subtree but the edge isn't? then this state won't get eliminated
537 if (!subtree.count(predecessor.getColumn()) || !subtree.at(predecessor.getColumn()).count(s)) {
538 allPredecessorsInVisitedStates = false;
539 break;
540 }
541 }
542 if (allPredecessorsInVisitedStates) {
543 existsEliminableState = true;
544 break;
545 }
546 }
547 // If we will not eliminate any states, do not perfom big-step
548 if (!existsEliminableState) {
549 continue;
550 }
551
552 // for (auto const& [state, annotation] : bottomAnnotations) {
553 // std::cout << state << ": " << annotation << std::endl;
554 // }
555
556 uint64_t oldMatrixSize = flexibleMatrix.getRowCount();
557
558 std::vector<std::pair<uint64_t, Annotation>> transitions = findBigStep(bottomAnnotations, parameter, flexibleMatrix, backwardsTransitions,
559 alreadyTimeTravelledToThis, treeStatesNeedUpdate, state, originalNumStates);
560
561 // Put paths into matrix
562 auto newStoredAnnotations =
563 replaceWithNewTransitions(state, transitions, flexibleMatrix, backwardsTransitions, reachableStates, treeStatesNeedUpdate);
564 for (auto const& entry : newStoredAnnotations) {
565 storedAnnotations.emplace(entry);
566 }
567
568 // Dynamically update unreachable states
569 updateUnreachableStates(reachableStates, visitedStates, backwardsTransitions, initialState);
570
571 uint64_t newMatrixSize = flexibleMatrix.getRowCount();
572 if (newMatrixSize > oldMatrixSize) {
573 // Extend labeling to more states
574 runningLabeling = extendStateLabeling(runningLabeling, oldMatrixSize, newMatrixSize, state, labelsInFormula);
575 runningLabelingTreeStates = extendStateLabeling(runningLabelingTreeStates, oldMatrixSize, newMatrixSize, state, labelsInFormula);
576
577 // Extend reachableStates
578 reachableStates.resize(newMatrixSize, true);
579
580 for (uint64_t i = oldMatrixSize; i < newMatrixSize; i++) {
581 topologicalOrderingStack.push(i);
582 for (auto& [_parameter, updateStates] : treeStatesNeedUpdate) {
583 updateStates.emplace(i);
584 }
585 // New states have zero reward
586 if (stateRewardVector) {
587 stateRewardVector->push_back(storm::utility::zero<RationalFunction>());
588 }
589 }
590 updateTreeStates(treeStates, treeStatesNeedUpdate, flexibleMatrix, backwardsTransitions, allParameters, stateRewardVector,
591 runningLabelingTreeStates);
592 }
593 // We continue the loop through the bigStepParameters if we don't do big-step.
594 // If we reach here, then we did indeed to big-step, so we will break.
595 break;
596 }
597
598#if WRITE_DTMCS
599 models::sparse::Dtmc<RationalFunction> newnewnewDTMC(flexibleMatrix.createSparseMatrix(), runningLabeling);
600 if (stateRewardVector) {
601 models::sparse::StandardRewardModel<RationalFunction> newRewardModel(*stateRewardVector);
602 newnewnewDTMC.addRewardModel(*stateRewardName, newRewardModel);
603 }
604 std::ofstream file2;
605 storm::io::openFile("dots/travel_" + std::to_string(flexibleMatrix.getRowCount()) + ".dot", file2);
606 newnewnewDTMC.writeDotToStream(file2);
608#endif
609 }
610
611 transitionMatrix = flexibleMatrix.createSparseMatrix();
612
613 // Delete states
614 {
615 storage::BitVector trueVector(transitionMatrix.getRowCount(), true);
616 storage::BitVector falseVector(transitionMatrix.getRowCount(), false);
617 storage::BitVector initialStates(transitionMatrix.getRowCount(), false);
618 initialStates.set(initialState, true);
619 storage::BitVector reachableStates = storm::utility::graph::getReachableStates(transitionMatrix, initialStates, trueVector, falseVector);
620
621 transitionMatrix = transitionMatrix.getSubmatrix(false, reachableStates, reachableStates);
622 runningLabeling = runningLabeling.getSubLabeling(reachableStates);
623 uint_fast64_t newInitialState = 0;
624 for (uint_fast64_t i = 0; i < initialState; i++) {
625 if (reachableStates.get(i)) {
626 newInitialState++;
627 }
628 }
629 initialState = newInitialState;
630 if (stateRewardVector) {
631 std::vector<RationalFunction> newStateRewardVector;
632 for (uint_fast64_t i = 0; i < stateRewardVector->size(); i++) {
633 if (reachableStates.get(i)) {
634 newStateRewardVector.push_back(stateRewardVector->at(i));
635 } else {
636 STORM_LOG_ERROR_COND(stateRewardVector->at(i).isZero(), "Deleted non-zero reward.");
637 }
638 }
639 stateRewardVector = newStateRewardVector;
640 }
641 }
642
643 models::sparse::Dtmc<RationalFunction> newDTMC(transitionMatrix, runningLabeling);
644
645 storage::BitVector newInitialStates(transitionMatrix.getRowCount());
646 newInitialStates.set(initialState, true);
647 newDTMC.setInitialStates(newInitialStates);
648
649 if (stateRewardVector) {
650 models::sparse::StandardRewardModel<RationalFunction> newRewardModel(*stateRewardVector);
651 newDTMC.addRewardModel(*stateRewardName, newRewardModel);
652 }
653
654 STORM_LOG_ASSERT(newDTMC.getTransitionMatrix().isProbabilistic(storm::utility::zero<RationalFunction>()),
655 "Internal error: resulting matrix not probabilistic!");
656
657 lastSavedAnnotations.clear();
658 for (auto const& entry : storedAnnotations) {
659 lastSavedAnnotations.emplace(std::make_pair(uniPolyToRationalFunction(entry.first), entry.second));
660 }
661
662 return std::make_pair(newDTMC, storedAnnotations);
663}
664
665std::pair<std::map<uint64_t, Annotation>, std::pair<std::vector<uint64_t>, std::map<uint64_t, std::set<uint64_t>>>> BigStep::bigStepBFS(
666 uint64_t start, const RationalFunctionVariable& parameter, const storage::FlexibleSparseMatrix<RationalFunction>& flexibleMatrix,
667 const storage::FlexibleSparseMatrix<RationalFunction>& backwardsFlexibleMatrix,
668 const std::map<RationalFunctionVariable, std::map<uint64_t, std::set<uint64_t>>>& treeStates,
669 const boost::optional<std::vector<RationalFunction>>& stateRewardVector, const std::map<UniPoly, Annotation>& storedAnnotations) {
670 // Find the subgraph we will work on using DFS, following the treeStates, stopping before cycles
671 auto const [subtree, bottomStates] = findSubgraph(flexibleMatrix, start, treeStates, stateRewardVector, parameter);
672
673 // We need this to later determine which states are now unreachable
674 std::vector<uint64_t> visitedStatesInBFSOrder;
675
676 std::set<std::pair<uint64_t, uint64_t>> visitedEdges;
677
678 // We iterate over these annotations
679 std::map<uint64_t, Annotation> annotations;
680
681 // Set of active states in BFS
682 std::queue<uint64_t> activeStates;
683 activeStates.push(start);
684
685 annotations.emplace(start, Annotation(parameter, polynomialCache));
686 // We go with probability one from the start to the start
687 annotations.at(start)[std::vector<uint64_t>()] = utility::one<RationalFunctionCoefficient>();
688
689 while (!activeStates.empty()) {
690 auto state = activeStates.front();
691 activeStates.pop();
692 visitedStatesInBFSOrder.push_back(state);
693 for (auto const& entry : flexibleMatrix.getRow(state)) {
694 auto const goToState = entry.getColumn();
695 if (!subtree.count(goToState) || !subtree.at(state).count(goToState)) {
696 continue;
697 }
698 visitedEdges.emplace(std::make_pair(state, goToState));
699 // Check if all of the backwards states have been visited
700 bool allBackwardsStatesVisited = true;
701 for (auto const& backwardsEntry : backwardsFlexibleMatrix.getRow(goToState)) {
702 if (!subtree.count(backwardsEntry.getColumn()) || !subtree.at(backwardsEntry.getColumn()).count(goToState)) {
703 // We don't consider this edge for one of two reasons:
704 // (1) The node is not in the subtree.
705 // (2) The edge is not in the subtree. This can happen if to states are in the subtree for unrelated reasons
706 continue;
707 }
708 if (!visitedEdges.count(std::make_pair(backwardsEntry.getColumn(), goToState))) {
709 allBackwardsStatesVisited = false;
710 break;
711 }
712 }
713 if (!allBackwardsStatesVisited) {
714 continue;
715 }
716
717 // Update the annotation of the target state
718 annotations.emplace(goToState, Annotation(parameter, polynomialCache));
719
720 // Value-iteration style
721 for (auto const& backwardsEntry : backwardsFlexibleMatrix.getRow(goToState)) {
722 if (!subtree.count(backwardsEntry.getColumn()) || !subtree.at(backwardsEntry.getColumn()).count(goToState)) {
723 // We don't consider this edge for one of two reasons:
724 // (1) The node is not in the subtree.
725 // (2) The edge is not in the subtree. This can happen if to states are in the subtree for unrelated reasons
726 continue;
727 }
728 auto const transition = backwardsEntry.getValue();
729
730 // std::cout << backwardsEntry.getColumn() << "--" << backwardsEntry.getValue() << "->" << goToState << ": ";
731
732 // We add stuff to this annotation
733 auto& targetAnnotation = annotations.at(goToState);
734
735 // std::cout << targetAnnotation << " + ";
736 // std::cout << "(" << transition << " * (" << annotations.at(backwardsEntry.getColumn()) << "))";
737
738 // The core of this big-step algorithm: "value-iterating" on our annotation.
739 if (transition.isConstant()) {
740 // std::cout << "(constant)";
741 targetAnnotation.addAnnotationTimesConstant(annotations.at(backwardsEntry.getColumn()), transition.constantPart());
742 } else {
743 // std::cout << "(pol)";
744 // Read transition from DTMC, convert to univariate polynomial
745 STORM_LOG_ERROR_COND(transition.denominator().isConstant(), "Only transitions with constant denominator supported but this has "
746 << transition.denominator() << " in transition " << transition);
747 auto nominator = transition.nominator();
748 UniPoly nominatorAsUnivariate = transition.nominator().toUnivariatePolynomial();
749 // Constant denominator is now distributed in the factors, not in the denominator of the rational function
750 nominatorAsUnivariate /= transition.denominator().coefficient();
751 if (storedAnnotations.count(nominatorAsUnivariate)) {
752 targetAnnotation.addAnnotationTimesAnnotation(annotations.at(backwardsEntry.getColumn()), storedAnnotations.at(nominatorAsUnivariate));
753 } else {
754 targetAnnotation.addAnnotationTimesPolynomial(annotations.at(backwardsEntry.getColumn()), std::move(nominatorAsUnivariate));
755 }
756 }
757
758 // Check if we have visited all forward edges of this annotation, if so, erase it
759 bool allForwardEdgesVisited = true;
760 for (auto const& entry : flexibleMatrix.getRow(backwardsEntry.getColumn())) {
761 if (!subtree.at(backwardsEntry.getColumn()).count(entry.getColumn())) {
762 // We don't consider this edge for one of two reasons:
763 // (1) The node is not in the subtree.
764 // (2) The edge is not in the subtree. This can happen if to states are in the subtree for unrelated reasons
765 continue;
766 }
767 if (!annotations.count(entry.getColumn())) {
768 allForwardEdgesVisited = false;
769 break;
770 }
771 }
772 if (allForwardEdgesVisited) {
773 annotations.erase(backwardsEntry.getColumn());
774 }
775 }
776 activeStates.push(goToState);
777 }
778 }
779 // Delete annotations that are not bottom states
780 for (auto const& [state, _successors] : subtree) {
781 // std::cout << "Subtree of " << state << ": ";
782 // for (auto const& entry : _successors) {
783 // std::cout << entry << " ";
784 // }
785 if (!bottomStates.count(state)) {
786 annotations.erase(state);
787 }
788 }
789 return std::make_pair(annotations, std::make_pair(visitedStatesInBFSOrder, subtree));
790}
791
792std::vector<std::pair<uint64_t, Annotation>> BigStep::findBigStep(const std::map<uint64_t, Annotation> bigStepAnnotations,
793 const RationalFunctionVariable& parameter,
794 storage::FlexibleSparseMatrix<RationalFunction>& flexibleMatrix,
795 storage::FlexibleSparseMatrix<RationalFunction>& backwardsFlexibleMatrix,
796 std::map<RationalFunctionVariable, std::set<std::set<uint64_t>>>& alreadyTimeTravelledToThis,
797 std::map<RationalFunctionVariable, std::set<uint64_t>>& treeStatesNeedUpdate, uint64_t root,
798 uint64_t originalNumStates) {
799 STORM_LOG_INFO("Find time travelling called with root " << root << " and parameter " << parameter);
800
801 // Time Travelling: For transitions that divide into constants, join them into one transition leading into new state
802 std::map<std::vector<uint64_t>, std::map<uint64_t, RationalFunctionCoefficient>> parametricTransitions;
803
804 for (auto const& [state, annotation] : bigStepAnnotations) {
805 for (auto const& [info, constant] : annotation) {
806 if (!parametricTransitions.count(info)) {
807 parametricTransitions[info] = std::map<uint64_t, RationalFunctionCoefficient>();
808 }
809 STORM_LOG_ASSERT(!parametricTransitions.at(info).count(state), "State already exists");
810 parametricTransitions.at(info)[state] = constant;
811 }
812 }
813
814 // These are the transitions that we are actually going to insert (that the function will return).
815 std::vector<std::pair<uint64_t, Annotation>> insertTransitions;
816
817 // State affected by big-step
818 std::unordered_set<uint64_t> affectedStates;
819
820 // for (auto const& [factors, transitions] : parametricTransitions) {
821 // std::cout << "Factors: ";
822 // for (uint64_t i = 0; i < factors.size(); i++) {
823 // std::cout << polynomialCache->at(parameter).second[i] << ": " << factors[i] << " ";
824 // }
825 // std::cout << std::endl;
826 // for (auto const& [state, info] : transitions) {
827 // std::cout << "State " << state << " with " << info << std::endl;
828 // }
829 // }
830
831 std::set<std::set<uint64_t>> targetSetStates;
832
833 for (auto const& [factors, transitions] : parametricTransitions) {
834 if (transitions.size() > 1) {
835 // STORM_LOG_ERROR_COND(!factors.empty(), "Empty factors!");
836 STORM_LOG_INFO("Time-travelling from root " << root);
837 // The set of target states of the paths that we maybe want to time-travel
838 std::set<uint64_t> targetStates;
839
840 // All of these states are affected by time-travelling
841 for (auto const& [state, info] : transitions) {
842 affectedStates.emplace(state);
843 if (state < originalNumStates) {
844 targetStates.emplace(state);
845 }
846 }
847
848 if (alreadyTimeTravelledToThis[parameter].count(targetStates)) {
849 for (auto const& [state, probability] : transitions) {
850 Annotation newAnnotation(parameter, polynomialCache);
851 newAnnotation[factors] = probability;
852
853 insertTransitions.emplace_back(state, newAnnotation);
854 }
855 continue;
856 }
857 targetSetStates.emplace(targetStates);
858
859 Annotation newAnnotation(parameter, polynomialCache);
860
861 RationalFunctionCoefficient constantPart = utility::zero<RationalFunctionCoefficient>();
862 for (auto const& [state, transition] : transitions) {
863 constantPart += transition;
864 }
865 newAnnotation[factors] = constantPart;
866
867 STORM_LOG_INFO("Time travellable transitions with " << newAnnotation);
868
869 // Create the new state that our parametric transitions will start in
870 uint64_t newRow = flexibleMatrix.insertNewRowsAtEnd(1);
871 uint64_t newRowBackwards = backwardsFlexibleMatrix.insertNewRowsAtEnd(1);
872 STORM_LOG_ASSERT(newRow == newRowBackwards, "Internal error: Drifting matrix and backwardsTransitions.");
873
874 // Sum of parametric transitions goes to new row
875 insertTransitions.emplace_back(newRow, newAnnotation);
876
877 // Write outgoing transitions from new row directly into the flexible matrix
878 for (auto const& [state, thisProb] : transitions) {
879 const RationalFunction probAsFunction = RationalFunction(thisProb) / constantPart;
880 // Forward
881 flexibleMatrix.getRow(newRow).push_back(storage::MatrixEntry<uint_fast64_t, RationalFunction>(state, probAsFunction));
882 // Backward
883 backwardsFlexibleMatrix.getRow(state).push_back(storage::MatrixEntry<uint_fast64_t, RationalFunction>(newRow, probAsFunction));
884 // Update tree-states here
885 for (auto& entry : treeStatesNeedUpdate) {
886 entry.second.emplace(state);
887 }
888 STORM_LOG_INFO("With: " << probAsFunction << " to " << state);
889 // Join duplicate transitions backwards (need to do this for all rows we come from)
890 backwardsFlexibleMatrix.getRow(state) = joinDuplicateTransitions(backwardsFlexibleMatrix.getRow(state));
891 }
892 // Join duplicate transitions forwards (only need to do this for row we go to)
893 flexibleMatrix.getRow(newRow) = joinDuplicateTransitions(flexibleMatrix.getRow(newRow));
894 } else {
895 auto const [state, probability] = *transitions.begin();
896
897 Annotation newAnnotation(parameter, polynomialCache);
898 newAnnotation[factors] = probability;
899
900 insertTransitions.emplace_back(state, newAnnotation);
901 }
902 }
903
904 // Add everything to alreadyTimeTravelledToThis
905 for (auto const& targetSet : targetSetStates) {
906 alreadyTimeTravelledToThis[parameter].emplace(targetSet);
907 }
908
909 return insertTransitions;
910}
911
912std::map<UniPoly, Annotation> BigStep::replaceWithNewTransitions(uint64_t state, const std::vector<std::pair<uint64_t, Annotation>> transitions,
913 storage::FlexibleSparseMatrix<RationalFunction>& flexibleMatrix,
914 storage::FlexibleSparseMatrix<RationalFunction>& backwardsFlexibleMatrix,
915 storage::BitVector& reachableStates,
916 std::map<RationalFunctionVariable, std::set<uint64_t>>& treeStatesNeedUpdate) {
917 std::map<UniPoly, Annotation> storedAnnotations;
918
919 // STORM_LOG_ASSERT(flexibleMatrix.createSparseMatrix().transpose() == backwardsFlexibleMatrix.createSparseMatrix(), "");
920 // Delete old transitions - backwards
921 for (auto const& deletingTransition : flexibleMatrix.getRow(state)) {
922 auto& row = backwardsFlexibleMatrix.getRow(deletingTransition.getColumn());
923 auto it = row.begin();
924 while (it != row.end()) {
925 if (it->getColumn() == state) {
926 it = row.erase(it);
927 } else {
928 it++;
929 }
930 }
931 }
932 // Delete old transitions - forwards
933 flexibleMatrix.getRow(state) = std::vector<storage::MatrixEntry<uint_fast64_t, RationalFunction>>();
934 // STORM_LOG_ASSERT(flexibleMatrix.createSparseMatrix().transpose() == backwardsFlexibleMatrix.createSparseMatrix().transpose().transpose(), "");
935
936 // Insert new transitions
937 std::map<uint64_t, Annotation> insertThese;
938 for (auto const& [target, probability] : transitions) {
939 for (auto& entry : treeStatesNeedUpdate) {
940 entry.second.emplace(target);
941 }
942 if (insertThese.count(target)) {
943 insertThese.at(target) += probability;
944 } else {
945 insertThese.emplace(target, probability);
946 }
947 }
948 for (auto const& [state2, annotation] : insertThese) {
949 auto uniProbability = annotation.getProbability();
950 storedAnnotations.emplace(uniProbability, std::move(annotation));
951 auto probability = uniPolyToRationalFunction(uniProbability);
952
953 // We know that neither no transition state <-> entry.first exist because we've erased them
954 flexibleMatrix.getRow(state).push_back(storm::storage::MatrixEntry(state2, probability));
955 backwardsFlexibleMatrix.getRow(state2).push_back(storm::storage::MatrixEntry(state, probability));
956 }
957 // STORM_LOG_ASSERT(flexibleMatrix.createSparseMatrix().transpose() == backwardsFlexibleMatrix.createSparseMatrix(), "");
958 return storedAnnotations;
959}
960
961void BigStep::updateUnreachableStates(storage::BitVector& reachableStates, std::vector<uint64_t> const& statesMaybeUnreachable,
962 storage::FlexibleSparseMatrix<RationalFunction> const& backwardsFlexibleMatrix, uint64_t initialState) {
963 if (backwardsFlexibleMatrix.getRowCount() > reachableStates.size()) {
964 reachableStates.resize(backwardsFlexibleMatrix.getRowCount(), true);
965 }
966 // Look if one of our visitedStates has become unreachable
967 // i.e. all of its predecessors are unreachable
968 for (auto const& visitedState : statesMaybeUnreachable) {
969 if (visitedState == initialState) {
970 continue;
971 }
972 bool isUnreachable = true;
973 for (auto const& entry : backwardsFlexibleMatrix.getRow(visitedState)) {
974 if (reachableStates.get(entry.getColumn())) {
975 isUnreachable = false;
976 break;
977 }
978 }
979 if (isUnreachable) {
980 reachableStates.set(visitedState, false);
981 }
982 }
983}
984
985std::vector<storm::storage::MatrixEntry<uint64_t, RationalFunction>> BigStep::joinDuplicateTransitions(
987 std::vector<uint64_t> keyOrder;
988 std::map<uint64_t, storm::storage::MatrixEntry<uint64_t, RationalFunction>> existingEntries;
989 for (auto const& entry : entries) {
990 if (existingEntries.count(entry.getColumn())) {
991 existingEntries.at(entry.getColumn()).setValue(existingEntries.at(entry.getColumn()).getValue() + entry.getValue());
992 } else {
993 existingEntries[entry.getColumn()] = entry;
994 keyOrder.push_back(entry.getColumn());
995 }
996 }
997 std::vector<storm::storage::MatrixEntry<uint64_t, RationalFunction>> newEntries;
998 for (uint64_t key : keyOrder) {
999 newEntries.push_back(existingEntries.at(key));
1000 }
1001 return newEntries;
1002}
1003
1004models::sparse::StateLabeling BigStep::extendStateLabeling(models::sparse::StateLabeling const& oldLabeling, uint64_t oldSize, uint64_t newSize,
1005 uint64_t stateWithLabels, const std::set<std::string>& labelsInFormula) {
1006 models::sparse::StateLabeling newLabels(newSize);
1007 for (auto const& label : oldLabeling.getLabels()) {
1008 newLabels.addLabel(label);
1009 }
1010 for (uint64_t state = 0; state < oldSize; state++) {
1011 for (auto const& label : oldLabeling.getLabelsOfState(state)) {
1012 newLabels.addLabelToState(label, state);
1013 }
1014 }
1015 for (uint64_t i = oldSize; i < newSize; i++) {
1016 // We assume that everything that we time-travel has the same labels for now.
1017 for (auto const& label : oldLabeling.getLabelsOfState(stateWithLabels)) {
1018 if (labelsInFormula.count(label)) {
1019 newLabels.addLabelToState(label, i);
1020 }
1021 }
1022 }
1023 return newLabels;
1024}
1025
1026void BigStep::updateTreeStates(std::map<RationalFunctionVariable, std::map<uint64_t, std::set<uint64_t>>>& treeStates,
1027 std::map<RationalFunctionVariable, std::set<uint64_t>>& workingSets,
1028 const storage::FlexibleSparseMatrix<RationalFunction>& flexibleMatrix,
1029 const storage::FlexibleSparseMatrix<RationalFunction>& backwardsTransitions,
1030 const std::set<RationalFunctionVariable>& allParameters, const boost::optional<std::vector<RationalFunction>>& stateRewardVector,
1031 const models::sparse::StateLabeling stateLabeling) {
1032 for (auto const& parameter : allParameters) {
1033 std::set<uint64_t>& workingSet = workingSets[parameter];
1034 while (!workingSet.empty()) {
1035 std::set<uint64_t> newWorkingSet;
1036 for (uint64_t row : workingSet) {
1037 if (stateRewardVector && !stateRewardVector->at(row).isZero()) {
1038 continue;
1039 }
1040 for (auto const& entry : backwardsTransitions.getRow(row)) {
1041 if (entry.getValue().isConstant()) {
1042 // If the set of tree states at the current position is a subset of the set of
1043 // tree states of the parent state, we've reached some loop. Then we can stop.
1044 bool isSubset = true;
1045 for (auto const& state : treeStates.at(parameter)[row]) {
1046 if (!treeStates.at(parameter)[entry.getColumn()].count(state)) {
1047 isSubset = false;
1048 break;
1049 }
1050 }
1051 if (isSubset) {
1052 continue;
1053 }
1054 for (auto const& state : treeStates.at(parameter).at(row)) {
1055 treeStates.at(parameter).at(entry.getColumn()).emplace(state);
1056 }
1057 if (stateLabeling.getLabelsOfState(entry.getColumn()) == stateLabeling.getLabelsOfState(row)) {
1058 newWorkingSet.emplace(entry.getColumn());
1059 }
1060 }
1061 }
1062 }
1063 workingSet = newWorkingSet;
1064 }
1065 }
1066}
1067
1068} // namespace transformer
1069} // namespace storm
bool isRewardModelSet() const
Retrieves whether a reward model was set.
Definition CheckTask.h:190
std::string const & getRewardModel() const
Retrieves the reward model over which to perform the checking (if set).
Definition CheckTask.h:197
FormulaType const & getFormula() const
Retrieves the formula from this task.
Definition CheckTask.h:140
virtual void writeDotToStream(std::ostream &outStream, size_t maxWidthLabel=30, bool includeLabeling=true, storm::storage::BitVector const *subsystem=nullptr, std::vector< ValueType > const *firstValue=nullptr, std::vector< ValueType > const *secondValue=nullptr, std::vector< uint_fast64_t > const *stateColoring=nullptr, std::vector< std::string > const *colors=nullptr, std::vector< uint_fast64_t > *scheduler=nullptr, bool finalizeOutput=true) const override
This class represents a discrete-time Markov chain.
Definition Dtmc.h:13
virtual void reduceToStateBasedRewards() override
Converts the transition rewards of all reward models to state-based rewards.
Definition Dtmc.cpp:41
void removeLabel(std::string const &label)
Removes a label from the labelings.
storm::storage::SparseMatrix< ValueType > const & getTransitionMatrix() const
Retrieves the matrix representing the transitions of the model.
Definition Model.cpp:199
void setInitialStates(storm::storage::BitVector const &states)
Overwrites the initial states of the model.
Definition Model.cpp:184
void addRewardModel(std::string const &rewardModelName, RewardModelType const &rewModel)
Adds a reward model to the model.
Definition Model.cpp:256
storm::models::sparse::StateLabeling const & getStateLabeling() const
Returns the state labeling associated with this model.
Definition Model.cpp:321
virtual uint_fast64_t getNumberOfStates() const override
Returns the number of states of the model.
Definition Model.cpp:164
RewardModelType const & getRewardModel(std::string const &rewardModelName) const
Retrieves the reward model with the given name, if one exists.
Definition Model.cpp:220
virtual std::string const & getUniqueRewardModelName() const override
Retrieves the name of the unique reward model, if there exists exactly one.
Definition Model.cpp:294
storm::storage::BitVector const & getInitialStates() const
Retrieves the initial states of the model.
Definition Model.cpp:179
This class manages the labeling of the state space with a number of (atomic) labels.
StateLabeling getSubLabeling(storm::storage::BitVector const &states) const
Retrieves the sub labeling that represents the same labeling as the current one for all selected stat...
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
uint64_t getNextSetIndex(uint64_t startingIndex) const
Retrieves the index of the bit that is the next bit set to true in the bit vector.
void set(uint64_t index, bool value=true)
Sets the given truth value at the given index.
void resize(uint64_t newLength, bool init=false)
Resizes the bit vector to hold the given new number of bits.
bool get(uint64_t index) const
Retrieves the truth value of the bit at the given index and performs a bound check.
The flexible sparse matrix is used during state elimination.
row_type & getRow(index_type)
Returns an object representing the given row.
A class that holds a possibly non-square matrix in the compressed row storage format.
bool isProbabilistic(ValueType const &tolerance) const
Checks for each row whether it sums to one.
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 ...
storm::storage::SparseMatrix< value_type > transpose(bool joinGroups=false, bool keepZeros=false) const
Transposes the matrix.
index_type getRowCount() const
Returns the number of rows of the matrix.
UniPoly getProbability() const
Get the probability of this annotation as a univariate polynomial (which isn't factorized).
Definition BigStep.cpp:168
void addAnnotationTimesPolynomial(Annotation const &other, UniPoly &&polynomial)
Adds another annotation times a polynomial to this annotation.
Definition BigStep.cpp:125
void addAnnotationTimesConstant(Annotation const &other, RationalFunctionCoefficient timesConstant)
Adds another annotation times a constant to this annotation.
Definition BigStep.cpp:116
std::vector< UniPoly > getTerms() const
Get all of the terms of the UniPoly.
Definition BigStep.cpp:176
void computeDerivative(uint64_t nth)
Definition BigStep.cpp:206
Annotation(RationalFunctionVariable parameter, std::shared_ptr< PolynomialCache > polynomialCache)
Definition BigStep.cpp:88
void operator*=(RationalFunctionCoefficient n)
Multiply this annotation with a rational number.
Definition BigStep.cpp:104
std::shared_ptr< Annotation > derivative()
Definition BigStep.cpp:258
Interval evaluateOnIntervalMidpointTheorem(Interval input, bool higherOrderBounds=false) const
Definition BigStep.cpp:184
void operator+=(const Annotation other)
Add another annotation to this annotation.
Definition BigStep.cpp:93
void addAnnotationTimesAnnotation(Annotation const &anno1, Annotation const &anno2)
Adds another annotation times an annotation to this annotation.
Definition BigStep.cpp:145
RationalFunctionVariable getParameter() const
Definition BigStep.cpp:202
Annotation operator*(RationalFunctionCoefficient n) const
Multiply this annotation with a rational number to get a new annotation.
Definition BigStep.cpp:110
std::pair< models::sparse::Dtmc< RationalFunction >, std::map< UniPoly, Annotation > > bigStep(models::sparse::Dtmc< RationalFunction > const &model, modelchecker::CheckTask< logic::Formula, RationalFunction > const &checkTask)
Perform big-step on the given model and the given checkTask.
Definition BigStep.cpp:381
static std::unordered_map< RationalFunction, Annotation > lastSavedAnnotations
Definition BigStep.h:198
RationalFunction uniPolyToRationalFunction(UniPoly poly)
Definition BigStep.cpp:35
#define STORM_LOG_INFO(message)
Definition logging.h:24
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_ERROR_COND(cond, message)
Definition macros.h:52
void closeFile(std::ofstream &stream)
Close the given file after writing.
Definition file.h:47
void openFile(std::string const &filepath, std::ofstream &filestream, bool append=false, bool silent=false)
Open the given file for writing.
Definition file.h:18
std::set< storm::RationalFunctionVariable > getAllParameters(Model< storm::RationalFunction > const &model)
Get all parameters (probability, rewards, and rates) occurring in the model.
Definition Model.cpp:720
std::pair< storm::RationalNumber, storm::RationalNumber > count(std::vector< storm::storage::BitVector > const &origSets, std::vector< storm::storage::BitVector > const &intersects, std::vector< storm::storage::BitVector > const &intersectsInfo, storm::RationalNumber val, bool plus, uint64_t remdepth)
carl::UnivariatePolynomial< RationalFunctionCoefficient > UniPoly
Definition BigStep.cpp:33
std::pair< std::map< uint64_t, std::set< uint64_t > >, std::set< uint64_t > > findSubgraph(const storm::storage::FlexibleSparseMatrix< RationalFunction > &transitionMatrix, const uint64_t root, const std::map< RationalFunctionVariable, std::map< uint64_t, std::set< uint64_t > > > &treeStates, const boost::optional< std::vector< RationalFunction > > &stateRewardVector, const RationalFunctionVariable parameter)
Definition BigStep.cpp:293
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
ValueType max(ValueType const &first, ValueType const &second)
ValueType min(ValueType const &first, ValueType const &second)
bool isZero(ValueType const &a)
Definition constants.cpp:39
ValueType abs(ValueType const &number)
carl::Interval< double > Interval
Interval type.
carl::Variable RationalFunctionVariable
carl::RationalFunction< Polynomial, true > RationalFunction
uint64_t lookUpInCache(UniPoly const &f, RationalFunctionVariable const &p)
Look up the index of this polynomial in the cache.
Definition BigStep.cpp:55
UniPoly polynomialFromFactorization(std::vector< uint64_t > const &factorization, RationalFunctionVariable const &p) const
Computes a univariate polynomial from a factorization.
Definition BigStep.cpp:71
bool operator()(const UniPoly &lhs, const UniPoly &rhs) const
Definition BigStep.cpp:41