14template<
typename ValueType>
19template<
typename ValueType>
24template<
typename ValueType>
29template<
typename ValueType>
31 boost::get<map_type>(truthValues)[state] = value;
34template<
typename ValueType>
39template<
typename ValueType>
44template<
typename ValueType>
47 : truthValues(truthValues), scheduler(scheduler) {
51template<
typename ValueType>
54 : truthValues(
std::move(truthValues)), scheduler(scheduler) {
58template<
typename ValueType>
60 return std::make_unique<ExplicitQualitativeCheckResult<ValueType>>(this->truthValues);
63template<
typename ValueType>
67 "Cannot perform logical 'and' on check results of incompatible type.");
69 "Cannot perform logical 'and' on check results of incompatible type.");
73 boost::get<vector_type>(first.truthValues) &= boost::get<vector_type>(secondCheckResult.truthValues);
75 boost::get<vector_type>(first.truthValues) |= boost::get<vector_type>(secondCheckResult.truthValues);
78 std::function<bool(
bool,
bool)> function = logicalAnd ? std::function<bool(bool, bool)>([](
bool a,
bool b) {
return a && b; })
79 : std::function<bool(bool, bool)>([](bool a, bool b) {
return a || b; });
81 map_type& map1 = boost::get<map_type>(first.truthValues);
82 map_type
const& map2 = boost::get<map_type>(secondCheckResult.truthValues);
83 for (
auto& element1 : map1) {
84 auto const& keyValuePair = map2.find(element1.first);
85 STORM_LOG_THROW(keyValuePair != map2.end(), storm::exceptions::InvalidOperationException,
86 "Cannot perform logical 'and' on check results of incompatible type.");
87 element1.second = function(element1.second, keyValuePair->second);
91 for (
auto const& element2 : map2) {
92 auto const& keyValuePair = map1.find(element2.first);
93 STORM_LOG_THROW(keyValuePair != map1.end(), storm::exceptions::InvalidOperationException,
94 "Cannot perform logical 'and' on check results of incompatible type.");
99template<
typename ValueType>
101 performLogicalOperation(*
this, other,
true);
105template<
typename ValueType>
107 performLogicalOperation(*
this, other,
false);
111template<
typename ValueType>
114 return !boost::get<vector_type>(truthValues).empty();
116 for (
auto& element : boost::get<map_type>(truthValues)) {
117 if (element.second) {
125template<
typename ValueType>
128 return boost::get<vector_type>(truthValues).full();
130 for (
auto& element : boost::get<map_type>(truthValues)) {
131 if (!element.second) {
139template<
typename ValueType>
142 return boost::get<vector_type>(truthValues).getNumberOfSetBits();
145 for (
auto& element : boost::get<map_type>(truthValues)) {
146 if (element.second) {
154template<
typename ValueType>
157 return boost::get<vector_type>(truthValues).get(state);
159 map_type const& map = boost::get<map_type>(truthValues);
160 auto const& keyValuePair = map.find(state);
161 STORM_LOG_THROW(keyValuePair != map.end(), storm::exceptions::InvalidOperationException,
"Unknown key '" << state <<
"'.");
162 return keyValuePair->second;
166template<
typename ValueType>
168 return boost::get<vector_type>(truthValues);
171template<
typename ValueType>
173 return boost::get<map_type>(truthValues);
176template<
typename ValueType>
179 boost::get<vector_type>(truthValues).complement();
181 for (
auto& element : boost::get<map_type>(truthValues)) {
182 element.second = !element.second;
187template<
typename ValueType>
192template<
typename ValueType>
194 return truthValues.which() == 0;
197template<
typename ValueType>
202template<
typename ValueType>
205 vector_type const& vector = boost::get<vector_type>(truthValues);
206 bool allTrue = vector.
full();
207 bool allFalse = !allTrue && vector.
empty();
210 }
else if (allFalse) {
213 out <<
"{true, false}";
216 std::ios::fmtflags oldflags(std::cout.flags());
217 out << std::boolalpha;
219 map_type const& map = boost::get<map_type>(truthValues);
220 if (map.size() == 1) {
221 out << map.begin()->second;
224 bool allFalse =
true;
225 for (
auto const& entry : map) {
234 }
else if (allFalse) {
237 out <<
"{true, false}";
241 std::cout.flags(oldflags);
246template<
typename ValueType>
248 STORM_LOG_THROW(
filter.isExplicitQualitativeCheckResult(), storm::exceptions::InvalidOperationException,
249 "Cannot filter explicit check result with non-explicit filter.");
250 STORM_LOG_THROW(
filter.isResultForAllStates(), storm::exceptions::InvalidOperationException,
"Cannot filter check result with non-complete filter.");
256 for (
auto element : filterTruthValues) {
259 this->truthValues = newMap;
261 map_type const& map = boost::get<map_type>(truthValues);
264 for (
auto const& element : map) {
265 if (filterTruthValues.
get(element.first)) {
266 newMap.insert(element);
271 "The check result fails to contain some results referred to by the filter.");
273 this->truthValues = newMap;
277template<
typename ValueType>
279 return static_cast<bool>(scheduler);
282template<
typename ValueType>
284 this->scheduler = std::move(scheduler);
287template<
typename ValueType>
290 return *scheduler.value();
293template<
typename ValueType>
296 return *scheduler.value();
299template<
typename JsonRationalType>
301 std::optional<storm::storage::sparse::StateValuations>
const& stateValuations = std::nullopt,
302 std::optional<storm::models::sparse::StateLabeling>
const& stateLabels = std::nullopt) {
304 if (stateValuations) {
305 entry[
"s"] = stateValuations->template toJson<JsonRationalType>(
id);
311 auto labs = stateLabels->getLabelsOfState(
id);
314 json.push_back(std::move(entry));
317template<
typename ValueType>
318template<
typename JsonRationalType>
320 std::optional<storm::models::sparse::StateLabeling>
const& stateLabels)
const {
323 vector_type const& valuesAsVector = boost::get<vector_type>(truthValues);
324 for (uint64_t state = 0; state < valuesAsVector.
size(); ++state) {
325 insertJsonEntry(result, state, valuesAsVector.
get(state), stateValuations, stateLabels);
328 map_type const& valuesAsMap = boost::get<map_type>(truthValues);
329 for (
auto const& stateValue : valuesAsMap) {
330 insertJsonEntry(result, stateValue.first, stateValue.second, stateValuations, stateLabels);
339 std::optional<storm::models::sparse::StateLabeling>
const&)
const;
342 std::optional<storm::storage::sparse::StateValuations>
const&, std::optional<storm::models::sparse::StateLabeling>
const&)
const;
346 std::optional<storm::storage::sparse::StateValuations>
const&, std::optional<storm::models::sparse::StateLabeling>
const&)
const;
348 std::optional<storm::storage::sparse::StateValuations>
const&, std::optional<storm::models::sparse::StateLabeling>
const&)
const;
352 std::optional<storm::storage::sparse::StateValuations>
const&, std::optional<storm::models::sparse::StateLabeling>
const&)
const;
354 std::optional<storm::storage::sparse::StateValuations>
const&, std::optional<storm::models::sparse::StateLabeling>
const&)
const;
358 std::optional<storm::models::sparse::StateLabeling>
const&)
const;
360 std::optional<storm::storage::sparse::StateValuations>
const&, std::optional<storm::models::sparse::StateLabeling>
const&)
const;
ExplicitQualitativeCheckResult< ValueType > & asExplicitQualitativeCheckResult()
virtual bool isResultForAllStates() const
virtual bool isExplicitQualitativeCheckResult() const
virtual uint64_t count() const override
virtual bool forallTrue() const override
storm::json< JsonRationalType > toJson(std::optional< storm::storage::sparse::StateValuations > const &stateValuations=std::nullopt, std::optional< storm::models::sparse::StateLabeling > const &stateLabels=std::nullopt) const
storm::storage::Scheduler< ValueType > const & getScheduler() const
virtual bool isResultForAllStates() const override
std::map< storm::storage::sparse::state_type, bool > map_type
virtual void filter(QualitativeCheckResult const &filter) override
Filters the current result wrt.
bool operator[](storm::storage::sparse::state_type index) const
storm::storage::BitVector vector_type
virtual void complement() override
virtual bool isExplicit() const override
ExplicitQualitativeCheckResult()
virtual QualitativeCheckResult & operator&=(QualitativeCheckResult const &other) override
virtual std::unique_ptr< CheckResult > clone() const override
virtual bool hasScheduler() const override
virtual QualitativeCheckResult & operator|=(QualitativeCheckResult const &other) override
map_type const & getTruthValuesMap() const
virtual bool existsTrue() const override
void setScheduler(std::unique_ptr< storm::storage::Scheduler< ValueType > > &&scheduler)
vector_type const & getTruthValuesVector() const
virtual bool isExplicitQualitativeCheckResult() const override
virtual std::ostream & writeToStream(std::ostream &out) const override
A bit vector that is internally represented as a vector of 64-bit values.
bool full() const
Retrieves whether all bits are set in this bit vector.
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
uint64_t getNumberOfSetBits() const
Returns the number of bits that are set to true in this bit vector.
size_t size() const
Retrieves the number of bits this bit vector can store.
bool get(uint64_t index) const
Retrieves the truth value of the bit at the given index and performs a bound check.
This class defines which action is chosen in a particular state of a non-deterministic model.
#define STORM_LOG_THROW(cond, exception, message)
void insertJsonEntry(storm::json< JsonRationalType > &json, uint64_t const &id, bool value, std::optional< storm::storage::sparse::StateValuations > const &stateValuations=std::nullopt, std::optional< storm::models::sparse::StateLabeling > const &stateLabels=std::nullopt)
nlohmann::basic_json< std::map, std::vector, std::string, bool, int64_t, uint64_t, ValueType > json