Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
AssumptionMaker.cpp
Go to the documentation of this file.
1#include "AssumptionMaker.h"
2
3namespace storm {
4namespace analysis {
5template<typename ValueType, typename ConstantType>
7 numberOfStates = matrix.getColumnCount();
8 expressionManager = std::make_shared<expressions::ExpressionManager>(expressions::ExpressionManager());
9 for (uint_fast64_t i = 0; i < this->numberOfStates; ++i) {
10 expressionManager->declareRationalVariable(std::to_string(i));
11 }
12}
13
14template<typename ValueType, typename ConstantType>
15std::map<std::shared_ptr<expressions::BinaryRelationExpression>, AssumptionStatus> AssumptionMaker<ValueType, ConstantType>::createAndCheckAssumptions(
16 uint_fast64_t val1, uint_fast64_t val2, std::shared_ptr<Order> order, storage::ParameterRegion<ValueType> region) const {
17 auto vec1 = std::vector<ConstantType>();
18 auto vec2 = std::vector<ConstantType>();
19 return createAndCheckAssumptions(val1, val2, order, region, vec1, vec2);
20}
21
22template<typename ValueType, typename ConstantType>
23std::map<std::shared_ptr<expressions::BinaryRelationExpression>, AssumptionStatus> AssumptionMaker<ValueType, ConstantType>::createAndCheckAssumptions(
24 uint_fast64_t val1, uint_fast64_t val2, std::shared_ptr<Order> order, storage::ParameterRegion<ValueType> region, std::vector<ConstantType> const minValues,
25 std::vector<ConstantType> const maxValues) const {
26 std::map<std::shared_ptr<expressions::BinaryRelationExpression>, AssumptionStatus> result;
27 STORM_LOG_INFO("Creating assumptions for " << val1 << " and " << val2);
28 assert(order->compare(val1, val2) == Order::UNKNOWN);
29 auto assumption = createAndCheckAssumption(val1, val2, expressions::RelationType::Greater, order, region, minValues, maxValues);
30 if (assumption.second != AssumptionStatus::INVALID) {
31 result.insert(assumption);
32 if (assumption.second == AssumptionStatus::VALID) {
33 assert(createAndCheckAssumption(val2, val1, expressions::RelationType::Greater, order, region, minValues, maxValues).second !=
35 createAndCheckAssumption(val1, val2, expressions::RelationType::Equal, order, region, minValues, maxValues).second !=
37 STORM_LOG_INFO("Assumption " << assumption.first << "is valid\n");
38 return result;
39 }
40 }
41 assert(order->compare(val1, val2) == Order::UNKNOWN);
42 assumption = createAndCheckAssumption(val2, val1, expressions::RelationType::Greater, order, region, minValues, maxValues);
43 if (assumption.second != AssumptionStatus::INVALID) {
44 if (assumption.second == AssumptionStatus::VALID) {
45 result.clear();
46 result.insert(assumption);
47 assert(createAndCheckAssumption(val1, val2, expressions::RelationType::Equal, order, region, minValues, maxValues).second !=
49 STORM_LOG_INFO("Assumption " << assumption.first << "is valid\n");
50 return result;
51 }
52 result.insert(assumption);
53 }
54 assert(order->compare(val1, val2) == Order::UNKNOWN);
55 assumption = createAndCheckAssumption(val1, val2, expressions::RelationType::Equal, order, region, minValues, maxValues);
56 if (assumption.second != AssumptionStatus::INVALID) {
57 if (assumption.second == AssumptionStatus::VALID) {
58 result.clear();
59 result.insert(assumption);
60 STORM_LOG_INFO("Assumption " << assumption.first << "is valid\n");
61 return result;
62 }
63 result.insert(assumption);
64 }
65 assert(order->compare(val1, val2) == Order::UNKNOWN);
66 STORM_LOG_INFO("None of the assumptions is valid, number of possible assumptions: " << result.size() << '\n');
67 return result;
68}
69
70template<typename ValueType, typename ConstantType>
71void AssumptionMaker<ValueType, ConstantType>::initializeCheckingOnSamples(std::shared_ptr<logic::Formula const> formula,
72 std::shared_ptr<models::sparse::Dtmc<ValueType>> model,
73 storage::ParameterRegion<ValueType> region, uint_fast64_t numberOfSamples) {
74 assumptionChecker.initializeCheckingOnSamples(formula, model, region, numberOfSamples);
75}
76
77template<typename ValueType, typename ConstantType>
78void AssumptionMaker<ValueType, ConstantType>::setSampleValues(std::vector<std::vector<ConstantType>> const& samples) {
79 assumptionChecker.setSampleValues(samples);
80}
81
82template<typename ValueType, typename ConstantType>
83std::pair<std::shared_ptr<expressions::BinaryRelationExpression>, AssumptionStatus> AssumptionMaker<ValueType, ConstantType>::createAndCheckAssumption(
84 uint_fast64_t val1, uint_fast64_t val2, expressions::RelationType relationType, std::shared_ptr<Order> order, storage::ParameterRegion<ValueType> region,
85 std::vector<ConstantType> const minValues, std::vector<ConstantType> const maxValues) const {
86 assert(val1 != val2);
87 expressions::Variable var1 = expressionManager->getVariable(std::to_string(val1));
88 expressions::Variable var2 = expressionManager->getVariable(std::to_string(val2));
89 auto assumption = std::make_shared<expressions::BinaryRelationExpression>(
90 expressions::BinaryRelationExpression(*expressionManager, expressionManager->getBooleanType(), var1.getExpression().getBaseExpressionPointer(),
91 var2.getExpression().getBaseExpressionPointer(), relationType));
92 AssumptionStatus validationResult = assumptionChecker.validateAssumption(val1, val2, assumption, order, region, minValues, maxValues);
93 return std::pair<std::shared_ptr<expressions::BinaryRelationExpression>, AssumptionStatus>(assumption, validationResult);
94}
95
96template class AssumptionMaker<RationalFunction, double>;
97template class AssumptionMaker<RationalFunction, RationalNumber>;
98} // namespace analysis
99} // namespace storm
void setSampleValues(std::vector< std::vector< ConstantType > > const &samples)
Sets the sample values to the given vector.
std::map< std::shared_ptr< expressions::BinaryRelationExpression >, AssumptionStatus > createAndCheckAssumptions(uint_fast64_t val1, uint_fast64_t val2, std::shared_ptr< Order > order, storage::ParameterRegion< ValueType > region) const
Creates assumptions, and checks them, only VALID and UNKNOWN assumptions are returned.
AssumptionMaker(storage::SparseMatrix< ValueType > matrix)
Constructs AssumptionMaker based on the matrix of the model.
void initializeCheckingOnSamples(std::shared_ptr< logic::Formula const > formula, std::shared_ptr< models::sparse::Dtmc< ValueType > > model, storage::ParameterRegion< ValueType > region, uint_fast64_t numberOfSamples)
Initializes the given number of sample points for a given model, formula and region.
std::shared_ptr< BaseExpression const > const & getBaseExpressionPointer() const
Retrieves a pointer to the base expression underlying this expression object.
This class is responsible for managing a set of typed variables and all expressions using these varia...
storm::expressions::Expression getExpression() const
Retrieves an expression that represents the variable.
Definition Variable.cpp:34
This class represents a discrete-time Markov chain.
Definition Dtmc.h:14
A class that holds a possibly non-square matrix in the compressed row storage format.
index_type getColumnCount() const
Returns the number of columns of the matrix.
#define STORM_LOG_INFO(message)
Definition logging.h:29
AssumptionStatus
Constants for status of assumption.
RelationType
An enum type specifying the different relations applicable.
LabParser.cpp.
Definition cli.cpp:18