Symmetri
Loading...
Searching...
No Matches
petri.h File Reference
#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.

Classes

struct  symmetri::SmallEvent
 a minimal Event representation. More...
 
struct  symmetri::Petri
 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...
 
struct  symmetri::Petri::PTNet
 

Typedefs

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.
 

Functions

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, 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.
 
void symmetri::deductMarking (std::vector< AugmentedToken > &tokens, const SmallVectorInput &inputs)
 deducts the set input from the current token distribution
 
std::tuple< std::vector< std::string >, std::vector< std::string >, std::vector< Callback > > symmetri::convert (const Net &_net)
 
std::tuple< std::vector< SmallVectorInput >, std::vector< SmallVectorInput > > symmetri::populateIoLookups (const Net &_net, const std::vector< Place > &ordered_places)
 
std::vector< SmallVectorsymmetri::createReversePlaceToTransitionLookup (size_t place_count, size_t transition_count, const std::vector< SmallVectorInput > &input_transitions)
 
std::vector< int8_t > symmetri::createPriorityLookup (const std::vector< Transition > transition, const PriorityTable &_priority)
 

Function Documentation

◆ canFire()

bool symmetri::canFire ( const SmallVectorInput & pre,
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.

Parameters
prevector of preconditions
tokensthe current token distribution
Returns
true if the pre-conditions are met
false otherwise

◆ deductMarking()

void symmetri::deductMarking ( std::vector< AugmentedToken > & tokens,
const SmallVectorInput & inputs )

deducts the set input from the current token distribution

Parameters
inputsa 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
tokens
p_to_ts_n
Returns
gch::small_vector<size_t, 32>

◆ 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
m
s
Returns
size_t