15namespace modelchecker {
17template<
typename SparseModelType,
typename ConstantType>
19 bool produceScheduler)
20 :
SparseInstantiationModelChecker<SparseModelType, ConstantType>(parametricModel), modelInstantiator(parametricModel), produceScheduler(produceScheduler) {
24template<
typename SparseModelType,
typename ConstantType>
27 STORM_LOG_THROW(this->currentCheckTask, storm::exceptions::InvalidStateException,
"Checking has been invoked but no property has been specified before.");
28 auto const& instantiatedModel = modelInstantiator.instantiate(valuation);
29 STORM_LOG_THROW(instantiatedModel.getTransitionMatrix().isProbabilistic(), storm::exceptions::InvalidArgumentException,
30 "Instantiation point is invalid as the transition matrix becomes non-stochastic.");
35 return checkReachabilityProbabilityFormula(env, modelChecker, instantiatedModel);
41 return checkReachabilityRewardFormula(env, modelChecker, instantiatedModel);
49 return checkBoundedUntilFormula(env, modelChecker);
51 return modelChecker.
check(env, *this->currentCheckTask);
55template<
typename SparseModelType,
typename ConstantType>
59 if (produceScheduler) {
60 this->currentCheckTask->setProduceSchedulers(
true);
63 if (!this->currentCheckTask->getHint().isExplicitModelCheckerHint()) {
68 if (this->getInstantiationsAreGraphPreserving() && !hint.
hasMaybeStates()) {
70 std::vector<ConstantType> qualitativeResult;
71 if (this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) {
72 auto newCheckTask = *this->currentCheckTask;
73 newCheckTask.setQualitative(
true);
74 newCheckTask.setOnlyInitialStatesRelevant(
false);
75 newCheckTask.setProduceSchedulers(
false);
76 qualitativeResult = modelChecker.check(env, newCheckTask)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
78 auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula());
79 newCheckTask.setQualitative(
true);
80 newCheckTask.setOnlyInitialStatesRelevant(
false);
81 newCheckTask.setProduceSchedulers(
false);
83 modelChecker.computeProbabilities(env, newCheckTask)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
85 storm::storage::BitVector maybeStates = storm::utility::vector::filter<ConstantType>(qualitativeResult, [](ConstantType
const& value) ->
bool {
86 return !(storm::utility::isZero<ConstantType>(value) || storm::utility::isOne<ConstantType>(value));
101 std::unique_ptr<CheckResult> result;
104 if (this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) {
105 result = modelChecker.check(env, *this->currentCheckTask);
106 hint.
setResultHint(result->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector());
107 if (produceScheduler) {
112 auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula())
113 .setOnlyInitialStatesRelevant(
false);
114 std::unique_ptr<storm::modelchecker::CheckResult> quantitativeResult = modelChecker.computeProbabilities(env, newCheckTask);
115 result = quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().compareAgainstBound(
116 this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(),
117 this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs<ConstantType>());
118 hint.
setResultHint(std::move(quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector()));
119 if (produceScheduler) {
128template<
typename SparseModelType,
typename ConstantType>
132 this->currentCheckTask->setProduceSchedulers(
true);
134 if (!this->currentCheckTask->getHint().isExplicitModelCheckerHint()) {
139 if (this->getInstantiationsAreGraphPreserving() && !hint.
hasMaybeStates()) {
141 std::vector<ConstantType> qualitativeResult;
142 if (this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) {
143 auto newCheckTask = *this->currentCheckTask;
144 newCheckTask.setQualitative(
true);
145 newCheckTask.setOnlyInitialStatesRelevant(
false);
146 newCheckTask.setProduceSchedulers(
false);
147 qualitativeResult = modelChecker.check(env, newCheckTask)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
149 auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula());
150 newCheckTask.setQualitative(
true);
151 newCheckTask.setOnlyInitialStatesRelevant(
false);
152 newCheckTask.setProduceSchedulers(
false);
153 qualitativeResult = modelChecker.computeRewards(env, newCheckTask)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
155 storm::storage::BitVector maybeStates = storm::utility::vector::filter<ConstantType>(qualitativeResult, [](ConstantType
const& value) ->
bool {
156 return !(storm::utility::isZero<ConstantType>(value) || storm::utility::isInfinity<ConstantType>(value));
171 std::unique_ptr<CheckResult> result;
174 if (this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) {
175 result = modelChecker.check(env, *this->currentCheckTask);
177 hint.
setResultHint(result->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector());
180 auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula())
181 .setOnlyInitialStatesRelevant(
false);
182 std::unique_ptr<storm::modelchecker::CheckResult> quantitativeResult = modelChecker.computeRewards(env, newCheckTask);
183 result = quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().compareAgainstBound(
184 this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(),
185 this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs<ConstantType>());
187 hint.
setResultHint(std::move(quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector()));
194template<
typename SparseModelType,
typename ConstantType>
197 if (!this->currentCheckTask->getHint().isExplicitModelCheckerHint()) {
200 std::unique_ptr<CheckResult> result;
203 if (this->getInstantiationsAreGraphPreserving() && !hint.
hasMaybeStates()) {
206 if (this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) {
207 result = modelChecker.check(env, *this->currentCheckTask);
208 hint.
setResultHint(result->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector());
210 auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula())
211 .setOnlyInitialStatesRelevant(
false);
212 std::unique_ptr<CheckResult> quantitativeResult = modelChecker.computeProbabilities(env, newCheckTask);
213 result = quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().compareAgainstBound(
214 this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(),
215 this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs<ConstantType>());
216 hint.
setResultHint(std::move(quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector()));
221 std::unique_ptr<CheckResult> subFormulaResult =
222 modelChecker.check(env, this->currentCheckTask->getFormula().asOperatorFormula().getSubformula().asBoundedUntilFormula().getRightSubformula());
223 maybeStates = maybeStates & ~(subFormulaResult->asExplicitQualitativeCheckResult().getTruthValuesVector());
227 result = modelChecker.check(env, *this->currentCheckTask);
FragmentSpecification & setStepBoundedUntilFormulasAllowed(bool newValue)
FragmentSpecification & setOperatorAtTopLevelRequired(bool newValue)
FragmentSpecification & setTimeBoundedUntilFormulasAllowed(bool newValue)
FragmentSpecification & setReachabilityRewardFormulasAllowed(bool newValue)
FragmentSpecification & setRewardOperatorsAllowed(bool newValue)
FragmentSpecification & setBoundedUntilFormulasAllowed(bool newValue)
FragmentSpecification & setNestedOperatorsAllowed(bool newValue)
FragmentSpecification & setProbabilityOperatorsAllowed(bool newValue)
virtual std::unique_ptr< CheckResult > check(Environment const &env, CheckTask< storm::logic::Formula, SolutionType > const &checkTask)
Checks the provided formula.
This class contains information that might accelerate the model checking process.
void setSchedulerHint(boost::optional< storage::Scheduler< ValueType > > const &schedulerHint)
void setResultHint(boost::optional< std::vector< ValueType > > const &resultHint)
storm::storage::BitVector const & getMaybeStates() const
void setComputeOnlyMaybeStates(bool value)
void setNoEndComponentsInMaybeStates(bool value)
void setMaybeStates(storm::storage::BitVector const &maybeStates)
std::vector< ValueType > const & getResultHint() const
bool hasMaybeStates() const
Class to efficiently check a formula on a parametric model with different parameter instantiations.
Class to efficiently check a formula on a parametric model with different parameter instantiations.
std::unique_ptr< CheckResult > checkReachabilityProbabilityFormula(Environment const &env, storm::modelchecker::SparseMdpPrctlModelChecker< storm::models::sparse::Mdp< ConstantType > > &modelChecker, storm::models::sparse::Mdp< ConstantType > const &instantiatedModel)
virtual std::unique_ptr< CheckResult > check(Environment const &env, storm::utility::parametric::Valuation< typename SparseModelType::ValueType > const &valuation) override
std::unique_ptr< CheckResult > checkBoundedUntilFormula(Environment const &env, storm::modelchecker::SparseMdpPrctlModelChecker< storm::models::sparse::Mdp< ConstantType > > &modelChecker)
std::unique_ptr< CheckResult > checkReachabilityRewardFormula(Environment const &env, storm::modelchecker::SparseMdpPrctlModelChecker< storm::models::sparse::Mdp< ConstantType > > &modelChecker, storm::models::sparse::Mdp< ConstantType > const &instantiatedModel)
SparseMdpInstantiationModelChecker(SparseModelType const ¶metricModel, bool produceScheduler=true)
This class represents a (discrete-time) Markov decision process.
storm::storage::SparseMatrix< ValueType > const & getTransitionMatrix() const
Retrieves the matrix representing the transitions of the model.
storm::storage::SparseMatrix< ValueType > getBackwardTransitions() const
Retrieves the backward transition relation of the model, i.e.
A bit vector that is internally represented as a vector of 64-bit values.
This class defines which action is chosen in a particular state of a non-deterministic model.
#define STORM_LOG_THROW(cond, exception, message)
FragmentSpecification propositional()
FragmentSpecification reachability()
bool constexpr maximize(OptimizationDirection d)
bool constexpr minimize(OptimizationDirection d)
storm::storage::BitVector performProb1A(storm::models::sparse::NondeterministicModel< T, RM > const &model, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
Computes the sets of states that have probability 1 of satisfying phi until psi under all possible re...
std::map< typename VariableType< FunctionType >::type, typename CoefficientType< FunctionType >::type > Valuation
storm::storage::BitVector filterGreaterZero(std::vector< T > const &values)
Retrieves a bit vector containing all the indices for which the value at this position is greater tha...