20namespace modelchecker {
22template<
typename SparseModelType,
typename ConstantType>
27template<
typename SparseModelType,
typename ConstantType>
30 currentFormula = checkTask.
getFormula().asSharedPointer();
31 currentCheckTask = std::make_unique<storm::modelchecker::CheckTask<storm::logic::Formula, ConstantType>>(
32 checkTask.
substituteFormula(*currentFormula).template convertValueType<ConstantType>());
34 if (currentCheckTask->getFormula().isProbabilityOperatorFormula()) {
35 auto const& probOpFormula = currentCheckTask->getFormula().asProbabilityOperatorFormula();
36 if (probOpFormula.getSubformula().isBoundedUntilFormula()) {
37 specifyBoundedUntilFormula(currentCheckTask->substituteFormula(probOpFormula.getSubformula().asBoundedUntilFormula()));
38 }
else if (probOpFormula.getSubformula().isUntilFormula()) {
39 specifyUntilFormula(env, currentCheckTask->substituteFormula(probOpFormula.getSubformula().asUntilFormula()));
40 }
else if (probOpFormula.getSubformula().isEventuallyFormula()) {
41 specifyReachabilityProbabilityFormula(env, currentCheckTask->substituteFormula(probOpFormula.getSubformula().asEventuallyFormula()));
43 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Parameter lifting is not supported for the given property.");
45 }
else if (currentCheckTask->getFormula().isRewardOperatorFormula()) {
46 auto const& rewOpFormula = currentCheckTask->getFormula().asRewardOperatorFormula();
47 if (rewOpFormula.getSubformula().isEventuallyFormula()) {
48 specifyReachabilityRewardFormula(env, currentCheckTask->substituteFormula(rewOpFormula.getSubformula().asEventuallyFormula()));
49 }
else if (rewOpFormula.getSubformula().isCumulativeRewardFormula()) {
50 specifyCumulativeRewardFormula(currentCheckTask->substituteFormula(rewOpFormula.getSubformula().asCumulativeRewardFormula()));
55template<
typename SparseModelType,
typename ConstantType>
57 return this->parametricModel->getInitialStates().getNumberOfSetBits() == 1;
60template<
typename SparseModelType,
typename ConstantType>
62 STORM_LOG_ASSERT(hasUniqueInitialState(),
"Model does not have a unique initial state.");
63 return *this->parametricModel->getInitialStates().begin();
66template<
typename RegionType>
68 std::map<typename RegionType::VariableType, storm::analysis::MonotonicityKind>
const& monotonicityResult,
70 typename RegionType::Valuation result;
71 for (
auto const& [var, mon] : monotonicityResult) {
73 result.emplace(var, region.getLowerBoundary(var));
75 result.emplace(var,
storm::solver::maximize(dir) ? region.getUpperBoundary(var) : region.getLowerBoundary(var));
77 result.emplace(var,
storm::solver::minimize(dir) ? region.getUpperBoundary(var) : region.getLowerBoundary(var));
83template<
typename SparseModelType,
typename ConstantType>
86 bool sampleVerticesOfRegion) {
87 STORM_LOG_THROW(this->currentCheckTask->isOnlyInitialStatesRelevantSet(), storm::exceptions::NotSupportedException,
88 "Analyzing regions with parameter lifting requires a property where only the value in the initial states is relevant.");
89 STORM_LOG_THROW(this->currentCheckTask->isBoundSet(), storm::exceptions::NotSupportedException,
90 "Analyzing regions with parameter lifting requires a bounded property.");
91 STORM_LOG_THROW(hasUniqueInitialState(), storm::exceptions::NotSupportedException,
92 "Analyzing regions with parameter lifting requires a model with a single initial state.");
103 if (getInstantiationChecker(
false).isWellDefined(center)) {
104 result = getInstantiationChecker(
false).check(env, center)->asExplicitQualitativeCheckResult()[getUniqueInitialState()]
109 if (getInstantiationChecker(
false).isWellDefined(lowerCorner)) {
110 result = getInstantiationChecker(
false).check(env, lowerCorner)->asExplicitQualitativeCheckResult()[getUniqueInitialState()]
122 [[maybe_unused]]
bool const existsViolated =
125 "Invalid state of region analysis.");
127 auto const dirForSat =
128 isLowerBound(this->currentCheckTask->getBound().comparisonType) ? storm::OptimizationDirection::Minimize : storm::OptimizationDirection::Maximize;
130 std::vector<storm::OptimizationDirection> dirsToCheck;
132 dirsToCheck = {dirForSat};
133 }
else if (existsIllDefined) {
139 for (
auto const& dirToCheck : dirsToCheck) {
142 globalMonotonicity.has_value() && globalMonotonicity->isDone() && globalMonotonicity->isAllMonotonicity()) {
145 auto& checker = existsSat ? getInstantiationCheckerSAT(
false) : getInstantiationCheckerVIO(
false);
146 bool const monCheckResult = checker.check(env, valuation)->asExplicitQualitativeCheckResult()[getUniqueInitialState()];
147 if (existsSat == monCheckResult) {
149 STORM_LOG_INFO(
"Region " << region.
region <<
" is " << result <<
", discovered with instantiation checker on " << valuation
150 <<
" and help of monotonicity\n");
158 "This case should only be reached if the initial region result is unknown, but it is " << result <<
".");
160 if (sampleVerticesOfRegion) {
161 result = sampleVertices(env, region.
region, result);
166 auto const checkResult = this->check(env, region, dirToCheck);
168 bool const value = checkResult->asExplicitQualitativeCheckResult()[getUniqueInitialState()];
169 if ((dirToCheck == dirForSat) == value) {
171 }
else if (sampleVerticesOfRegion) {
172 result = sampleVertices(env, region.
region, result);
182template<
typename SparseModelType,
typename ConstantType>
197 auto vertexIt = vertices.begin();
198 while (vertexIt != vertices.end() && !(hasSatPoint && hasViolatedPoint)) {
199 if (getInstantiationChecker(
false).check(env, *vertexIt)->asExplicitQualitativeCheckResult()[getUniqueInitialState()]) {
202 hasViolatedPoint =
true;
208 if (hasViolatedPoint) {
220template<
typename SparseModelType,
typename ConstantType>
223 auto quantitativeResult = computeQuantitativeValues(env, region, dirForParameters);
224 if (quantitativeResult.size() == 0) {
227 auto quantitativeCheckResult = std::make_unique<storm::modelchecker::ExplicitQuantitativeCheckResult<ConstantType>>(std::move(quantitativeResult));
228 if (currentCheckTask->getFormula().hasQuantitativeResult()) {
229 return quantitativeCheckResult;
231 return quantitativeCheckResult->compareAgainstBound(this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(),
232 this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs<ConstantType>());
236template<
typename SparseModelType,
typename ConstantType>
239 STORM_LOG_WARN_COND(this->currentCheckTask->getFormula().hasQuantitativeResult(),
"Computing quantitative bounds for a qualitative formula...");
240 return std::make_unique<ExplicitQuantitativeCheckResult<ConstantType>>(computeQuantitativeValues(env, region, dirForParameters));
243template<
typename SparseModelType,
typename ConstantType>
247 STORM_LOG_THROW(hasUniqueInitialState(), storm::exceptions::NotSupportedException,
248 "Getting a bound at the initial state requires a model with a single initial state.");
249 auto result = computeQuantitativeValues(env, region, dirForParameters).at(getUniqueInitialState());
250 return storm::utility::isInfinity(result) ? storm::utility::infinity<CoefficientType>() : storm::utility::convertNumber<CoefficientType>(result);
253template<
typename SparseModelType,
typename ConstantType>
256 return getInstantiationChecker(quantitative);
259template<
typename SparseModelType,
typename ConstantType>
262 return getInstantiationChecker(quantitative);
265template<
typename SparseModelType,
typename ConstantType>
267 return *parametricModel;
270template<
typename SparseModelType,
typename ConstantType>
272 return *currentCheckTask;
275template<
typename SparseModelType,
typename ConstantType>
278 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Parameter lifting is not supported for the given property.");
281template<
typename SparseModelType,
typename ConstantType>
284 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Parameter lifting is not supported for the given property.");
287template<
typename SparseModelType,
typename ConstantType>
293 specifyUntilFormula(env, currentCheckTask->substituteFormula(*untilFormula));
296template<
typename SparseModelType,
typename ConstantType>
299 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Parameter lifting is not supported for the given property.");
302template<
typename SparseModelType,
typename ConstantType>
305 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Parameter lifting is not supported for the given property.");
308template<
typename SparseModelType,
typename ConstantType>
309std::pair<typename SparseParameterLiftingModelChecker<SparseModelType, ConstantType>::CoefficientType,
319 auto value = getInstantiationChecker(
true).check(env, point)->template asExplicitQuantitativeCheckResult<ConstantType>()[getUniqueInitialState()];
321 return std::make_pair(storm::utility::convertNumber<CoefficientType>(value), std::move(point));
324template<
typename SparseModelType,
typename ConstantType>
327 std::vector<ConstantType>
const& newValues) {
328 if (hasUniqueInitialState()) {
330 auto const& newValue = newValues.at(getUniqueInitialState());
332 storm::utility::isInfinity(newValue) ? storm::utility::infinity<CoefficientType>() : storm::utility::convertNumber<CoefficientType>(newValue);
CheckTask< NewFormulaType, ValueType > substituteFormula(NewFormulaType const &newFormula) const
Copies the check task from the source while replacing the formula with the new one.
FormulaType const & getFormula() const
Retrieves the formula from this task.
Class to efficiently check a formula on a parametric model with different parameter instantiations.
Class to approximately check a formula on a parametric model for all parameter valuations within a re...
virtual RegionResult analyzeRegion(Environment const &env, AnnotatedRegion< ParametricType > ®ion, RegionResultHypothesis const &hypothesis=RegionResultHypothesis::Unknown, bool sampleVerticesOfRegion=false) override
Analyzes the given region by means of Parameter Lifting.
typename RegionModelChecker< ParametricType >::CoefficientType CoefficientType
uint64_t getUniqueInitialState() const
SparseParameterLiftingModelChecker()
virtual void specifyUntilFormula(Environment const &env, CheckTask< storm::logic::UntilFormula, ConstantType > const &checkTask)
virtual void specifyReachabilityRewardFormula(Environment const &env, CheckTask< storm::logic::EventuallyFormula, ConstantType > const &checkTask)
std::unique_ptr< QuantitativeCheckResult< ConstantType > > getBound(Environment const &env, AnnotatedRegion< ParametricType > ®ion, storm::solver::OptimizationDirection const &dirForParameters)
Over-approximates the values within the given region for each state of the considered parametric mode...
virtual void specifyCumulativeRewardFormula(const CheckTask< storm::logic::CumulativeRewardFormula, ConstantType > &checkTask)
virtual storm::modelchecker::SparseInstantiationModelChecker< SparseModelType, ConstantType > & getInstantiationCheckerSAT(bool quantitative)
std::unique_ptr< CheckResult > check(Environment const &env, AnnotatedRegion< ParametricType > ®ion, storm::solver::OptimizationDirection const &dirForParameters)
Checks the specified formula on the given region by applying parameter lifting (Parameter choices are...
RegionResult sampleVertices(Environment const &env, storm::storage::ParameterRegion< ParametricType > const ®ion, RegionResult const &initialResult=RegionResult::Unknown)
Analyzes the 2^#parameters corner points of the given region.
void specifyFormula(Environment const &env, CheckTask< storm::logic::Formula, ParametricType > const &checkTask)
virtual storm::modelchecker::SparseInstantiationModelChecker< SparseModelType, ConstantType > & getInstantiationCheckerVIO(bool quantitative)
bool hasUniqueInitialState() const
virtual CoefficientType getBoundAtInitState(Environment const &env, AnnotatedRegion< ParametricType > ®ion, storm::solver::OptimizationDirection const &dirForParameters) override
Over-approximates the value within the given region.
void updateKnownValueBoundInRegion(AnnotatedRegion< ParametricType > ®ion, storm::solver::OptimizationDirection dir, std::vector< ConstantType > const &newValues)
virtual void specifyReachabilityProbabilityFormula(Environment const &env, CheckTask< storm::logic::EventuallyFormula, ConstantType > const &checkTask)
typename RegionModelChecker< ParametricType >::Valuation Valuation
CheckTask< storm::logic::Formula, ConstantType > const & getCurrentCheckTask() const
virtual std::pair< CoefficientType, Valuation > getAndEvaluateGoodPoint(Environment const &env, AnnotatedRegion< ParametricType > ®ion, storm::solver::OptimizationDirection const &dirForParameters) override
Heuristically finds a point within the region and computes the value at the initial state for that po...
SparseModelType const & getConsideredParametricModel() const
virtual void specifyBoundedUntilFormula(const CheckTask< storm::logic::BoundedUntilFormula, ConstantType > &checkTask)
std::set< VariableType > const & getVariables() const
Valuation getCenterPoint() const
Returns the center point of this region.
Valuation const & getLowerBoundaries() const
CoefficientType getCenter(const std::string varName) const
std::vector< Valuation > getVerticesOfRegion(std::set< VariableType > const &consideredVariables) const
Returns a vector of all possible combinations of lower and upper bounds of the given variables.
#define STORM_LOG_INFO(message)
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_WARN_COND(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
@ Incr
the result is monotonically increasing
@ Decr
the result is monotonically decreasing
@ Constant
the result is constant
RegionResult
The results for a single Parameter Region.
@ CenterSat
the formula is satisfied for the parameter Valuation that corresponds to the center point of the regi...
@ CenterIllDefined
the formula is ill-defined for the parameter Valuation that corresponds to the center point of the re...
@ 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
@ Unknown
the result is unknown
@ ExistsBoth
the formula is satisfied for some parameters but also violated for others
@ AllIllDefined
the formula is ill-defined for all parameters in the given region
@ CenterViolated
the formula is violated for the parameter Valuation that corresponds to the center point of the regio...
@ ExistsSat
the formula is satisfied for at least one parameter evaluation that lies in the given region
@ ExistsViolated
the formula is violated for at least one parameter evaluation that lies in the given region
@ ExistsIllDefined
the formula is ill-defined for at least one parameter evaluation that lies in the given region
RegionResultHypothesis
hypothesis for the result for a single Parameter Region
auto getOptimalValuationForMonotonicity(RegionType const ®ion, std::map< typename RegionType::VariableType, storm::analysis::MonotonicityKind > const &monotonicityResult, storm::OptimizationDirection dir)
bool constexpr maximize(OptimizationDirection d)
OptimizationDirection constexpr invert(OptimizationDirection d)
bool constexpr minimize(OptimizationDirection d)
bool isInfinity(ValueType const &a)
storm::modelchecker::MonotonicityAnnotation< ParametricType > monotonicityAnnotation
Whether the result is known through monotonicity.
bool resultKnownThroughMonotonicity
The result of the analysis of this region.
storm::modelchecker::RegionResult result
The depth of the refinement tree this region is in.
bool updateValueBound(CoefficientType const &newValue, storm::OptimizationDirection dir)
what is known about this region in terms of monotonicity
Region const region
The subregions of this region.