diff --git a/src/storm/modelchecker/parametric/ParameterLifting.cpp b/src/storm/modelchecker/parametric/ParameterLifting.cpp index 657b37d07..fb6ab1015 100644 --- a/src/storm/modelchecker/parametric/ParameterLifting.cpp +++ b/src/storm/modelchecker/parametric/ParameterLifting.cpp @@ -19,6 +19,12 @@ #include "storm/exceptions/InvalidStateException.h" #include "storm/exceptions/InvalidArgumentException.h" +#include "storm/utility/Stopwatch.h" +#include "storm/settings/SettingsManager.h" +#include "storm/settings/modules/IOSettings.h" +#include "storm/settings/modules/DebugSettings.h" + + namespace storm { namespace modelchecker { namespace parametric { @@ -34,7 +40,10 @@ namespace storm { STORM_LOG_THROW(checkTask.isOnlyInitialStatesRelevantSet(), storm::exceptions::NotSupportedException, "Parameter lifting requires a property where only the value in the initial states is relevant."); STORM_LOG_THROW(checkTask.isBoundSet(), storm::exceptions::NotSupportedException, "Parameter lifting requires a bounded property."); + storm::utility::Stopwatch sw(true); simplifyParametricModel(checkTask); + sw.stop(); + std::cout << "SIStats: " << sw << std::endl; initializeUnderlyingCheckers(); currentCheckTask = std::make_unique>(checkTask.substituteFormula(*currentFormula)); @@ -83,6 +92,36 @@ namespace storm { STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "When analyzing a region, an invalid initial result was given: " << initialResult); } + // TODO remove this: + if(storm::settings::getModule().isDebugSet() && storm::settings::getModule().isPrismInputSet() && storm::settings::getModule().isPropertySet()) { + std::vector> points; + if(result == RegionCheckResult::AllSat || result == RegionCheckResult::AllViolated) { + points = region.getVerticesOfRegion(region.getVariables()); + points.push_back(region.getCenterPoint()); + } else if (result == RegionCheckResult::CenterSat || result == RegionCheckResult::CenterViolated) { + points.push_back(region.getCenterPoint()); + } + if(!points.empty()) std::cout << "VALIDATE_REGION:" << region.toString(true) << std::endl; + for (auto const& p : points) { + if((result == RegionCheckResult::AllSat) || (result == RegionCheckResult::CenterSat)) { + std::cout << "EXPECTTRUE:"; + } else { + std::cout << "EXPECTFALSE:"; + } + std::cout << "STORMEXECUTABLE --prism " << storm::settings::getModule().getPrismInputFilename() + << " --prop " << storm::settings::getModule().getProperty(); + if( storm::settings::getModule().isConstantsSet()) { + std::cout << " -const " << storm::settings::getModule().getConstantDefinitionString(); + } + for(auto varDef = p.begin(); varDef != p.end(); ++varDef) { + if(varDef!=p.begin()) std::cout << ","; + std::cout << varDef->first << "=" << storm::utility::convertNumber(varDef->second); + } + std::cout << std::endl; + } + } + + return result; } @@ -90,6 +129,8 @@ namespace storm { std::vector, RegionCheckResult>> ParameterLifting::performRegionRefinement(storm::storage::ParameterRegion const& region, typename storm::storage::ParameterRegion::CoefficientType const& threshold) const { STORM_LOG_INFO("Applying refinement on region: " << region.toString(true) << " ."); + storm::utility::Stopwatch sw(true); + auto areaOfParameterSpace = region.area(); auto fractionOfUndiscoveredArea = storm::utility::one::CoefficientType>(); auto fractionOfAllSatArea = storm::utility::zero::CoefficientType>(); @@ -131,6 +172,9 @@ namespace storm { ++indexOfCurrentRegion; } resultRegions.resize(regions.size()); + + sw.stop(); + std::cout << "REStats: " << sw << std::endl; return storm::utility::vector::filterVector(regions, resultRegions); } diff --git a/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp b/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp index 830113f77..90dfd89fd 100644 --- a/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp +++ b/src/storm/modelchecker/parametric/SparseDtmcInstantiationModelChecker.cpp @@ -18,15 +18,25 @@ namespace storm { template std::unique_ptr SparseDtmcInstantiationModelChecker::check(storm::utility::parametric::Valuation const& valuation) { STORM_LOG_THROW(this->currentCheckTask, storm::exceptions::InvalidStateException, "Checking has been invoked but no property has been specified before."); + this->swInstantiation.start(); auto const& instantiatedModel = modelInstantiator.instantiate(valuation); + this->swInstantiation.stop(); STORM_LOG_ASSERT(instantiatedModel.getTransitionMatrix().isProbabilistic(), "Instantiated matrix is not probabilistic!"); storm::modelchecker::SparseDtmcPrctlModelChecker> modelChecker(instantiatedModel); // Check if there are some optimizations implemented for the specified property + this->swCheck.start(); if(!this->currentCheckTask->isQualitativeSet() && this->currentCheckTask->getFormula().isInFragment(storm::logic::reachability().setRewardOperatorsAllowed(true).setReachabilityRewardFormulasAllowed(true))) { - return checkWithHint(modelChecker); + auto result = checkWithHint(modelChecker); + this->swCheck.stop(); + return result; + //return checkWithHint(modelChecker); } else { - return modelChecker.check(*this->currentCheckTask); + STORM_LOG_WARN("Checking without hint"); // todo:remove this warning + auto result = modelChecker.check(*this->currentCheckTask); + this->swCheck.stop(); + return result; + //return modelChecker.check(*this->currentCheckTask); } } diff --git a/src/storm/modelchecker/parametric/SparseDtmcParameterLiftingModelChecker.cpp b/src/storm/modelchecker/parametric/SparseDtmcParameterLiftingModelChecker.cpp index 6578bd58c..40d20c21f 100644 --- a/src/storm/modelchecker/parametric/SparseDtmcParameterLiftingModelChecker.cpp +++ b/src/storm/modelchecker/parametric/SparseDtmcParameterLiftingModelChecker.cpp @@ -166,7 +166,10 @@ namespace storm { return std::make_unique>(resultsForNonMaybeStates); } + this->swInstantiation.start(); parameterLifter->specifyRegion(region, dirForParameters); + this->swInstantiation.stop(); + this->swCheck.start(); // Set up the solver auto solver = solverFactory->create(parameterLifter->getMatrix()); @@ -198,6 +201,7 @@ namespace storm { result[maybeState] = *maybeStateResIt; ++maybeStateResIt; } + this->swCheck.stop(); return std::make_unique>(std::move(result)); } diff --git a/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h b/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h index fb39772e1..474082ff8 100644 --- a/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h +++ b/src/storm/modelchecker/parametric/SparseInstantiationModelChecker.h @@ -6,6 +6,8 @@ #include "storm/modelchecker/hints/ModelCheckerHint.h" #include "storm/utility/parametric.h" +#include "storm/utility/Stopwatch.h" + namespace storm { namespace modelchecker { namespace parametric { @@ -18,6 +20,11 @@ namespace storm { public: SparseInstantiationModelChecker(SparseModelType const& parametricModel); + + ~SparseInstantiationModelChecker() { + std::cout << "INStats (instantiation/check): " << swInstantiation << "\t" << swCheck << std::endl; + } + void specifyFormula(CheckTask const& checkTask); virtual std::unique_ptr check(storm::utility::parametric::Valuation const& valuation) = 0; @@ -29,6 +36,8 @@ namespace storm { SparseModelType const& parametricModel; std::unique_ptr> currentCheckTask; + + storm::utility::Stopwatch swInstantiation, swCheck; private: // store the current formula. Note that currentCheckTask only stores a reference to the formula. diff --git a/src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp b/src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp index 675218d71..cfc13cda2 100644 --- a/src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp +++ b/src/storm/modelchecker/parametric/SparseMdpInstantiationModelChecker.cpp @@ -19,19 +19,27 @@ namespace storm { template std::unique_ptr SparseMdpInstantiationModelChecker::check(storm::utility::parametric::Valuation const& valuation) { STORM_LOG_THROW(this->currentCheckTask, storm::exceptions::InvalidStateException, "Checking has been invoked but no property has been specified before."); + this->swInstantiation.start(); auto const& instantiatedModel = modelInstantiator.instantiate(valuation); + this->swInstantiation.stop(); STORM_LOG_ASSERT(instantiatedModel.getTransitionMatrix().isProbabilistic(), "Instantiated matrix is not probabilistic!"); storm::modelchecker::SparseMdpPrctlModelChecker> modelChecker(instantiatedModel); // Check if there are some optimizations implemented for the specified property + this->swCheck.start(); if(!this->currentCheckTask->isQualitativeSet() && this->currentCheckTask->getFormula().isInFragment(storm::logic::reachability().setRewardOperatorsAllowed(true).setReachabilityRewardFormulasAllowed(true))) { - return checkWithResultHint(modelChecker); + auto result = checkWithResultHint(modelChecker); + this->swCheck.stop(); + return result; + //return checkWithResultHint(modelChecker); } else { - return modelChecker.check(*this->currentCheckTask); + auto result = modelChecker.check(*this->currentCheckTask); + this->swCheck.stop(); + return result; + //return modelChecker.check(*this->currentCheckTask); } } - template std::unique_ptr SparseMdpInstantiationModelChecker::checkWithResultHint(storm::modelchecker::SparseMdpPrctlModelChecker>& modelchecker) { diff --git a/src/storm/modelchecker/parametric/SparseMdpParameterLiftingModelChecker.cpp b/src/storm/modelchecker/parametric/SparseMdpParameterLiftingModelChecker.cpp index 227aea2eb..4410adf55 100644 --- a/src/storm/modelchecker/parametric/SparseMdpParameterLiftingModelChecker.cpp +++ b/src/storm/modelchecker/parametric/SparseMdpParameterLiftingModelChecker.cpp @@ -200,7 +200,10 @@ namespace storm { return std::make_unique>(resultsForNonMaybeStates); } + this->swInstantiation.start(); parameterLifter->specifyRegion(region, dirForParameters); + this->swInstantiation.stop(); + this->swCheck.start(); // Set up the solver auto solver = solverFactory->create(player1Matrix, parameterLifter->getMatrix()); @@ -238,6 +241,7 @@ namespace storm { result[maybeState] = *maybeStateResIt; ++maybeStateResIt; } + this->swCheck.stop(); return std::make_unique>(std::move(result)); } diff --git a/src/storm/modelchecker/parametric/SparseParameterLiftingModelChecker.cpp b/src/storm/modelchecker/parametric/SparseParameterLiftingModelChecker.cpp index 93fce21f7..ff9a4a7f9 100644 --- a/src/storm/modelchecker/parametric/SparseParameterLiftingModelChecker.cpp +++ b/src/storm/modelchecker/parametric/SparseParameterLiftingModelChecker.cpp @@ -22,7 +22,7 @@ namespace storm { template void SparseParameterLiftingModelChecker::specifyFormula(storm::modelchecker::CheckTask const& checkTask) { - + swInit.start(); reset(); currentFormula = checkTask.getFormula().asSharedPointer(); currentCheckTask = std::make_unique>(checkTask.substituteFormula(*currentFormula).template convertValueType()); @@ -46,6 +46,7 @@ namespace storm { specifyCumulativeRewardFormula(currentCheckTask->substituteFormula(rewOpFormula.getSubformula().asCumulativeRewardFormula())); } } + swInit.stop(); } template diff --git a/src/storm/modelchecker/parametric/SparseParameterLiftingModelChecker.h b/src/storm/modelchecker/parametric/SparseParameterLiftingModelChecker.h index 59fd8458b..0d5629dda 100644 --- a/src/storm/modelchecker/parametric/SparseParameterLiftingModelChecker.h +++ b/src/storm/modelchecker/parametric/SparseParameterLiftingModelChecker.h @@ -7,6 +7,8 @@ #include "storm/solver/OptimizationDirection.h" #include "storm/utility/parametric.h" +#include "storm/utility/Stopwatch.h" + namespace storm { namespace modelchecker { namespace parametric { @@ -22,6 +24,10 @@ namespace storm { public: SparseParameterLiftingModelChecker(SparseModelType const& parametricModel); + ~SparseParameterLiftingModelChecker() { + std::cout << "PLStats (init/instantiation/check): " << swInit << "\t" << swInstantiation << "\t" << swCheck << std::endl; + } + virtual bool canHandle(CheckTask const& checkTask) const = 0; void specifyFormula(CheckTask const& checkTask); @@ -49,6 +55,8 @@ namespace storm { SparseModelType const& parametricModel; std::unique_ptr> currentCheckTask; + + storm::utility::Stopwatch swInit, swInstantiation, swCheck; private: // store the current formula. Note that currentCheckTask only stores a reference to the formula.