Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseDerivativeInstantiationModelChecker.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <map>
13
14namespace storm {
15namespace derivative {
16template<typename FunctionType, typename ConstantType>
18 public:
24 // Intentionally left empty.
25 }
27
37
43 std::unique_ptr<modelchecker::ExplicitQuantitativeCheckResult<ConstantType>> check(
46 boost::optional<std::vector<ConstantType>> const& valueVector = boost::none);
47
48 uint64_t getInitialState() {
49 return initialStateEqSystem;
50 }
51
52 private:
53 // TODO it is not good that this model is not a reference. (but we reduce to state based rewards in this code.)
55 std::unique_ptr<modelchecker::CheckTask<storm::logic::Formula, FunctionType>> currentCheckTask;
56 // store the current formula. Note that currentCheckTask only stores a reference to the formula.
57 std::shared_ptr<storm::logic::Formula const> currentFormula;
58
59 std::set<typename utility::parametric::VariableType<FunctionType>::type> parameters;
60 std::map<typename utility::parametric::VariableType<FunctionType>::type, std::unique_ptr<storm::solver::LinearEquationSolver<ConstantType>>>
61 linearEquationSolvers;
62 std::vector<std::pair<typename storm::storage::SparseMatrix<ConstantType>::iterator, ConstantType*>> matrixMappingUnderived;
63 std::map<typename utility::parametric::VariableType<FunctionType>::type,
64 std::vector<std::pair<typename storm::storage::SparseMatrix<ConstantType>::iterator, ConstantType*>>>
65 matrixMappingsDerived;
66 std::unordered_map<FunctionType, ConstantType> functionsUnderived;
67 std::map<typename utility::parametric::VariableType<FunctionType>::type, std::unordered_map<FunctionType, ConstantType>> functionsDerived;
68 storage::SparseMatrix<FunctionType> constrainedMatrixEquationSystem;
69 storage::SparseMatrix<ConstantType> constrainedMatrixInstantiated;
70 std::unique_ptr<std::map<typename utility::parametric::VariableType<FunctionType>::type, storage::SparseMatrix<FunctionType>>> deltaConstrainedMatrices;
71 std::unique_ptr<std::map<typename utility::parametric::VariableType<FunctionType>::type, storage::SparseMatrix<ConstantType>>>
72 deltaConstrainedMatricesInstantiated;
73 std::unique_ptr<std::map<typename utility::parametric::VariableType<FunctionType>::type, std::vector<FunctionType>>> derivedOutputVecs;
74
75 // next states: states that have a relevant successor
77 uint_fast64_t initialStateEqSystem;
78 uint_fast64_t initialStateModel;
79
80 void initializeInstantiatedMatrix(storage::SparseMatrix<FunctionType>& matrix, storage::SparseMatrix<ConstantType>& matrixInstantiated,
81 std::vector<std::pair<typename storm::storage::SparseMatrix<ConstantType>::iterator, ConstantType*>>& matrixMapping,
82 std::unordered_map<FunctionType, ConstantType>& functions);
83
84 utility::Stopwatch instantiationWatch;
85 utility::Stopwatch approximationWatch;
86 utility::Stopwatch generalSetupWatch;
87};
88
89template<typename ValueType>
91 public:
92 SignedGradientDescentTerminationCondition(uint64_t initialState) : initialState(initialState) {}
93
94 bool terminateNow(std::function<ValueType(uint64_t const&)> const& valueGetter, solver::SolverGuarantee const& guarantee) const {
95 if (guarantee == solver::SolverGuarantee::GreaterOrEqual && valueGetter(initialState) > utility::convertNumber<ValueType>(1e-6)) {
96 return true;
97 }
98 if (guarantee == solver::SolverGuarantee::LessOrEqual && valueGetter(initialState) < utility::convertNumber<ValueType>(-1e-6)) {
99 return true;
100 }
101 return false;
102 }
103 bool requiresGuarantee(solver::SolverGuarantee const& guarantee) const {
105 }
106
107 private:
108 uint64_t initialState;
109};
110} // namespace derivative
111} // namespace storm
bool terminateNow(std::function< ValueType(uint64_t const &)> const &valueGetter, solver::SolverGuarantee const &guarantee) const
bool requiresGuarantee(solver::SolverGuarantee const &guarantee) const
Retrieves whether the termination criterion requires the given guarantee in order to decide terminati...
std::unique_ptr< modelchecker::ExplicitQuantitativeCheckResult< ConstantType > > check(Environment const &env, storm::utility::parametric::Valuation< FunctionType > const &valuation, typename utility::parametric::VariableType< FunctionType >::type const &parameter, boost::optional< std::vector< ConstantType > > const &valueVector=boost::none)
check calculates the deriative of the model w.r.t.
void specifyFormula(Environment const &env, modelchecker::CheckTask< logic::Formula, FunctionType > const &checkTask)
specifyFormula specifies a CheckTask.
SparseDerivativeInstantiationModelChecker(storm::models::sparse::Dtmc< FunctionType > const &model)
Instantiates a new SparseDerivativeInstantiationModelChecker.
This class represents a discrete-time Markov chain.
Definition Dtmc.h:16
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
A class that holds a possibly non-square matrix in the compressed row storage format.
std::vector< MatrixEntry< index_type, value_type > >::iterator iterator
A class that provides convenience operations to display run times.
Definition Stopwatch.h:13
std::map< typename VariableType< FunctionType >::type, typename CoefficientType< FunctionType >::type > Valuation
Definition parametric.h:43
TargetType convertNumber(SourceType const &number)