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