Title: | Building, Visualizing, Exporting and Replaying Petri Nets |
---|---|
Description: | Functions for the construction of Petri Nets. Petri Nets can be replayed by firing enabled transitions. Silent transitions will be hidden by the execution handler. Also includes functionalities for the visualization of Petri Nets and export of Petri Nets to PNML (Petri Net Markup Language) files. |
Authors: | Gert Janssenswillen [aut, cre], Ivan Esin [ctb] |
Maintainer: | Gert Janssenswillen <[email protected]> |
License: | GPL-3 |
Version: | 0.3.0 |
Built: | 2024-11-27 06:11:54 UTC |
Source: | https://github.com/bupaverse/petrinetr |
Function to create a marked_petrinet
, consisting of a petrinet
, an initial marking, and a final marking.
create_marked_PN(PN, initial_marking, final_marking)
create_marked_PN(PN, initial_marking, final_marking)
PN |
|
initial_marking |
|
final_marking |
|
Function to create a petrinet
by specifying places, transitions and flows.
create_PN(places, transitions, flows)
create_PN(places, transitions, flows)
places |
|
transitions |
|
flows |
|
A petrinet
library(dplyr) create_PN(tibble(id = "p1", label = "place_1"), tibble(id = "t1", label = "transition_1"), tibble(from = "t1",to = "p1"))
library(dplyr) create_PN(tibble(id = "p1", label = "place_1"), tibble(id = "t1", label = "transition_1"), tibble(from = "t1",to = "p1"))
List the enabled transitions in a marked Petri Net. Silent transitions, i.e. starting with "inv_" or "tau" are assumed to be able to fire silently, thereby possible enabling other transitions.
enabled(PN)
enabled(PN)
PN |
A Petri Net |
Check if a transition is currently enabled
enabled_transition(PN, transition)
enabled_transition(PN, transition)
PN |
A Petri Net |
transition |
A Transition |
Executes (fire) an enabled transition and returns the Petri Net with the New marking. If the transition is enabled via the firing of silent transition (i.e. starting with "inv_" of "tau"), it will fire these first. If the transition is not enabled, it will return FALSE.
execute(PN, transition)
execute(PN, transition)
PN |
A Petri Net |
transition |
The transition to be fired |
Get the final marking of a marked_petrinet
final_marking(PN)
final_marking(PN)
PN |
Extracts the flows from a (marked) Petri Net
flows(PN) ## S3 method for class 'petrinet' flows(PN) ## S3 method for class 'marked_petrinet' flows(PN)
flows(PN) ## S3 method for class 'petrinet' flows(PN) ## S3 method for class 'marked_petrinet' flows(PN)
PN |
A data.frame containing the flows of the petri net.
flows(petrinet)
: Flow of petrinet
flows(marked_petrinet)
: Flow of marked petrinet
Get the initial marking of a marked_petrinet
initial_marking(PN)
initial_marking(PN)
PN |
Check if a transition is part of a petri net.
is_transition(transition, PN)
is_transition(transition, PN)
transition |
|
PN |
logical that indicates whether transition
is a transition in PN
Get the current marking of a Petri Net
marking(PN)
marking(PN)
PN |
A Petri Net |
Several auxilliary functions for Petri Net objects.
n_places(PN) n_transitions(PN) n_flows(PN) n_nodes(PN) rename_transitions(PN, .f, ...) rename_places(PN, .f, ...) add_places(PN, places) add_transitions(PN, transitions) add_flows(PN, flows)
n_places(PN) n_transitions(PN) n_flows(PN) n_nodes(PN) rename_transitions(PN, .f, ...) rename_places(PN, .f, ...) add_places(PN, places) add_transitions(PN, transitions) add_flows(PN, flows)
PN |
A petri net |
.f |
A function name to apply for renaming |
... |
Additional arguments |
places |
|
transitions |
|
flows |
|
Get nodes from (marked) petrinet
nodes(PN)
nodes(PN)
PN |
Parses a sequence of transitions. If possible returns the Petri Net with the updated marking. Otherwise returns FALSE
parse_trace(PN, trace)
parse_trace(PN, trace)
PN |
A Petri Net |
trace |
A sequence of transitions, stored in a vector. |
Tests whether a sequence of transitions can be fired by a Petri Net. If so returns TRUE, otherwise FALSE.
parsel_trace(PN, trace)
parsel_trace(PN, trace)
PN |
A Petri Net |
trace |
A sequence of transitions, stored in a vector. |
Check if a node is part of a petri net
part_of(node, PN)
part_of(node, PN)
node |
A node |
PN |
A Petri Net |
Functions for the construction of Petri Nets. Petri Nets can be replayed by firing enabled transitions. Silent transitions will be hidden by the execution handler. Also includes functionalities for the visualization of Petri Nets and export of Petri Nets to PNML-files.
Extracts the places from a Petri Net
places(PN) ## S3 method for class 'petrinet' places(PN) ## S3 method for class 'marked_petrinet' places(PN)
places(PN) ## S3 method for class 'petrinet' places(PN) ## S3 method for class 'marked_petrinet' places(PN)
PN |
places(petrinet)
: Places of petrinet
places(marked_petrinet)
: Places of marked petrinet
Read .PNML file
read_PN(file, add_final_marking = TRUE)
read_PN(file, add_final_marking = TRUE)
file |
Path to .pnml file |
add_final_marking |
|
A codemarked_petrinet
Visualize Petri Net with bipartite graph.
render_PN(PN)
render_PN(PN)
PN |
Extracts the transitions from a Petri Net
transitions(PN) ## S3 method for class 'petrinet' transitions(PN) ## S3 method for class 'marked_petrinet' transitions(PN)
transitions(PN) ## S3 method for class 'petrinet' transitions(PN) ## S3 method for class 'marked_petrinet' transitions(PN)
PN |
transitions(petrinet)
: Transitions of petrinet
transitions(marked_petrinet)
: Transitions of marked petrinet
Visualize a Petri Net with an interactive network
visNetwork_from_PN(PN)
visNetwork_from_PN(PN)
PN |