Petri is a data structure that encodes the Petri net and holds pointers to the thread-pool and the reducer-queue. It is optimized for calculating the active transition set and dispatching a Callback to the TaskSystem.
More...
#include <petri.h>
|
| Petri (const Net &_net, const PriorityTable &_priority, const Marking &_initial_tokens, const Marking &_final_marking, const std::string &_case_id, std::shared_ptr< TaskSystem > threadpool) |
| Construct a new Petri from a multiset description of a Petri net, a lookup table for the transitions, optional priorities and an initial marking. A lot of conversion work is done in the constructor, so you should avoid creating Models during the run-time of a Petri application.
|
|
| Petri (Petri const &)=delete |
|
| Petri (Petri &&) noexcept=delete |
|
Petri & | operator= (Petri const &)=delete |
|
Petri & | operator= (Petri &&) noexcept=delete |
|
std::vector< AugmentedToken > | toTokens (const Marking &marking) const noexcept |
| outputs the marking as a vector of tokens; e.g. [1 1 1 0 5] means 3 tokens in place 1, 1 token in place 0 and 1 token in place 5.
|
|
Marking | getMarking () const |
| Get the current marking. It is represented by a vector of places: every occurance of a place in this vectors implies a token in that place. This representation does not show the empty places explicitly; if a place is not in this vector you can assume it has no token.
|
|
Eventlog | getLogInternal () const |
| get the current eventlog, also copies in all child eventlogs of active petri nets.
|
|
void | tryFire (const Transition &t) |
| Try to fire a single transition. Does nothing if t is not active.
|
|
void | fireTransitions () |
| Fires all active transitions until it there are none left. Associated asynchronous Callbacks are scheduled and synchronous Callback are executed immediately.
|
|
|
struct { | |
|
std::vector< std::string > transition | |
| (ordered) list of string representation of transitions
|
|
std::vector< std::string > place | |
| (ordered) list of string representation of places
|
|
std::vector< SmallVectorInput > input_n | |
| list of list of inputs to transitions. This vector is indexed like transition .
|
|
std::vector< SmallVectorInput > output_n | |
| list of list of outputs of transitions. This vector is indexed like transition .
|
|
std::vector< SmallVector > p_to_ts_n | |
| list of list of transitions that have places as inputs. This vector is index like place
|
|
std::vector< int8_t > priority | |
| This vector holds priorities for all transitions. This vector is index like transition .
|
|
std::vector< Callback > store | |
| This is the same 'lookup table', only index using transition so it is compatible with index lookup.
|
|
} | net | |
| Is a data-oriented design of a Petri net.
|
|
std::vector< AugmentedToken > | initial_tokens |
| The initial marking.
|
|
std::vector< AugmentedToken > | tokens |
| The current marking.
|
|
std::vector< AugmentedToken > | final_marking |
| The final marking.
|
|
std::vector< size_t > | scheduled_callbacks |
| List of active transitions.
|
|
SmallLog | log |
| The most up to date event_log.
|
|
Token | state |
| The current state of the Petri.
|
|
std::string | case_id |
| The unique identifier for this Petri-run.
|
|
std::atomic< std::optional< unsigned int > > | thread_id_ |
| The id of the thread from which the Petri is fired.
|
|
std::shared_ptr< moodycamel::BlockingConcurrentQueue< Reducer > > | reducer_queue |
|
std::shared_ptr< TaskSystem > | pool |
| A pointer to the threadpool used to defer Callbacks.
|
|
Petri is a data structure that encodes the Petri net and holds pointers to the thread-pool and the reducer-queue. It is optimized for calculating the active transition set and dispatching a Callback to the TaskSystem.
◆ Petri()
symmetri::Petri::Petri |
( |
const Net & | _net, |
|
|
const PriorityTable & | _priority, |
|
|
const Marking & | _initial_tokens, |
|
|
const Marking & | _final_marking, |
|
|
const std::string & | _case_id, |
|
|
std::shared_ptr< TaskSystem > | threadpool ) |
|
explicit |
Construct a new Petri from a multiset description of a Petri net, a lookup table for the transitions, optional priorities and an initial marking. A lot of conversion work is done in the constructor, so you should avoid creating Models during the run-time of a Petri application.
- Parameters
-
_net | |
_priority | |
_initial_tokens | |
_final_marking | |
_case_id | |
threadpool | |
◆ getLogInternal()
Eventlog symmetri::Petri::getLogInternal |
( |
| ) |
const |
get the current eventlog, also copies in all child eventlogs of active petri nets.
- Returns
- Eventlog
◆ getMarking()
Marking symmetri::Petri::getMarking |
( |
| ) |
const |
Get the current marking. It is represented by a vector of places: every occurance of a place in this vectors implies a token in that place. This representation does not show the empty places explicitly; if a place is not in this vector you can assume it has no token.
- Returns
- std::vector<Place>
◆ toTokens()
outputs the marking as a vector of tokens; e.g. [1 1 1 0 5] means 3 tokens in place 1, 1 token in place 0 and 1 token in place 5.
- Parameters
-
- Returns
- std::vector<size_t>
◆ tryFire()
void symmetri::Petri::tryFire |
( |
const Transition & | t | ) |
|
Try to fire a single transition. Does nothing if t is not active.
- Parameters
-
t | string representation of the transition that is tried to fire. |
◆ reducer_queue
std::shared_ptr<moodycamel::BlockingConcurrentQueue<Reducer> > symmetri::Petri::reducer_queue |
A pointer to the reducer queue. It is a shared pointer because it needs to be captured by Reducers which are executed later, guaranteeing the queue is not destroyed while in use.
The documentation for this struct was generated from the following files:
- symmetri/petri.h
- symmetri/petri.cpp