Browse Source

Cleaning and support for linux platforms

tempestpy_adaptions
Sebastian Junges 4 years ago
parent
commit
bbbe178572
  1. 15
      src/storm-pomdp/analysis/JaniBeliefSupportMdpGenerator.cpp

15
src/storm-pomdp/analysis/JaniBeliefSupportMdpGenerator.cpp

@ -1,12 +1,12 @@
#include "storm-pomdp/analysis/JaniBeliefSupportMdpGenerator.h" #include "storm-pomdp/analysis/JaniBeliefSupportMdpGenerator.h"
#include "storm/storage/jani/Model.h" #include "storm/storage/jani/Model.h"
#include "storm/storage/expressions/ExpressionManager.h" #include "storm/storage/expressions/ExpressionManager.h"
#include "storm/models/symbolic/StandardRewardModel.h"
#include "storm/io/file.h" #include "storm/io/file.h"
#include "storm/api/verification.h" #include "storm/api/verification.h"
#include "storm/api/builder.h" #include "storm/api/builder.h"
#include "storm-parsers/api/properties.h" #include "storm-parsers/api/properties.h"
#include "storm/storage/SymbolicModelDescription.h" #include "storm/storage/SymbolicModelDescription.h"
#include "storm-parsers/api/model_descriptions.h"
#include "storm/modelchecker/results/CheckResult.h" #include "storm/modelchecker/results/CheckResult.h"
#include "storm/modelchecker/results/SymbolicQualitativeCheckResult.h" #include "storm/modelchecker/results/SymbolicQualitativeCheckResult.h"
@ -84,7 +84,6 @@ namespace storm {
std::string name = "s" + std::to_string(i); std::string name = "s" + std::to_string(i);
bool isInitial = pomdp.getInitialStates().get(i); bool isInitial = pomdp.getInitialStates().get(i);
stateVariables.emplace(i, &model.addVariable(jani::BooleanVariable(name, exprManager.declareBooleanVariable(name), exprManager.boolean(isInitial)))); stateVariables.emplace(i, &model.addVariable(jani::BooleanVariable(name, exprManager.declareBooleanVariable(name), exprManager.boolean(isInitial))));
} }
std::map<detail::ObsActPair, uint64_t> actionIndices; std::map<detail::ObsActPair, uint64_t> actionIndices;
@ -118,8 +117,6 @@ namespace storm {
tedge->addDestination(edgedest); tedge->addDestination(edgedest);
aut.addEdge(jani::Edge(primeloc, oaps.second, boost::none, tedge, {primeloc}, {exprManager.rational(1.0)})); aut.addEdge(jani::Edge(primeloc, oaps.second, boost::none, tedge, {primeloc}, {exprManager.rational(1.0)}));
} }
model.addAutomaton(aut); model.addAutomaton(aut);
} }
jani::Automaton obsAut("obsAut", exprManager.declareIntegerVariable("obsAut")); jani::Automaton obsAut("obsAut", exprManager.declareIntegerVariable("obsAut"));
@ -181,10 +178,10 @@ namespace storm {
template <typename ValueType> template <typename ValueType>
void JaniBeliefSupportMdpGenerator<ValueType>::verifySymbolic(bool onlyInitial) { void JaniBeliefSupportMdpGenerator<ValueType>::verifySymbolic(bool onlyInitial) {
storage::SymbolicModelDescription symdesc(model); storage::SymbolicModelDescription symdesc(model);
// This trick only works because we do not explictly check that the model is stochastic!
symdesc = symdesc.preprocess("posProb=0.1"); symdesc = symdesc.preprocess("posProb=0.1");
auto property = storm::api::parsePropertiesForJaniModel("Pmax>=1 [!\"bad\" U \"target\"]", model)[0]; auto property = storm::api::parsePropertiesForJaniModel("Pmax>=1 [!\"bad\" U \"target\"]", model)[0];
auto mdp = storm::api::buildSymbolicModel<storm::dd::DdType::Sylvan, ValueType>(symdesc, {property.getRawFormula()}); auto mdp = storm::api::buildSymbolicModel<storm::dd::DdType::Sylvan, ValueType>(symdesc, {property.getRawFormula()});
mdp->printModelInformationToStream(std::cout);
storm::Environment env; storm::Environment env;
std::unique_ptr<modelchecker::CheckResult> result = storm::api::verifyWithDdEngine(env, mdp, storm::api::createTask<ValueType>(property.getRawFormula(), onlyInitial)); std::unique_ptr<modelchecker::CheckResult> result = storm::api::verifyWithDdEngine(env, mdp, storm::api::createTask<ValueType>(property.getRawFormula(), onlyInitial));
std::unique_ptr<storm::modelchecker::CheckResult> filter; std::unique_ptr<storm::modelchecker::CheckResult> filter;
@ -200,14 +197,14 @@ namespace storm {
} }
if(result && !onlyInitial) { if(result && !onlyInitial) {
auto vars = result->asSymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>().getTruthValuesVector().getContainedMetaVariables();
auto vars = result->asSymbolicQualitativeCheckResult<storm::dd::DdType::Sylvan>().getTruthValuesVector().getContainedMetaVariables();
// TODO Export these results.
} else if (result) { } else if (result) {
initialIsWinning = result->asQualitativeCheckResult().existsTrue(); initialIsWinning = result->asQualitativeCheckResult().existsTrue();
} }
} }
template <typename ValueType>
template <typename ValueType>
bool JaniBeliefSupportMdpGenerator<ValueType>::isInitialWinning() const { bool JaniBeliefSupportMdpGenerator<ValueType>::isInitialWinning() const {
return initialIsWinning; return initialIsWinning;
} }
@ -217,8 +214,6 @@ namespace storm {
template class JaniBeliefSupportMdpGenerator<storm::RationalNumber>; template class JaniBeliefSupportMdpGenerator<storm::RationalNumber>;
template class JaniBeliefSupportMdpGenerator<storm::RationalFunction>; template class JaniBeliefSupportMdpGenerator<storm::RationalFunction>;
} }
} }
} }
Loading…
Cancel
Save