Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SparseDerivativeInstantiationModelChecker.h
Go to the documentation of this file.
1#ifndef STORM_DERIVATIVEEVALUATIONHELPER_H
2#define STORM_DERIVATIVEEVALUATIONHELPER_H
3
4#include <cstdint>
5#include <map>
15
16namespace storm {
17namespace derivative {
18template<typename FunctionType, typename ConstantType>
20 public:
26 // Intentionally left empty.
27 }
29
39
45 std::unique_ptr<modelchecker::ExplicitQuantitativeCheckResult<ConstantType>> check(
48 boost::optional<std::vector<ConstantType>> const& valueVector = boost::none);
49
50 uint64_t getInitialState() {
51 return initialStateEqSystem;
52 }
53
54 private:
55 // TODO it is not good that this model is not a reference. (but we reduce to state based rewards in this code.)
57 std::unique_ptr<modelchecker::CheckTask<storm::logic::Formula, FunctionType>> currentCheckTask;
58 // store the current formula. Note that currentCheckTask only stores a reference to the formula.
59 std::shared_ptr<storm::logic::Formula const> currentFormula;
60
61 std::set<typename utility::parametric::VariableType<FunctionType>::type> parameters;
62 std::map<typename utility::parametric::VariableType<FunctionType>::type, std::unique_ptr<storm::solver::LinearEquationSolver<ConstantType>>>
63 linearEquationSolvers;
64 std::vector<std::pair<typename storm::storage::SparseMatrix<ConstantType>::iterator, ConstantType*>> matrixMappingUnderived;
65 std::map<typename utility::parametric::VariableType<FunctionType>::type,
66 std::vector<std::pair<typename storm::storage::SparseMatrix<ConstantType>::iterator, ConstantType*>>>
67 matrixMappingsDerived;
68 std::unordered_map<FunctionType, ConstantType> functionsUnderived;
69 std::map<typename utility::parametric::VariableType<FunctionType>::type, std::unordered_map<FunctionType, ConstantType>> functionsDerived;
70 storage::SparseMatrix<FunctionType> constrainedMatrixEquationSystem;
71 storage::SparseMatrix<ConstantType> constrainedMatrixInstantiated;
72 std::unique_ptr<std::map<typename utility::parametric::VariableType<FunctionType>::type, storage::SparseMatrix<FunctionType>>> deltaConstrainedMatrices;
73 std::unique_ptr<std::map<typename utility::parametric::VariableType<FunctionType>::type, storage::SparseMatrix<ConstantType>>>
74 deltaConstrainedMatricesInstantiated;
75 std::unique_ptr<std::map<typename utility::parametric::VariableType<FunctionType>::type, std::vector<FunctionType>>> derivedOutputVecs;
76
77 // next states: states that have a relevant successor
79 uint_fast64_t initialStateEqSystem;
80 uint_fast64_t initialStateModel;
81
82 void initializeInstantiatedMatrix(storage::SparseMatrix<FunctionType>& matrix, storage::SparseMatrix<ConstantType>& matrixInstantiated,
83 std::vector<std::pair<typename storm::storage::SparseMatrix<ConstantType>::iterator, ConstantType*>>& matrixMapping,
84 std::unordered_map<FunctionType, ConstantType>& functions);
86
87 utility::Stopwatch instantiationWatch;
88 utility::Stopwatch approximationWatch;
89 utility::Stopwatch generalSetupWatch;
90};
91
92template<typename ValueType>
94 public:
95 SignedGradientDescentTerminationCondition(uint64_t initialState) : initialState(initialState) {};
96
97 bool terminateNow(std::function<ValueType(uint64_t const&)> const& valueGetter, solver::SolverGuarantee const& guarantee) const {
98 if (guarantee == solver::SolverGuarantee::GreaterOrEqual && valueGetter(initialState) > utility::convertNumber<ValueType>(1e-6)) {
99 return true;
100 }
101 if (guarantee == solver::SolverGuarantee::LessOrEqual && valueGetter(initialState) < utility::convertNumber<ValueType>(-1e-6)) {
102 return true;
103 }
104 return false;
105 };
106 bool requiresGuarantee(solver::SolverGuarantee const& guarantee) const {
108 }
109
110 private:
111 uint64_t initialState;
112};
113} // namespace derivative
114} // namespace storm
115
116#endif // STORM_DERIVATIVEEVALUATIONHELPER_H
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:14
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
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:14
std::map< typename VariableType< FunctionType >::type, typename CoefficientType< FunctionType >::type > Valuation
Definition parametric.h:41
LabParser.cpp.
Definition cli.cpp:18