|
|
@ -2,6 +2,8 @@ |
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <boost/variant/get.hpp>
|
|
|
|
|
|
|
|
#include "storm/utility/macros.h"
|
|
|
|
#include "storm/utility/FilteredRewardModel.h"
|
|
|
@ -14,6 +16,10 @@ |
|
|
|
#include "storm/modelchecker/helper/utility/SetInformationFromCheckTask.h"
|
|
|
|
|
|
|
|
#include "storm/logic/FragmentSpecification.h"
|
|
|
|
#include "storm/logic/Coalition.h"
|
|
|
|
|
|
|
|
#include "storm/storage/BitVector.h"
|
|
|
|
#include "storm/environment/solver/MultiplierEnvironment.h"
|
|
|
|
|
|
|
|
#include "storm/models/sparse/StandardRewardModel.h"
|
|
|
|
|
|
|
@ -30,10 +36,11 @@ namespace storm { |
|
|
|
// Intentionally left empty.
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename SparseSmgModelType> |
|
|
|
bool SparseSmgRpatlModelChecker<SparseSmgModelType>::canHandleStatic(CheckTask<storm::logic::Formula, ValueType> const& checkTask, bool* requiresSingleInitialState) { |
|
|
|
storm::logic::Formula const& formula = checkTask.getFormula(); |
|
|
|
|
|
|
|
if (formula.isInFragment(storm::logic::rpatl().setCoalitionOperatorsAllowed(true).setRewardOperatorsAllowed(true).setLongRunAverageRewardFormulasAllowed(true).setLongRunAverageProbabilitiesAllowed(true).setLongRunAverageOperatorsAllowed(true))) { |
|
|
|
return true; |
|
|
|
} else { |
|
|
@ -51,21 +58,22 @@ namespace storm { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename SparseSmgModelType> |
|
|
|
std::unique_ptr<CheckResult> SparseSmgRpatlModelChecker<SparseSmgModelType>::checkGameFormula(Environment const& env, CheckTask<storm::logic::GameFormula, ValueType> const& checkTask) { |
|
|
|
STORM_LOG_DEBUG("checkGameFormula matrix: " << this->getModel().getTransitionMatrix().getDimensionsAsString()); |
|
|
|
STORM_LOG_DEBUG("checkGameFormula playerindices:"); |
|
|
|
STORM_LOG_DEBUG("checkGameFormula matrix: \n" << this->getModel().getTransitionMatrix()); |
|
|
|
// TODO set min max row groups w.r.t. coalition
|
|
|
|
Environment solverEnv = env; |
|
|
|
coalitionIndicator(solverEnv, checkTask); |
|
|
|
|
|
|
|
storm::logic::GameFormula const& gameFormula = checkTask.getFormula(); |
|
|
|
storm::logic::Formula const& subFormula = gameFormula.getSubformula(); |
|
|
|
STORM_LOG_DEBUG(gameFormula); |
|
|
|
|
|
|
|
if (subFormula.isRewardOperatorFormula()) { |
|
|
|
return this->checkRewardOperatorFormula(env, checkTask.substituteFormula(subFormula.asRewardOperatorFormula())); |
|
|
|
return this->checkRewardOperatorFormula(solverEnv, checkTask.substituteFormula(subFormula.asRewardOperatorFormula())); |
|
|
|
} else if (subFormula.isLongRunAverageOperatorFormula()) { |
|
|
|
return this->checkLongRunAverageOperatorFormula(env, checkTask.substituteFormula(subFormula.asLongRunAverageOperatorFormula())); |
|
|
|
return this->checkLongRunAverageOperatorFormula(solverEnv, checkTask.substituteFormula(subFormula.asLongRunAverageOperatorFormula())); |
|
|
|
} |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "checkGameFormula NYI"); |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Cannot check this property (yet)."); |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ModelType> |
|
|
@ -73,26 +81,26 @@ namespace storm { |
|
|
|
storm::logic::RewardOperatorFormula const& formula = checkTask.getFormula(); |
|
|
|
std::unique_ptr<CheckResult> result = this->computeRewards(env, formula.getMeasureType(), checkTask.substituteFormula(formula.getSubformula())); |
|
|
|
|
|
|
|
return nullptr; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ModelType> |
|
|
|
std::unique_ptr<CheckResult> AbstractModelChecker<ModelType>::computeRewards(Environment const& env, storm::logic::RewardMeasureType rewardMeasureType, CheckTask<storm::logic::Formula, ValueType> const& checkTask) { |
|
|
|
storm::logic::Formula const& rewardFormula = checkTask.getFormula(); |
|
|
|
if (rewardFormula.isLongRunAverageRewardFormula()) { |
|
|
|
return this->computeLongRunAverageRewards(env, rewardMeasureType, checkTask.substituteFormula(rewardFormula.asLongRunAverageRewardFormula())); |
|
|
|
} |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The given formula '" << rewardFormula << "' is invalid."); |
|
|
|
std::unique_ptr<CheckResult> SparseSmgRpatlModelChecker<ModelType>::checkLongRunAverageOperatorFormula(Environment const& env, CheckTask<storm::logic::LongRunAverageOperatorFormula, ValueType> const& checkTask) { |
|
|
|
storm::logic::LongRunAverageOperatorFormula const& formula = checkTask.getFormula(); |
|
|
|
std::unique_ptr<CheckResult> result = this->computeLongRunAverageProbabilities(env, checkTask.substituteFormula(formula.getSubformula().asStateFormula())); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
template<typename ModelType> |
|
|
|
std::unique_ptr<CheckResult> AbstractModelChecker<ModelType>::checkLongRunAverageOperatorFormula(Environment const& env, CheckTask<storm::logic::LongRunAverageOperatorFormula, ValueType> const& checkTask) { |
|
|
|
storm::logic::LongRunAverageOperatorFormula const& formula = checkTask.getFormula(); |
|
|
|
//STORM_LOG_THROW(formula.getSubformula().isStateFormula(), storm::exceptions::InvalidArgumentException, "The given formula is invalid.");
|
|
|
|
|
|
|
|
std::unique_ptr<CheckResult> result = this->computeLongRunAverageProbabilities(env, checkTask.substituteFormula(formula.getSubformula().asStateFormula())); |
|
|
|
|
|
|
|
return result; //TODO check bounds.
|
|
|
|
template<typename ModelType> |
|
|
|
std::unique_ptr<CheckResult> SparseSmgRpatlModelChecker<ModelType>::computeRewards(Environment const& env, storm::logic::RewardMeasureType rewardMeasureType, CheckTask<storm::logic::Formula, ValueType> const& checkTask) { |
|
|
|
storm::logic::Formula const& rewardFormula = checkTask.getFormula(); |
|
|
|
if (rewardFormula.isLongRunAverageRewardFormula()) { |
|
|
|
return this->computeLongRunAverageRewards(env, rewardMeasureType, checkTask.substituteFormula(rewardFormula.asLongRunAverageRewardFormula())); |
|
|
|
} |
|
|
|
STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "The given formula '" << rewardFormula << "' cannot (yet) be handled."); |
|
|
|
} |
|
|
|
|
|
|
|
template<typename SparseSmgModelType> |
|
|
@ -107,9 +115,15 @@ namespace storm { |
|
|
|
storm::modelchecker::helper::setInformationFromCheckTaskNondeterministic(helper, checkTask, this->getModel()); |
|
|
|
auto values = helper.computeLongRunAverageRewards(env, rewardModel.get()); |
|
|
|
|
|
|
|
//std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<ValueType>(std::move(values));
|
|
|
|
//return result;
|
|
|
|
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "NYI"); |
|
|
|
std::unique_ptr<CheckResult> result(new ExplicitQuantitativeCheckResult<ValueType>(std::move(values))); |
|
|
|
if (checkTask.isProduceSchedulersSet()) { |
|
|
|
result->asExplicitQuantitativeCheckResult<ValueType>().setScheduler(std::make_unique<storm::storage::Scheduler<ValueType>>(helper.extractScheduler())); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename SparseSmgModelType> |
|
|
|
void SparseSmgRpatlModelChecker<SparseSmgModelType>::coalitionIndicator(Environment& env, CheckTask<storm::logic::GameFormula, ValueType> const& checkTask) { |
|
|
|
storm::storage::BitVector coalitionIndicators(this->getModel().getTransitionMatrix().getRowGroupCount()); |
|
|
@ -143,7 +157,6 @@ namespace storm { |
|
|
|
template class SparseSmgRpatlModelChecker<storm::models::sparse::Smg<double>>; |
|
|
|
#ifdef STORM_HAVE_CARL
|
|
|
|
template class SparseSmgRpatlModelChecker<storm::models::sparse::Smg<storm::RationalNumber>>; |
|
|
|
//template class SparseSmgRpatlModelChecker<storm::models::sparse::Smg<storm::RationalFunction>>; TODO are we going to need this?
|
|
|
|
#endif
|
|
|
|
} |
|
|
|
} |