Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
PermissiveSchedulers.cpp
Go to the documentation of this file.
1
3
11#include "storm/utility/graph.h"
14
15namespace storm {
16namespace ps {
17
18template<typename RM>
19boost::optional<SubMDPPermissiveScheduler<RM>> computePermissiveSchedulerViaMILP(storm::Environment const& env,
23 STORM_LOG_ASSERT(safeProp.getSubformula().isEventuallyFormula(), "No eventually formula.");
24 auto backwardTransitions = mdp.getBackwardTransitions();
26 ->template asExplicitQualitativeCheckResult<double>()
27 .getTruthValuesVector();
28 goalstates = storm::utility::graph::performProb1A(mdp, backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates);
29 storm::storage::BitVector sinkstates =
30 storm::utility::graph::performProb0A(backwardTransitions, storm::storage::BitVector(goalstates.size(), true), goalstates);
31
32 auto solver = storm::utility::solver::getLpSolver<double>(env, "Gurobi", storm::solver::LpSolverTypeSelection::Gurobi);
34 STORM_LOG_THROW(!storm::logic::isStrict(safeProp.getComparisonType()), storm::exceptions::NotImplementedException, "Strict bounds are not supported.");
36 // comp.dumpLpToFile("milpdump.lp");
37 std::cout << "Found Solution: " << (comp.foundSolution() ? "yes" : "no") << '\n';
38 if (comp.foundSolution()) {
39 return boost::optional<SubMDPPermissiveScheduler<RM>>(comp.getScheduler());
40 } else {
41 return boost::optional<SubMDPPermissiveScheduler<RM>>();
42 }
43}
44
45template<typename RM>
46boost::optional<SubMDPPermissiveScheduler<RM>> computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp<double, RM> const& mdp,
49 STORM_LOG_ASSERT(safeProp.getSubformula().isEventuallyFormula(), "No eventually formula.");
50 auto backwardTransitions = mdp.getBackwardTransitions();
52 ->template asExplicitQualitativeCheckResult<double>()
53 .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::Environment const& env,
74template boost::optional<SubMDPPermissiveScheduler<>> computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp<double> const& mdp,
76
77} // namespace ps
78} // namespace storm
EventuallyFormula & asEventuallyFormula()
Definition Formula.cpp:341
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:13
storm::storage::SparseMatrix< ValueType > getBackwardTransitions() const
Retrieves the backward transition relation of the model, i.e.
Definition Model.cpp:158
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:16
size_t size() const
Retrieves the number of bits this bit vector can store.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:28
bool isLowerBound(ComparisonType t)
bool isStrict(ComparisonType t)
boost::optional< SubMDPPermissiveScheduler< RM > > computePermissiveSchedulerViaSMT(storm::models::sparse::Mdp< double, RM > const &mdp, storm::logic::ProbabilityOperatorFormula const &safeProp)
boost::optional< SubMDPPermissiveScheduler< RM > > computePermissiveSchedulerViaMILP(storm::Environment const &env, 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:981
storm::storage::BitVector performProb0A(storm::storage::SparseMatrix< T > const &backwardTransitions, storm::storage::BitVector const &phiStates, storm::storage::BitVector const &psiStates)
Definition graph.cpp:733
std::unique_ptr< storm::solver::SmtSolver > getSmtSolver(storm::expressions::ExpressionManager &manager)
Definition solver.cpp:189
std::unique_ptr< storm::solver::LpSolver< ValueType > > getLpSolver(storm::Environment const &env, std::string const &name, storm::solver::LpSolverTypeSelection solvType)
Definition solver.cpp:146