Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
PermissiveSchedulers.cpp
Go to the documentation of this file.
1
3
10#include "storm/utility/graph.h"
13
14namespace storm {
15namespace ps {
16
17template<typename RM>
18boost::optional<SubMDPPermissiveScheduler<RM>> computePermissiveSchedulerViaMILP(storm::models::sparse::Mdp<double, RM> const& mdp,
21 STORM_LOG_ASSERT(safeProp.getSubformula().isEventuallyFormula(), "No eventually formula.");
22 auto backwardTransitions = mdp.getBackwardTransitions();
23 storm::storage::BitVector goalstates =
24 propMC.check(safeProp.getSubformula().asEventuallyFormula().getSubformula())->asExplicitQualitativeCheckResult().getTruthValuesVector();
25 goalstates = storm::utility::graph::performProb1A(mdp, backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates);
26 storm::storage::BitVector sinkstates =
27 storm::utility::graph::performProb0A(backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates);
28
29 auto solver = storm::utility::solver::getLpSolver<double>("Gurobi", storm::solver::LpSolverTypeSelection::Gurobi);
31 STORM_LOG_THROW(!storm::logic::isStrict(safeProp.getComparisonType()), storm::exceptions::NotImplementedException, "Strict bounds are not supported");
33 // comp.dumpLpToFile("milpdump.lp");
34 std::cout << "Found Solution: " << (comp.foundSolution() ? "yes" : "no") << '\n';
35 if (comp.foundSolution()) {
36 return boost::optional<SubMDPPermissiveScheduler<RM>>(comp.getScheduler());
37 } else {
38 return boost::optional<SubMDPPermissiveScheduler<RM>>();
39 }
40}
41
42template<typename RM>
43boost::optional<SubMDPPermissiveScheduler<RM>> computePermissiveSchedulerViaMC(std::shared_ptr<storm::models::sparse::Mdp<double, RM>> mdp,
45
46template<typename RM>
47boost::optional<SubMDPPermissiveScheduler<RM>> computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp<double, RM> const& mdp,
50 STORM_LOG_ASSERT(safeProp.getSubformula().isEventuallyFormula(), "No eventually formula.");
51 auto backwardTransitions = mdp.getBackwardTransitions();
52 storm::storage::BitVector goalstates =
53 propMC.check(safeProp.getSubformula().asEventuallyFormula().getSubformula())->asExplicitQualitativeCheckResult().getTruthValuesVector();
54 goalstates = storm::utility::graph::performProb1A(mdp, backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates);
55 storm::storage::BitVector sinkstates =
56 storm::utility::graph::performProb0A(backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates);
57
58 std::shared_ptr<storm::expressions::ExpressionManager> expressionManager = std::make_shared<storm::expressions::ExpressionManager>();
59 auto solver = storm::utility::solver::getSmtSolver(*expressionManager);
61 STORM_LOG_THROW(!storm::logic::isStrict(safeProp.getComparisonType()), storm::exceptions::NotImplementedException, "Strict bounds are not supported");
63 if (comp.foundSolution()) {
64 return boost::optional<SubMDPPermissiveScheduler<RM>>(comp.getScheduler());
65 } else {
66 return boost::optional<SubMDPPermissiveScheduler<RM>>();
67 }
68 return boost::none;
69}
70
71template boost::optional<SubMDPPermissiveScheduler<>> computePermissiveSchedulerViaMILP(storm::models::sparse::Mdp<double> const& mdp,
73template boost::optional<SubMDPPermissiveScheduler<>> computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp<double> const& mdp,
75
76} // namespace ps
77} // namespace storm
EventuallyFormula & asEventuallyFormula()
Definition Formula.cpp:333
virtual bool isEventuallyFormula() const
Definition Formula.cpp:88
ComparisonType getComparisonType() const
ValueType getThresholdAs() const
Formula const & getSubformula() const
Formula const & getSubformula() const
virtual std::unique_ptr< CheckResult > check(Environment const &env, CheckTask< storm::logic::Formula, SolutionType > const &checkTask)
Checks the provided formula.
This class represents a (discrete-time) Markov decision process.
Definition Mdp.h:14
storm::storage::SparseMatrix< ValueType > getBackwardTransitions() const
Retrieves the backward transition relation of the model, i.e.
Definition Model.cpp:152
SubMDPPermissiveScheduler< RM > getScheduler() const override
void calculatePermissiveScheduler(bool lowerBound, double boundary) override
SubMDPPermissiveScheduler< RM > getScheduler() const override
void calculatePermissiveScheduler(bool lowerBound, double boundary) override
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
size_t size() const
Retrieves the number of bits this bit vector can store.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
bool isLowerBound(ComparisonType t)
bool isStrict(ComparisonType t)
boost::optional< SubMDPPermissiveScheduler< RM > > computePermissiveSchedulerViaMC(std::shared_ptr< storm::models::sparse::Mdp< double, RM > > mdp, storm::logic::ProbabilityOperatorFormula const &safeProp)
boost::optional< SubMDPPermissiveScheduler< RM > > computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp< double, RM > const &mdp, storm::logic::ProbabilityOperatorFormula const &safeProp)
boost::optional< SubMDPPermissiveScheduler< RM > > computePermissiveSchedulerViaMILP(storm::models::sparse::Mdp< double, RM > const &mdp, storm::logic::ProbabilityOperatorFormula const &safeProp)
storm::storage::BitVector performProb1A(storm::models::sparse::NondeterministicModel< T, RM > const &model, storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
Computes the sets of states that have probability 1 of satisfying phi until psi under all possible re...
Definition graph.cpp:997
storm::storage::BitVector performProb0A(storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
Definition graph.cpp:749
std::unique_ptr< storm::solver::SmtSolver > getSmtSolver(storm::expressions::ExpressionManager &manager)
Definition solver.cpp:154
LabParser.cpp.
Definition cli.cpp:18