Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
InformationCollector.cpp
Go to the documentation of this file.
5
6namespace storm {
7namespace jani {
8namespace detail {
10 public:
12 info = InformationObject();
13 domainSizesSum = 0;
14 domainSizesProduct = storm::utility::one<storm::RationalNumber>();
15 this->traverse(model, boost::any());
16 if (domainSizesProduct > storm::utility::convertNumber<storm::RationalNumber>(std::numeric_limits<uint64_t>::max())) {
17 STORM_LOG_WARN("Truncating the domain size as it does not fit in an unsigned 64 bit number.");
18 info.stateDomainSize = std::numeric_limits<uint64_t>::max();
19 } else {
20 info.stateDomainSize = storm::utility::convertNumber<uint64_t>(domainSizesProduct);
21 }
22 if (info.stateDomainSize > 0) {
23 info.avgVarDomainSize = storm::utility::convertNumber<double>(domainSizesSum) / storm::utility::convertNumber<double>(info.nrVariables);
24 } else {
25 info.avgVarDomainSize = 0.0;
26 }
27 return info;
28 }
29
30 virtual void traverse(Model const& model, boost::any const& data) override {
31 info.modelType = model.getModelType();
32 info.nrAutomata = model.getNumberOfAutomata();
34 }
35
36 virtual void traverse(Automaton const& automaton, boost::any const& data) override {
37 info.nrLocations += automaton.getNumberOfLocations();
38 domainSizesProduct *= storm::utility::convertNumber<storm::RationalNumber, uint64_t>(automaton.getNumberOfLocations());
39 domainSizesSum += automaton.getNumberOfLocations();
40 info.nrEdges += automaton.getNumberOfEdges();
41 ConstJaniTraverser::traverse(automaton, data);
42 }
43
44 virtual void traverse(VariableSet const& variableSet, boost::any const& data) override {
46 ConstJaniTraverser::traverse(variableSet, data);
47 }
48
49 virtual void traverse(Variable const& variable, boost::any const& data) override {
50 if (!variable.isTransient()) {
51 // Only consider domain size for non-transient variables
52 auto const& type = variable.getType();
53 if (type.isBasicType() && type.asBasicType().isBooleanType()) {
54 domainSizesProduct *= storm::utility::convertNumber<storm::RationalNumber, uint64_t>(2u);
55 domainSizesSum += 2;
56 } else if (type.isBoundedType() && type.asBoundedType().isIntegerType() && type.asBoundedType().hasLowerBound() &&
57 type.asBoundedType().hasUpperBound() && !type.asBoundedType().getLowerBound().containsVariables() &&
58 !type.asBoundedType().getUpperBound().containsVariables()) {
59 auto size = type.asBoundedType().getUpperBound().evaluateAsInt() - type.asBoundedType().getLowerBound().evaluateAsInt();
60 domainSizesProduct *= storm::utility::convertNumber<storm::RationalNumber, uint64_t>(size);
61 domainSizesSum += size;
62 } else {
63 domainSizesProduct = storm::utility::zero<storm::RationalNumber>(); // i.e. unknown
64 }
65 }
66 ConstJaniTraverser::traverse(variable, data);
67 }
68
69 private:
71 uint64_t domainSizesSum;
72 storm::RationalNumber domainSizesProduct; // Use infinite precision to detect overflows.
73};
74
75} // namespace detail
76
77InformationObject::InformationObject() : nrVariables(0), nrAutomata(0), nrEdges(0), nrLocations(0), stateDomainSize(1), avgVarDomainSize(0.0) {
78 // Intentionally left empty
79}
80
84} // namespace jani
85} // namespace storm
uint64_t getNumberOfEdges() const
Retrieves the number of edges.
uint64_t getNumberOfLocations() const
Retrieves the number of locations.
virtual void traverse(Model const &model, boost::any const &data)
ModelType const & getModelType() const
Retrieves the type of the model.
Definition Model.cpp:121
std::size_t getNumberOfAutomata() const
Retrieves the number of automata in this model.
Definition Model.cpp:914
JaniType & getType()
Definition Variable.cpp:67
bool isTransient() const
Definition Variable.cpp:42
uint64_t getNumberOfNontransientVariables() const
InformationObject collect(Model const &model)
virtual void traverse(Automaton const &automaton, boost::any const &data) override
virtual void traverse(Variable const &variable, boost::any const &data) override
virtual void traverse(VariableSet const &variableSet, boost::any const &data) override
virtual void traverse(Model const &model, boost::any const &data) override
#define STORM_LOG_WARN(message)
Definition logging.h:30
InformationObject collectModelInformation(Model const &model)
LabParser.cpp.
Definition cli.cpp:18
double avgVarDomainSize
The size of the domain of the states (i.e., the product of the range of all variables times the numbe...
uint64_t nrVariables
The type of the model.
uint64_t nrLocations
The number of edges in the model.
uint64_t nrAutomata
The number of non-transient variables in the model.
uint64_t nrEdges
The number of automata in the model.
uint64_t stateDomainSize
The numer of all locations of all automata of the model.