#include "SparseParameterLiftingModelChecker.h" #include "storm/adapters/CarlAdapter.h" #include "storm/logic/FragmentSpecification.h" #include "storm/modelchecker/results/ExplicitQuantitativeCheckResult.h" #include "storm/modelchecker/results/ExplicitQualitativeCheckResult.h" #include "storm/models/sparse/Dtmc.h" #include "storm/models/sparse/Mdp.h" #include "storm/models/sparse/StandardRewardModel.h" #include "storm/exceptions/InvalidArgumentException.h" #include "storm/exceptions/NotSupportedException.h" namespace storm { namespace modelchecker { namespace parametric { template SparseParameterLiftingModelChecker::SparseParameterLiftingModelChecker(SparseModelType const& parametricModel) : parametricModel(parametricModel) { //Intentionally left empty } template void SparseParameterLiftingModelChecker::specifyFormula(storm::modelchecker::CheckTask const& checkTask) { currentFormula = checkTask.getFormula().asSharedPointer(); currentCheckTask = std::make_unique>(checkTask.substituteFormula(*currentFormula).template convertValueType()); if(currentCheckTask->getFormula().isProbabilityOperatorFormula()) { auto const& probOpFormula = currentCheckTask->getFormula().asProbabilityOperatorFormula(); if(probOpFormula.getSubformula().isBoundedUntilFormula()) { specifyBoundedUntilFormula(currentCheckTask->substituteFormula(probOpFormula.getSubformula().asBoundedUntilFormula())); } else if(probOpFormula.getSubformula().isUntilFormula()) { specifyUntilFormula(currentCheckTask->substituteFormula(probOpFormula.getSubformula().asUntilFormula())); } else if (probOpFormula.getSubformula().isEventuallyFormula()) { specifyReachabilityProbabilityFormula(currentCheckTask->substituteFormula(probOpFormula.getSubformula().asEventuallyFormula())); } else { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Parameter lifting is not supported for the given property."); } } else if (currentCheckTask->getFormula().isRewardOperatorFormula()) { auto const& rewOpFormula = currentCheckTask->getFormula().asRewardOperatorFormula(); if(rewOpFormula.getSubformula().isEventuallyFormula()) { specifyReachabilityRewardFormula(currentCheckTask->substituteFormula(rewOpFormula.getSubformula().asEventuallyFormula())); } else if (rewOpFormula.getSubformula().isCumulativeRewardFormula()) { specifyCumulativeRewardFormula(currentCheckTask->substituteFormula(rewOpFormula.getSubformula().asCumulativeRewardFormula())); } } } template std::unique_ptr SparseParameterLiftingModelChecker::check(ParameterRegion const& region, storm::solver::OptimizationDirection const& dirForParameters) { auto quantitativeResult = computeQuantitativeValues(region, dirForParameters); if(currentCheckTask->getFormula().hasQuantitativeResult()) { return quantitativeResult; } else { return quantitativeResult->template asExplicitQuantitativeCheckResult().compareAgainstBound(this->currentCheckTask->getFormula().asOperatorFormula().getComparisonType(), this->currentCheckTask->getFormula().asOperatorFormula().template getThresholdAs()); } } template void SparseParameterLiftingModelChecker::specifyBoundedUntilFormula(CheckTask const& checkTask) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Parameter lifting is not supported for the given property."); } template void SparseParameterLiftingModelChecker::specifyUntilFormula(CheckTask const& checkTask) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Parameter lifting is not supported for the given property."); } template void SparseParameterLiftingModelChecker::specifyReachabilityProbabilityFormula(CheckTask const& checkTask) { // transform to until formula auto untilFormula = std::make_shared(storm::logic::Formula::getTrueFormula(), checkTask.getFormula().getSubformula().asSharedPointer()); specifyUntilFormula(currentCheckTask->substituteFormula(*untilFormula)); } template void SparseParameterLiftingModelChecker::specifyReachabilityRewardFormula(CheckTask const& checkTask) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Parameter lifting is not supported for the given property."); } template void SparseParameterLiftingModelChecker::specifyCumulativeRewardFormula(CheckTask const& checkTask) { STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Parameter lifting is not supported for the given property."); } template class SparseParameterLiftingModelChecker, double>; template class SparseParameterLiftingModelChecker, double>; } } }