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