Browse Source

minor fixes to let the total reward tests compile and pass

tempestpy_adaptions
TimQu 7 years ago
parent
commit
5a16b2befa
  1. 8
      resources/examples/testfiles/ma/simple2.ma
  2. 2
      src/storm/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.cpp
  3. 2
      src/test/storm/modelchecker/CtmcCslModelCheckerTest.cpp
  4. 38
      src/test/storm/modelchecker/MarkovAutomatonCslModelCheckerTest.cpp

8
resources/examples/testfiles/ma/simple2.ma

@ -4,12 +4,13 @@ ma
module main
s : [0..4]; // current state:
s : [0..5]; // current state:
<> s=0 -> 4 : (s'=1) + 4 : (s'=2);
[alpha] s=1 -> 1 : (s'=0);
[beta] s=1 -> 0.3 : (s'=2) + 0.7 : (s'=1);
[beta] s=1 -> 0.3 : (s'=5) + 0.7 : (s'=1);
<> s=5 -> 1 : (s'=2);
[gamma] s=2 -> 1 : (s'=1);
[delta] s=2 -> 0.5 : (s'=2) + 0.5 : (s'=3);
<> s=3 -> 1 : (s'=4);
@ -36,5 +37,6 @@ endrewards
rewards "rew3"
s=0 : 7;
[delta] s=2 : 1;
[gamma] s=4 : 100;
[gamma] s=2 : 100;
[lambda] s=4 : 27;
endrewards

2
src/storm/modelchecker/csl/SparseMarkovAutomatonCslModelChecker.cpp

@ -29,7 +29,7 @@ namespace storm {
template<typename SparseMarkovAutomatonModelType>
bool SparseMarkovAutomatonCslModelChecker<SparseMarkovAutomatonModelType>::canHandle(CheckTask<storm::logic::Formula, ValueType> const& checkTask) const {
storm::logic::Formula const& formula = checkTask.getFormula();
if(formula.isInFragment(storm::logic::csl().setGloballyFormulasAllowed(false).setNextFormulasAllowed(false).setRewardOperatorsAllowed(true).setReachabilityRewardFormulasAllowed(true).setTimeAllowed(true).setLongRunAverageProbabilitiesAllowed(true).setLongRunAverageRewardFormulasAllowed(true))) {
if(formula.isInFragment(storm::logic::csl().setGloballyFormulasAllowed(false).setNextFormulasAllowed(false).setRewardOperatorsAllowed(true).setReachabilityRewardFormulasAllowed(true).setTotalRewardFormulasAllowed(true).setTimeAllowed(true).setLongRunAverageProbabilitiesAllowed(true).setLongRunAverageRewardFormulasAllowed(true))) {
return true;
} else {
// Check whether we consider a multi-objective formula

2
src/test/storm/modelchecker/CtmcCslModelCheckerTest.cpp

@ -384,7 +384,7 @@ namespace {
EXPECT_NEAR(this->parseNumber("23/8"), this->getQuantitativeResultAtInitialState(model, result), this->precision());
result = checker->check(this->env(), tasks[1]);
EXPECT_TRUE(storm::utility::isInfinity(this->getQuantitativeResultAtInitialState(model, result), this->precision()));
EXPECT_TRUE(storm::utility::isInfinity(this->getQuantitativeResultAtInitialState(model, result)));
}
}

38
src/test/storm/modelchecker/MarkovAutomatonCslModelCheckerTest.cpp

@ -135,11 +135,12 @@ namespace {
template <typename MT = typename TestType::ModelType>
typename std::enable_if<std::is_same<MT, SymbolicModelType>::value, std::shared_ptr<storm::modelchecker::AbstractModelChecker<MT>>>::type
createModelChecker(std::shared_ptr<MT> const& model) const {
if (TestType::engine == storm::settings::modules::CoreSettings::Engine::Hybrid) {
return std::make_shared<storm::modelchecker::HybridMarkovAutomatonCslModelChecker<SymbolicModelType>>(*model);
} else if (TestType::engine == storm::settings::modules::CoreSettings::Engine::Dd) {
return std::make_shared<storm::modelchecker::SymbolicMarkovAutomatonCslModelChecker<SymbolicModelType>>(*model);
}
// if (TestType::engine == storm::settings::modules::CoreSettings::Engine::Hybrid) {
// return std::make_shared<storm::modelchecker::HybridMarkovAutomatonCslModelChecker<SymbolicModelType>>(*model);
// } else if (TestType::engine == storm::settings::modules::CoreSettings::Engine::Dd) {
// return std::make_shared<storm::modelchecker::SymbolicMarkovAutomatonCslModelChecker<SymbolicModelType>>(*model);
// }
return nullptr;
}
bool getQualitativeResultAtInitialState(std::shared_ptr<storm::models::Model<ValueType>> const& model, std::unique_ptr<storm::modelchecker::CheckResult>& result) {
@ -161,7 +162,8 @@ namespace {
if (isSparseModel()) {
return std::make_unique<storm::modelchecker::ExplicitQualitativeCheckResult>(model->template as<SparseModelType>()->getInitialStates());
} else {
return std::make_unique<storm::modelchecker::SymbolicQualitativeCheckResult<TestType::ddType>>(model->template as<SymbolicModelType>()->getReachableStates(), model->template as<SymbolicModelType>()->getInitialStates());
// return std::make_unique<storm::modelchecker::SymbolicQualitativeCheckResult<TestType::ddType>>(model->template as<SymbolicModelType>()->getReachableStates(), model->template as<SymbolicModelType>()->getInitialStates());
return nullptr;
}
}
};
@ -170,7 +172,7 @@ namespace {
SparseDoubleValueIterationEnvironment,
SparseDoubleIntervalIterationEnvironment,
SparseRationalPolicyIterationEnvironment,
SparseRationalRationalSearchEnvironment,
SparseRationalRationalSearchEnvironment
> TestingTypes;
TYPED_TEST_CASE(MarkovAutomatonCslModelCheckerTest, TestingTypes);
@ -196,8 +198,10 @@ namespace {
result = checker->check(this->env(), tasks[1]);
EXPECT_NEAR(this->parseNumber("2/3"), this->getQuantitativeResultAtInitialState(model, result), this->precision());
result = checker->check(this->env(), tasks[2]);
EXPECT_NEAR(this->parseNumber("0.455504"), this->getQuantitativeResultAtInitialState(model, result), this->precision());
if (!storm::utility::isZero(this->precision())) {
result = checker->check(this->env(), tasks[2]);
EXPECT_NEAR(this->parseNumber("0.455504"), this->getQuantitativeResultAtInitialState(model, result), this->precision());
}
}
@ -214,11 +218,13 @@ namespace {
auto checker = this->createModelChecker(model);
std::unique_ptr<storm::modelchecker::CheckResult> result;
result = checker->check(this->env(), tasks[0]);
EXPECT_NEAR(this->parseNumber("0.6321205588"), this->getQuantitativeResultAtInitialState(model, result), this->precision());
if (!storm::utility::isZero(this->precision())) {
result = checker->check(this->env(), tasks[0]);
EXPECT_NEAR(this->parseNumber("0.6321205588"), this->getQuantitativeResultAtInitialState(model, result), this->precision());
result = checker->check(this->env(), tasks[1]);
EXPECT_NEAR(this->parseNumber("0.727468207"), this->getQuantitativeResultAtInitialState(model, result), this->precision());
result = checker->check(this->env(), tasks[1]);
EXPECT_NEAR(this->parseNumber("0.727468207"), this->getQuantitativeResultAtInitialState(model, result), this->precision());
}
}
TYPED_TEST(MarkovAutomatonCslModelCheckerTest, simple2) {
@ -230,11 +236,11 @@ namespace {
formulasString += "; R{\"rew2\"}min=? [C]";
formulasString += "; R{\"rew3\"}min=? [C]";
auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR "/ma/simple2.nm", formulasString);
auto modelFormulas = this->buildModelFormulas(STORM_TEST_RESOURCES_DIR "/ma/simple2.ma", formulasString);
auto model = std::move(modelFormulas.first);
auto tasks = this->getTasks(modelFormulas.second);
EXPECT_EQ(5ul, model->getNumberOfStates());
EXPECT_EQ(8ul, model->getNumberOfTransitions());
EXPECT_EQ(6ul, model->getNumberOfStates());
EXPECT_EQ(11ul, model->getNumberOfTransitions());
ASSERT_EQ(model->getType(), storm::models::ModelType::MarkovAutomaton);
auto checker = this->createModelChecker(model);
std::unique_ptr<storm::modelchecker::CheckResult> result;

Loading…
Cancel
Save