-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
106 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ build | |
install | ||
docs/html | ||
.vscode | ||
examples/flight/mermaid.html | ||
|
||
# Prerequisites | ||
*.d | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#pragma once | ||
#include "symmetri/types.h" | ||
|
||
namespace symmetri { | ||
|
||
/** | ||
* @brief Checks if the markings are exactly the same. Note that this uses a | ||
* different type for Marking compared to the Marking type used to | ||
* construct a net (an unordered map of strings). In this format the amount of | ||
* tokens in a particular place is represented by how often that place occurs in | ||
* the vector. For example: {"A","A","B"} is a marking with two tokens in place | ||
* "A" and one token in place "B". This format does not have the overhead of | ||
* mentioning all empty places. | ||
* | ||
* @tparam T | ||
* @param m1 | ||
* @param m2 | ||
* @return true | ||
* @return false | ||
*/ | ||
template <typename T> | ||
bool MarkingEquality(const std::vector<T>& m1, const std::vector<T>& m2) { | ||
auto m1_sorted = m1; | ||
auto m2_sorted = m2; | ||
std::sort(m1_sorted.begin(), m1_sorted.end()); | ||
std::sort(m2_sorted.begin(), m2_sorted.end()); | ||
return m1_sorted == m2_sorted; | ||
} | ||
|
||
/** | ||
* @brief Checks if marking is at least a subset of final_marking. Note | ||
* that this uses a different type for Marking compared to the Marking | ||
* type used to construct a net (an unordered map of strings). In this | ||
* format the amount of tokens in a particular place is represented by how often | ||
* that place occurs in the vector. For example: {"A","A","B"} is a marking with | ||
* two tokens in place "A" and one token in place "B". This format does not have | ||
* the overhead of mentioning all empty places. | ||
* | ||
* @tparam T | ||
* @param marking | ||
* @param final_marking | ||
* @return true | ||
* @return false | ||
*/ | ||
template <typename T> | ||
bool MarkingReached(const std::vector<T>& marking, | ||
const std::vector<T>& final_marking) { | ||
if (final_marking.empty()) { | ||
return false; | ||
} | ||
auto unique = final_marking; | ||
std::sort(unique.begin(), unique.end()); | ||
auto last = std::unique(unique.begin(), unique.end()); | ||
unique.erase(last, unique.end()); | ||
|
||
return std::all_of(std::begin(unique), std::end(unique), [&](const auto& p) { | ||
return std::count(marking.begin(), marking.end(), p) == | ||
std::count(final_marking.begin(), final_marking.end(), p); | ||
}); | ||
} | ||
|
||
/** | ||
* @brief Checks if two petri-nets have equal amount of arcs between places | ||
* and transitions of the same name. | ||
* | ||
* @param net1 | ||
* @param net2 | ||
* @return true | ||
* @return false | ||
*/ | ||
bool stateNetEquality(const Net& net1, const Net& net2); | ||
|
||
/** | ||
* @brief Calculates a hash given an event log. This hash is only influenced by | ||
* the order of the completions of transitions and if the output of those | ||
* transitions is Completed, or something else. | ||
* | ||
* @param event_log An eventlog, can both be from a terminated or a still active | ||
* net. | ||
* @return size_t The hashed result. | ||
*/ | ||
size_t calculateTrace(const Eventlog& event_log) noexcept; | ||
|
||
/** | ||
* @brief A convenience function to get a string representation of the | ||
* state-enum. | ||
* | ||
* @param s The State | ||
* @return std::string The State as a human readable string. | ||
*/ | ||
std::string printState(State s) noexcept; | ||
|
||
} // namespace symmetri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters