Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
AssumptionMaker.cpp
Go to the documentation of this file.
2
4
5namespace storm {
6namespace analysis {
7template<typename ValueType, typename ConstantType>
9 numberOfStates = matrix.getColumnCount();
10 expressionManager = std::make_shared<expressions::ExpressionManager>(expressions::ExpressionManager());
11 for (uint_fast64_t i = 0; i < this->numberOfStates; ++i) {
12 expressionManager->declareRationalVariable(std::to_string(i));
13 }
14}
15
16template<typename ValueType, typename ConstantType>
17std::map<std::shared_ptr<expressions::BinaryRelationExpression>, AssumptionStatus> AssumptionMaker<ValueType, ConstantType>::createAndCheckAssumptions(
18 uint_fast64_t val1, uint_fast64_t val2, std::shared_ptr<Order> order, storage::ParameterRegion<ValueType> region) const {
19 auto vec1 = std::vector<ConstantType>();
20 auto vec2 = std::vector<ConstantType>();
21 return createAndCheckAssumptions(val1, val2, order, region, vec1, vec2);
22}
23
24template<typename ValueType, typename ConstantType>
25std::map<std::shared_ptr<expressions::BinaryRelationExpression>, AssumptionStatus> AssumptionMaker<ValueType, ConstantType>::createAndCheckAssumptions(
26 uint_fast64_t val1, uint_fast64_t val2, std::shared_ptr<Order> order, storage::ParameterRegion<ValueType> region, std::vector<ConstantType> const minValues,
27 std::vector<ConstantType> const maxValues) const {
28 std::map<std::shared_ptr<expressions::BinaryRelationExpression>, AssumptionStatus> result;
29 STORM_LOG_INFO("Creating assumptions for " << val1 << " and " << val2);
30 assert(order->compare(val1, val2) == Order::UNKNOWN);
31 auto assumption = createAndCheckAssumption(val1, val2, expressions::RelationType::Greater, order, region, minValues, maxValues);
32 if (assumption.second != AssumptionStatus::INVALID) {
33 result.insert(assumption);
34 if (assumption.second == AssumptionStatus::VALID) {
35 assert(createAndCheckAssumption(val2, val1, expressions::RelationType::Greater, order, region, minValues, maxValues).second !=
37 createAndCheckAssumption(val1, val2, expressions::RelationType::Equal, order, region, minValues, maxValues).second !=
39 STORM_LOG_INFO("Assumption " << assumption.first << "is valid\n");
40 return result;
41 }
42 }
43 assert(order->compare(val1, val2) == Order::UNKNOWN);
44 assumption = createAndCheckAssumption(val2, val1, expressions::RelationType::Greater, order, region, minValues, maxValues);
45 if (assumption.second != AssumptionStatus::INVALID) {
46 if (assumption.second == AssumptionStatus::VALID) {
47 result.clear();
48 result.insert(assumption);
49 assert(createAndCheckAssumption(val1, val2, expressions::RelationType::Equal, order, region, minValues, maxValues).second !=
51 STORM_LOG_INFO("Assumption " << assumption.first << "is valid\n");
52 return result;
53 }
54 result.insert(assumption);
55 }
56 assert(order->compare(val1, val2) == Order::UNKNOWN);
57 assumption = createAndCheckAssumption(val1, val2, expressions::RelationType::Equal, order, region, minValues, maxValues);
58 if (assumption.second != AssumptionStatus::INVALID) {
59 if (assumption.second == AssumptionStatus::VALID) {
60 result.clear();
61 result.insert(assumption);
62 STORM_LOG_INFO("Assumption " << assumption.first << "is valid\n");
63 return result;
64 }
65 result.insert(assumption);
66 }
67 assert(order->compare(val1, val2) == Order::UNKNOWN);
68 STORM_LOG_INFO("None of the assumptions is valid, number of possible assumptions: " << result.size() << '\n');
69 return result;
70}
71
72template<typename ValueType, typename ConstantType>
73void AssumptionMaker<ValueType, ConstantType>::initializeCheckingOnSamples(std::shared_ptr<logic::Formula const> formula,
74 std::shared_ptr<models::sparse::Dtmc<ValueType>> model,
75 storage::ParameterRegion<ValueType> region, uint_fast64_t numberOfSamples) {
76 assumptionChecker.initializeCheckingOnSamples(formula, model, region, numberOfSamples);
77}
78
79template<typename ValueType, typename ConstantType>
80void AssumptionMaker<ValueType, ConstantType>::setSampleValues(std::vector<std::vector<ConstantType>> const& samples) {
81 assumptionChecker.setSampleValues(samples);
82}
83
84template<typename ValueType, typename ConstantType>
85std::pair<std::shared_ptr<expressions::BinaryRelationExpression>, AssumptionStatus> AssumptionMaker<ValueType, ConstantType>::createAndCheckAssumption(
86 uint_fast64_t val1, uint_fast64_t val2, expressions::RelationType relationType, std::shared_ptr<Order> order, storage::ParameterRegion<ValueType> region,
87 std::vector<ConstantType> const minValues, std::vector<ConstantType> const maxValues) const {
88 assert(val1 != val2);
89 expressions::Variable var1 = expressionManager->getVariable(std::to_string(val1));
90 expressions::Variable var2 = expressionManager->getVariable(std::to_string(val2));
91 auto assumption = std::make_shared<expressions::BinaryRelationExpression>(
92 expressions::BinaryRelationExpression(*expressionManager, expressionManager->getBooleanType(), var1.getExpression().getBaseExpressionPointer(),
93 var2.getExpression().getBaseExpressionPointer(), relationType));
94 AssumptionStatus validationResult = assumptionChecker.validateAssumption(val1, val2, assumption, order, region, minValues, maxValues);
95 return std::pair<std::shared_ptr<expressions::BinaryRelationExpression>, AssumptionStatus>(assumption, validationResult);
96}
97
98template class AssumptionMaker<RationalFunction, double>;
99template class AssumptionMaker<RationalFunction, RationalNumber>;
100} // namespace analysis
101} // 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:13
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:24
AssumptionStatus
Constants for status of assumption.
RelationType
An enum type specifying the different relations applicable.