#include <functional>
#include <optional>
#include <tuple>
#include "externals/blockingconcurrentqueue.h"
#include "externals/small_vector.hpp"
#include "symmetri/callback.h"
#include "symmetri/tasks.h"
#include "symmetri/types.h"
Go to the source code of this file.
|
using | symmetri::AugmentedToken = std::tuple<size_t, Token> |
| AugmentedToken describes a token with a color in a particular place.
|
|
using | symmetri::SmallLog = std::vector<SmallEvent> |
| a list of events
|
|
using | symmetri::SmallVector = gch::small_vector<size_t, 4> |
| General purpose stack-allocated mini vector for indices.
|
|
using | symmetri::SmallVectorInput = gch::small_vector<AugmentedToken, 4> |
| General purpose stack-allocated mini vector for colored markings.
|
|
using | symmetri::Reducer = std::function<void(Petri &)> |
| A Reducer updates the Petri-object. Reducers are used to process the post-callback marking mutations.
|
|
|
size_t | symmetri::toIndex (const std::vector< std::string > &m, const std::string &s) |
| a small helper function to get the index representation of a place or transition.
|
|
gch::small_vector< size_t, 32 > | symmetri::possibleTransitions (const std::vector< AugmentedToken > &tokens, const std::vector< SmallVectorInput > &input_n, const std::vector< SmallVector > &p_to_ts_n) |
| calculates a list of possible transitions given the current token-distribution. It returns a list of transitions sorted by priority. The first element being the high priority.
|
|
bool | symmetri::canFire (const SmallVectorInput &pre, const std::vector< AugmentedToken > &tokens) |
| Takes a vector of input places (pre-conditions) and the current token distribution to determine whether the pre-conditions are met, e.g. the transition is active.
|
|
Reducer | symmetri::scheduleCallback (size_t t_idx, const Callback &task, const std::shared_ptr< moodycamel::BlockingConcurrentQueue< Reducer > > &reducer_queue) |
| Schedules the callback associated with transition t_idx/transition. It returns a reducer which is to be executed after Callback task completed.
|
|
void | symmetri::deductMarking (std::vector< AugmentedToken > &tokens, const SmallVectorInput &inputs) |
| deducts the set input from the current token distribution
|
|
◆ canFire()
Takes a vector of input places (pre-conditions) and the current token distribution to determine whether the pre-conditions are met, e.g. the transition is active.
- Parameters
-
pre | vector of preconditions |
tokens | the current token distribution |
- Returns
- true if the pre-conditions are met
-
false otherwise
◆ deductMarking()
deducts the set input from the current token distribution
- Parameters
-
inputs | a vector representing the tokens to be removed |
◆ possibleTransitions()
gch::small_vector< size_t, 32 > symmetri::possibleTransitions |
( |
const std::vector< AugmentedToken > & | tokens, |
|
|
const std::vector< SmallVectorInput > & | input_n, |
|
|
const std::vector< SmallVector > & | p_to_ts_n ) |
calculates a list of possible transitions given the current token-distribution. It returns a list of transitions sorted by priority. The first element being the high priority.
- Parameters
-
- Returns
- gch::small_vector<size_t, 32>
◆ scheduleCallback()
Reducer symmetri::scheduleCallback |
( |
size_t | t_idx, |
|
|
const Callback & | task, |
|
|
const std::shared_ptr< moodycamel::BlockingConcurrentQueue< Reducer > > & | reducer_queue ) |
Schedules the callback associated with transition t_idx/transition. It returns a reducer which is to be executed after Callback task completed.
- Parameters
-
t_idx | the index of the transition as used in the Petri-class |
task | the Callback to be scheduled |
- Returns
- Reducer
◆ toIndex()
size_t symmetri::toIndex |
( |
const std::vector< std::string > & | m, |
|
|
const std::string & | s ) |
a small helper function to get the index representation of a place or transition.
- Parameters
-
- Returns
- size_t