Symmetri
Loading...
Searching...
No Matches
symmetri::Petri Struct Reference

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>

Classes

struct  PTNet
 

Public Member Functions

 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
 
Petrioperator= (Petri const &)=delete
 
Petrioperator= (Petri &&) noexcept=delete
 
std::vector< AugmentedTokentoTokens (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 fireTransitions ()
 Fires all active transitions until it there are none left. Associated asynchronous Callbacks are scheduled and synchronous Callback are executed immediately.
 
void fireAsynchronous (const size_t t)
 Schedules the Callback associated with t on the threadpool.
 

Public Attributes

struct symmetri::Petri::PTNet net
 Is a data-oriented design of a Petri net.
 
std::vector< AugmentedTokeninitial_tokens
 The initial marking.
 
std::vector< AugmentedTokentokens
 The current marking.
 
std::vector< AugmentedTokenfinal_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< TaskSystempool
 A pointer to the threadpool used to defer Callbacks.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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

Member Function Documentation

◆ fireAsynchronous()

void symmetri::Petri::fireAsynchronous ( const size_t t)

Schedules the Callback associated with t on the threadpool.

Parameters
ttransition as index in transition vector

◆ 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()

std::vector< AugmentedToken > symmetri::Petri::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.

Parameters
marking
Returns
std::vector<size_t>

Member Data Documentation

◆ 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: