Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
RegionRefinementCheckResult.cpp
Go to the documentation of this file.
2
3#include <map>
4
8
9namespace storm {
10namespace modelchecker {
11
12template<typename ValueType>
14 std::vector<std::pair<storm::storage::ParameterRegion<ValueType>, storm::modelchecker::RegionResult>> const& regionResults,
16 : RegionCheckResult<ValueType>(regionResults), parameterSpace(parameterSpace) {
17 this->initFractions(this->parameterSpace.area());
18}
19
20template<typename ValueType>
24 : RegionCheckResult<ValueType>(std::move(regionResults)), parameterSpace(std::move(parameterSpace)) {
25 this->initFractions(this->parameterSpace.area());
26}
27
28template<typename ValueType>
32
33template<typename ValueType>
37
38template<typename ValueType>
39std::unique_ptr<CheckResult> RegionRefinementCheckResult<ValueType>::clone() const {
40 return std::make_unique<RegionRefinementCheckResult<ValueType>>(this->regionResults, this->parameterSpace);
41}
42
43template<typename ValueType>
45 if (this->getParameterSpace().getVariables().size() == 2) {
47 auto x = *this->getParameterSpace().getVariables().begin();
48 auto y = *(this->getParameterSpace().getVariables().rbegin());
49
50 uint_fast64_t const sizeX = 128;
51 uint_fast64_t const sizeY = 64;
52
53 out << "Region refinement Check result (visualization):\n";
54 out << " \t x-axis: " << x << " \t y-axis: " << y << " \t S=safe, [ ]=unsafe, -=ambiguous \n";
55 for (uint_fast64_t i = 0; i < sizeX + 2; ++i) {
56 out << "#";
57 }
58 out << '\n';
59
60 CoefficientType deltaX =
61 (getParameterSpace().getUpperBoundary(x) - getParameterSpace().getLowerBoundary(x)) / storm::utility::convertNumber<CoefficientType>(sizeX);
62 CoefficientType deltaY =
63 (getParameterSpace().getUpperBoundary(y) - getParameterSpace().getLowerBoundary(y)) / storm::utility::convertNumber<CoefficientType>(sizeY);
64 CoefficientType printedRegionArea = deltaX * deltaY;
65 for (CoefficientType yUpper = getParameterSpace().getUpperBoundary(y); yUpper != getParameterSpace().getLowerBoundary(y); yUpper -= deltaY) {
66 CoefficientType yLower = yUpper - deltaY;
67 out << "#";
68 for (CoefficientType xLower = getParameterSpace().getLowerBoundary(x); xLower != getParameterSpace().getUpperBoundary(x); xLower += deltaX) {
69 CoefficientType xUpper = xLower + deltaX;
70 bool currRegionSafe = false;
71 bool currRegionUnSafe = false;
72 bool currRegionComplete = false;
73 CoefficientType coveredArea = storm::utility::zero<CoefficientType>();
74 for (auto const& r : this->getRegionResults()) {
76 continue;
77 }
78 CoefficientType interesctionSizeY = std::min(yUpper, r.first.getUpperBoundary(y)) - std::max(yLower, r.first.getLowerBoundary(y));
79 interesctionSizeY = std::max(interesctionSizeY, storm::utility::zero<CoefficientType>());
80 CoefficientType interesctionSizeX = std::min(xUpper, r.first.getUpperBoundary(x)) - std::max(xLower, r.first.getLowerBoundary(x));
81 interesctionSizeX = std::max(interesctionSizeX, storm::utility::zero<CoefficientType>());
82 CoefficientType instersectionArea = interesctionSizeY * interesctionSizeX;
83 if (!storm::utility::isZero(instersectionArea)) {
84 currRegionSafe = currRegionSafe || r.second == storm::modelchecker::RegionResult::AllSat;
85 currRegionUnSafe = currRegionUnSafe || r.second == storm::modelchecker::RegionResult::AllViolated;
86 coveredArea += instersectionArea;
87 if (currRegionSafe && currRegionUnSafe) {
88 break;
89 }
90 if (coveredArea == printedRegionArea) {
91 currRegionComplete = true;
92 break;
93 }
94 }
95 }
96 if (currRegionComplete && currRegionSafe && !currRegionUnSafe) {
97 out << "S";
98 } else if (currRegionComplete && currRegionUnSafe && !currRegionSafe) {
99 out << " ";
100 } else {
101 out << "-";
102 }
103 }
104 out << "#\n";
105 }
106 for (uint_fast64_t i = 0; i < sizeX + 2; ++i) {
107 out << "#";
108 }
109 out << '\n';
110 } else {
111 STORM_LOG_WARN("Writing illustration of region check result to a stream is only implemented for two parameters.");
112 }
113 return out;
114}
115
116#ifdef STORM_HAVE_CARL
118#endif
119} // namespace modelchecker
120} // namespace storm
virtual void initFractions(typename storm::storage::ParameterRegion< ValueType >::CoefficientType const &overallArea)
storm::storage::ParameterRegion< ValueType > parameterSpace
virtual std::unique_ptr< CheckResult > clone() const override
virtual std::ostream & writeIllustrationToStream(std::ostream &out) const override
storm::storage::ParameterRegion< ValueType > const & getParameterSpace() const
RegionRefinementCheckResult(std::vector< std::pair< storm::storage::ParameterRegion< ValueType >, storm::modelchecker::RegionResult > > const &regionResults, storm::storage::ParameterRegion< ValueType > const &parameterSpace)
storm::utility::parametric::CoefficientType< ParametricType >::type CoefficientType
CoefficientType area() const
Returns the area of this region.
#define STORM_LOG_WARN(message)
Definition logging.h:30
RegionResult
The results for a single Parameter Region.
@ AllSat
the formula is satisfied for all parameters in the given region
@ AllViolated
the formula is violated for all parameters in the given region
bool isZero(ValueType const &a)
Definition constants.cpp:41
LabParser.cpp.
Definition cli.cpp:18