Symmetri
Loading...
Searching...
No Matches
utilities.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <algorithm>
6
7#include "symmetri/types.h"
8
9namespace symmetri {
10
26template <typename T>
27bool MarkingEquality(const std::vector<T>& m1, const std::vector<T>& m2) {
28 std::vector<T> m1_sorted = m1;
29 std::vector<T> m2_sorted = m2;
30 std::sort(m1_sorted.begin(), m1_sorted.end());
31 std::sort(m2_sorted.begin(), m2_sorted.end());
32 return m1_sorted == m2_sorted;
33}
34
50template <typename T>
51bool MarkingReached(const std::vector<T>& marking,
52 const std::vector<T>& goal_marking) {
53 if (goal_marking.empty()) {
54 return false;
55 }
56 auto unique = goal_marking;
57 std::sort(unique.begin(), unique.end());
58 auto last = std::unique(unique.begin(), unique.end());
59 unique.erase(last, unique.end());
60
61 return std::all_of(std::begin(unique), std::end(unique), [&](const auto& p) {
62 return std::count(marking.begin(), marking.end(), p) ==
63 std::count(goal_marking.begin(), goal_marking.end(), p);
64 });
65}
66
76bool stateNetEquality(const Net& net1, const Net& net2);
77
87size_t calculateTrace(const Eventlog& log) noexcept;
88
89} // namespace symmetri
bool MarkingEquality(const std::vector< T > &m1, const std::vector< T > &m2)
Checks if the markings are exactly the same. Note that this uses a different type for Marking compare...
Definition utilities.hpp:27
bool MarkingReached(const std::vector< T > &marking, const std::vector< T > &goal_marking)
Checks if marking is at least a subset of goal_marking. Note that this uses a different type for Mark...
Definition utilities.hpp:51