Storm 1.14.0.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 // Intentionally left empty.
10}
11
12template<typename ValueType, typename ConstantType>
13std::vector<std::pair<Assumption, AssumptionStatus>> AssumptionMaker<ValueType, ConstantType>::createAndCheckAssumptions(
14 uint_fast64_t val1, uint_fast64_t val2, std::shared_ptr<Order> order, storage::ParameterRegion<ValueType> region) const {
15 auto vec1 = std::vector<ConstantType>();
16 auto vec2 = std::vector<ConstantType>();
17 return createAndCheckAssumptions(val1, val2, order, region, vec1, vec2);
18}
19
20template<typename ValueType, typename ConstantType>
21std::vector<std::pair<Assumption, AssumptionStatus>> AssumptionMaker<ValueType, ConstantType>::createAndCheckAssumptions(
22 uint_fast64_t val1, uint_fast64_t val2, std::shared_ptr<Order> order, storage::ParameterRegion<ValueType> region, std::vector<ConstantType> const minValues,
23 std::vector<ConstantType> const maxValues) const {
24 std::vector<std::pair<Assumption, AssumptionStatus>> result;
25 STORM_LOG_INFO("Creating assumptions for " << val1 << " and " << val2);
26 STORM_LOG_ASSERT(order->compare(val1, val2) == Order::UNKNOWN, "Expected the given pair to indeed be unordered.");
27 auto assumption = createAndCheckAssumption(val1, val2, AssumptionRelation::Greater, order, region, minValues, maxValues);
28 if (assumption.second != AssumptionStatus::INVALID) {
29 result.push_back(assumption);
30 if (assumption.second == AssumptionStatus::VALID) {
32 createAndCheckAssumption(val2, val1, AssumptionRelation::Greater, order, region, minValues, maxValues).second != AssumptionStatus::VALID &&
33 createAndCheckAssumption(val1, val2, AssumptionRelation::Equal, order, region, minValues, maxValues).second != AssumptionStatus::VALID,
34 "At most one of the three candidate assumptions may be valid.");
35 STORM_LOG_INFO("Assumption " << assumption.first << "is valid\n");
36 return result;
37 }
38 }
39 STORM_LOG_ASSERT(order->compare(val1, val2) == Order::UNKNOWN, "Expected the given pair to indeed be unordered.");
40 assumption = createAndCheckAssumption(val2, val1, AssumptionRelation::Greater, order, region, minValues, maxValues);
41 if (assumption.second != AssumptionStatus::INVALID) {
42 if (assumption.second == AssumptionStatus::VALID) {
43 result.clear();
44 result.push_back(assumption);
46 createAndCheckAssumption(val1, val2, AssumptionRelation::Equal, order, region, minValues, maxValues).second != AssumptionStatus::VALID,
47 "At most one of the three candidate assumptions may be valid.");
48 STORM_LOG_INFO("Assumption " << assumption.first << "is valid\n");
49 return result;
50 }
51 result.push_back(assumption);
52 }
53 STORM_LOG_ASSERT(order->compare(val1, val2) == Order::UNKNOWN, "Expected the given pair to indeed be unordered.");
54 assumption = createAndCheckAssumption(val1, val2, AssumptionRelation::Equal, order, region, minValues, maxValues);
55 if (assumption.second != AssumptionStatus::INVALID) {
56 if (assumption.second == AssumptionStatus::VALID) {
57 result.clear();
58 result.push_back(assumption);
59 STORM_LOG_INFO("Assumption " << assumption.first << "is valid\n");
60 return result;
61 }
62 result.push_back(assumption);
63 }
64 STORM_LOG_ASSERT(order->compare(val1, val2) == Order::UNKNOWN, "Expected the given pair to indeed be unordered.");
65 STORM_LOG_INFO("None of the assumptions is valid, number of possible assumptions: " << result.size() << '\n');
66 return result;
67}
68
69template<typename ValueType, typename ConstantType>
70void AssumptionMaker<ValueType, ConstantType>::initializeCheckingOnSamples(Environment const& env, std::shared_ptr<logic::Formula const> formula,
71 std::shared_ptr<models::sparse::Dtmc<ValueType>> model,
72 storage::ParameterRegion<ValueType> region, uint_fast64_t numberOfSamples) {
73 assumptionChecker.initializeCheckingOnSamples(env, formula, model, region, numberOfSamples);
74}
75
76template<typename ValueType, typename ConstantType>
77void AssumptionMaker<ValueType, ConstantType>::setSampleValues(std::vector<std::vector<ConstantType>> const& samples) {
78 assumptionChecker.setSampleValues(samples);
79}
80
81template<typename ValueType, typename ConstantType>
82std::pair<Assumption, AssumptionStatus> AssumptionMaker<ValueType, ConstantType>::createAndCheckAssumption(
83 uint_fast64_t val1, uint_fast64_t val2, AssumptionRelation relationType, std::shared_ptr<Order> order, storage::ParameterRegion<ValueType> region,
84 std::vector<ConstantType> const minValues, std::vector<ConstantType> const maxValues) const {
85 STORM_LOG_ASSERT(val1 != val2, "An assumption must relate two distinct states.");
86 Assumption assumption{val1, val2, relationType};
87 AssumptionStatus validationResult = assumptionChecker.validateAssumption(assumption, order, region, minValues, maxValues);
88 return {assumption, validationResult};
89}
90
93} // namespace analysis
94} // namespace storm
void setSampleValues(std::vector< std::vector< ConstantType > > const &samples)
Sets the sample values to the given vector.
std::vector< std::pair< Assumption, 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.
void initializeCheckingOnSamples(Environment const &env, 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.
AssumptionMaker(storage::SparseMatrix< ValueType > matrix)
Constructs AssumptionMaker based on the matrix of the model.
This class represents a discrete-time Markov chain.
Definition Dtmc.h:16
A class that holds a possibly non-square matrix in the compressed row storage format.
#define STORM_LOG_INFO(message)
Definition logging.h:34
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
AssumptionStatus
Constants for status of assumption.
AssumptionRelation
The relation a candidate assumption states between two states.
Definition Assumption.h:14
A candidate relation between two states of a reachability order: either state1 > state2 (Greater) or ...
Definition Assumption.h:20