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