17namespace modelchecker {
19template<
typename SparseModelType,
typename ConstantType>
21 bool produceScheduler)
22 :
SparseInstantiationModelChecker<SparseModelType, ConstantType>(parametricModel), modelInstantiator(parametricModel), produceScheduler(produceScheduler) {
26template<
typename SparseModelType,
typename ConstantType>
29 STORM_LOG_THROW(this->currentCheckTask, storm::exceptions::InvalidStateException,
"Checking has been invoked but no property has been specified before.");
31 auto const& instantiatedModel = modelInstantiator.instantiate(valuation);
32 if (instantiatedModel.isExact()) {
33 STORM_LOG_THROW(instantiatedModel.getTransitionMatrix().isProbabilistic(storm::utility::zero<ConstantType>()),
34 storm::exceptions::InvalidArgumentException,
"Instantiation point is invalid as the transition matrix becomes non-stochastic.");
36 auto const& generalSettings = storm::settings::getModule<storm::settings::modules::GeneralSettings>();
37 STORM_LOG_THROW(instantiatedModel.getTransitionMatrix().isProbabilistic(storm::utility::convertNumber<ConstantType>(generalSettings.getPrecision())),
38 storm::exceptions::InvalidArgumentException,
"Instantiation point is invalid as the transition matrix becomes non-stochastic.");
45 return checkReachabilityProbabilityFormula(env, modelChecker, instantiatedModel);
51 return checkReachabilityRewardFormula(env, modelChecker, instantiatedModel);
59 return checkBoundedUntilFormula(env, modelChecker);
61 return modelChecker.
check(env, *this->currentCheckTask);
65template<
typename SparseModelType,
typename ConstantType>
69 if (produceScheduler) {
70 this->currentCheckTask->setProduceSchedulers(
true);
73 if (!this->currentCheckTask->getHint().isExplicitModelCheckerHint()) {
78 if (this->getInstantiationsAreGraphPreserving() && !hint.
hasMaybeStates()) {
80 std::vector<ConstantType> qualitativeResult;
81 if (this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) {
82 auto newCheckTask = *this->currentCheckTask;
83 newCheckTask.setQualitative(
true);
84 newCheckTask.setOnlyInitialStatesRelevant(
false);
85 newCheckTask.setProduceSchedulers(
false);
86 qualitativeResult = modelChecker.check(env, newCheckTask)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
88 auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula());
89 newCheckTask.setQualitative(
true);
90 newCheckTask.setOnlyInitialStatesRelevant(
false);
91 newCheckTask.setProduceSchedulers(
false);
93 modelChecker.computeProbabilities(env, newCheckTask)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
95 storm::storage::BitVector maybeStates = storm::utility::vector::filter<ConstantType>(qualitativeResult, [](ConstantType
const& value) ->
bool {
96 return !(storm::utility::isZero<ConstantType>(value) || storm::utility::isOne<ConstantType>(value));
111 std::unique_ptr<CheckResult> result;
114 if (this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) {
115 result = modelChecker.check(env, *this->currentCheckTask);
116 hint.
setResultHint(result->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector());
117 if (produceScheduler) {
122 auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula())
123 .setOnlyInitialStatesRelevant(
false);
124 std::unique_ptr<storm::modelchecker::CheckResult> quantitativeResult = modelChecker.computeProbabilities(env, newCheckTask);
125 result = quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().compareAgainstBound(
126 this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(),
127 this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs<ConstantType>());
128 hint.
setResultHint(std::move(quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector()));
129 if (produceScheduler) {
138template<
typename SparseModelType,
typename ConstantType>
142 this->currentCheckTask->setProduceSchedulers(
true);
144 if (!this->currentCheckTask->getHint().isExplicitModelCheckerHint()) {
149 if (this->getInstantiationsAreGraphPreserving() && !hint.
hasMaybeStates()) {
151 std::vector<ConstantType> qualitativeResult;
152 if (this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) {
153 auto newCheckTask = *this->currentCheckTask;
154 newCheckTask.setQualitative(
true);
155 newCheckTask.setOnlyInitialStatesRelevant(
false);
156 newCheckTask.setProduceSchedulers(
false);
157 qualitativeResult = modelChecker.check(env, newCheckTask)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
159 auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula());
160 newCheckTask.setQualitative(
true);
161 newCheckTask.setOnlyInitialStatesRelevant(
false);
162 newCheckTask.setProduceSchedulers(
false);
163 qualitativeResult = modelChecker.computeRewards(env, newCheckTask)->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector();
165 storm::storage::BitVector maybeStates = storm::utility::vector::filter<ConstantType>(qualitativeResult, [](ConstantType
const& value) ->
bool {
166 return !(storm::utility::isZero<ConstantType>(value) || storm::utility::isInfinity<ConstantType>(value));
181 std::unique_ptr<CheckResult> result;
184 if (this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) {
185 result = modelChecker.check(env, *this->currentCheckTask);
187 hint.
setResultHint(result->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector());
190 auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula())
191 .setOnlyInitialStatesRelevant(
false);
192 std::unique_ptr<storm::modelchecker::CheckResult> quantitativeResult = modelChecker.computeRewards(env, newCheckTask);
193 result = quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().compareAgainstBound(
194 this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(),
195 this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs<ConstantType>());
197 hint.
setResultHint(std::move(quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector()));
204template<
typename SparseModelType,
typename ConstantType>
207 if (!this->currentCheckTask->getHint().isExplicitModelCheckerHint()) {
210 std::unique_ptr<CheckResult> result;
213 if (this->getInstantiationsAreGraphPreserving() && !hint.
hasMaybeStates()) {
216 if (this->currentCheckTask->getFormula().asOperatorFormula().hasQuantitativeResult()) {
217 result = modelChecker.check(env, *this->currentCheckTask);
218 hint.
setResultHint(result->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector());
220 auto newCheckTask = this->currentCheckTask->substituteFormula(this->currentCheckTask->getFormula().asOperatorFormula().getSubformula())
221 .setOnlyInitialStatesRelevant(
false);
222 std::unique_ptr<CheckResult> quantitativeResult = modelChecker.computeProbabilities(env, newCheckTask);
223 result = quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().compareAgainstBound(
224 this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(),
225 this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs<ConstantType>());
226 hint.
setResultHint(std::move(quantitativeResult->template asExplicitQuantitativeCheckResult<ConstantType>().getValueVector()));
231 std::unique_ptr<CheckResult> subFormulaResult =
232 modelChecker.check(env, this->currentCheckTask->getFormula().asOperatorFormula().getSubformula().asBoundedUntilFormula().getRightSubformula());
233 maybeStates = maybeStates & ~(subFormulaResult->asExplicitQualitativeCheckResult().getTruthValuesVector());
237 result = modelChecker.check(env, *this->currentCheckTask);
242template<
typename SparseModelType,
typename ConstantType>
246 auto const& instantiatedModel = modelInstantiator.instantiate(valuation);
247 if (instantiatedModel.isExact()) {
248 return instantiatedModel.getTransitionMatrix().isProbabilistic(storm::utility::zero<ConstantType>());
250 auto const& generalSettings = storm::settings::getModule<storm::settings::modules::GeneralSettings>();
251 return instantiatedModel.getTransitionMatrix().isProbabilistic(storm::utility::convertNumber<ConstantType>(generalSettings.getPrecision()));
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)
virtual bool isWellDefined(storm::utility::parametric::Valuation< typename SparseModelType::ValueType > const &valuation) override
Checks if the given valuation is valid for the current model.
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...