Type: | Package |
Title: | Building, Visualizing, Exporting and Replaying Petri Nets |
Version: | 0.3.0 |
Date: | 2023-04-01 |
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. |
License: | GPL-3 |
Depends: | R(≥ 3.0.0) |
Imports: | dplyr, visNetwork, DiagrammeR, xml2, purrr, lifecycle |
RoxygenNote: | 7.2.3 |
Encoding: | UTF-8 |
URL: | https://bupar.net, https://github.com/bupaverse/petrinetR |
BugReports: | https://github.com/bupaverse/petrinetR/issues |
NeedsCompilation: | no |
Packaged: | 2023-04-02 21:56:34 UTC; lucp8407 |
Author: | Gert Janssenswillen [aut, cre], Ivan Esin [ctb] |
Maintainer: | Gert Janssenswillen <gert.janssenswillen@uhasselt.be> |
Repository: | CRAN |
Date/Publication: | 2023-04-03 13:20:02 UTC |
Create Petri Net
Description
Function to create a petrinet
by specifying places, transitions and flows.
Usage
create_PN(places, transitions, flows)
Arguments
places |
|
transitions |
|
flows |
|
Value
A petrinet
Examples
library(dplyr)
create_PN(tibble(id = "p1", label = "place_1"),
tibble(id = "t1", label = "transition_1"),
tibble(from = "t1",to = "p1"))
Create marked Petri Net
Description
Function to create a marked_petrinet
, consisting of a petrinet
, an initial marking, and a final marking.
Usage
create_marked_PN(PN, initial_marking, final_marking)
Arguments
PN |
|
initial_marking |
|
final_marking |
|
Value
Enabled transitions
Description
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.
Usage
enabled(PN)
Arguments
PN |
A Petri Net |
Enabled Transition
Description
Check if a transition is currently enabled
Usage
enabled_transition(PN, transition)
Arguments
PN |
A Petri Net |
transition |
A Transition |
Execute
Description
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.
Usage
execute(PN, transition)
Arguments
PN |
A Petri Net |
transition |
The transition to be fired |
Final Marking
Description
Get the final marking of a marked_petrinet
Usage
final_marking(PN)
Arguments
PN |
Flows
Description
Extracts the flows from a (marked) Petri Net
Usage
flows(PN)
## S3 method for class 'petrinet'
flows(PN)
## S3 method for class 'marked_petrinet'
flows(PN)
Arguments
PN |
Value
A data.frame containing the flows of the petri net.
Methods (by class)
-
flows(petrinet)
: Flow of petrinet -
flows(marked_petrinet)
: Flow of marked petrinet
Initial Marking
Description
Get the initial marking of a marked_petrinet
Usage
initial_marking(PN)
Arguments
PN |
Is node
Description
Check if a node is part of a petri net
Usage
is_node(node, PN)
Arguments
node |
|
PN |
Value
logical that indicates whether node
is a node in PN
Is place
Description
Check if a place is part of a petri net.
Usage
is_place(place, PN)
Arguments
place |
|
PN |
Value
logical that indicates whether place
is a place in PN
Is transition
Description
Check if a transition is part of a petri net.
Usage
is_transition(transition, PN)
Arguments
transition |
|
PN |
Value
logical that indicates whether transition
is a transition in PN
Marked petrinet
Description
Object consisting of a petrinet, initial marking, and final marking
Marking
Description
Get the current marking of a Petri Net
Usage
marking(PN)
Arguments
PN |
A Petri Net |
Utils
Description
Several auxilliary functions for Petri Net objects.
Usage
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)
Arguments
PN |
A petri net |
.f |
A function name to apply for renaming |
... |
Additional arguments |
places |
|
transitions |
|
flows |
|
Get nodes from (marked) petrinet
Description
Get nodes from (marked) petrinet
Usage
nodes(PN)
Arguments
PN |
Parse
Description
Parses a sequence of transitions. If possible returns the Petri Net with the updated marking. Otherwise returns FALSE
Usage
parse_trace(PN, trace)
Arguments
PN |
A Petri Net |
trace |
A sequence of transitions, stored in a vector. |
Parse (logical)
Description
Tests whether a sequence of transitions can be fired by a Petri Net. If so returns TRUE, otherwise FALSE.
Usage
parsel_trace(PN, trace)
Arguments
PN |
A Petri Net |
trace |
A sequence of transitions, stored in a vector. |
Part of
Description
Check if a node is part of a petri net
Usage
part_of(node, PN)
Arguments
node |
A node |
PN |
A Petri Net |
Ppetrinet
Description
Object consisting of places, transitions and flows that denote a petri net
petrinetR - 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-files.
Places
Description
Extracts the places from a Petri Net
Usage
places(PN)
## S3 method for class 'petrinet'
places(PN)
## S3 method for class 'marked_petrinet'
places(PN)
Arguments
PN |
Methods (by class)
-
places(petrinet)
: Places of petrinet -
places(marked_petrinet)
: Places of marked petrinet
Postset
Description
Get the postset of a transition or place in a Petri Net
Usage
post_set(PN, node)
Arguments
PN |
|
node |
|
Preset
Description
Get the preset of a transition or place in a Petri Net
Usage
pre_set(PN, node)
Arguments
PN |
|
node |
|
Read .PNML file
Description
Read .PNML file
Usage
read_PN(file, add_final_marking = TRUE)
Arguments
file |
Path to .pnml file |
add_final_marking |
|
Value
A codemarked_petrinet
Render Petri Net
Description
Visualize Petri Net with bipartite graph.
Usage
render_PN(PN)
Arguments
PN |
Transitions
Description
Extracts the transitions from a Petri Net
Usage
transitions(PN)
## S3 method for class 'petrinet'
transitions(PN)
## S3 method for class 'marked_petrinet'
transitions(PN)
Arguments
PN |
Methods (by class)
-
transitions(petrinet)
: Transitions of petrinet -
transitions(marked_petrinet)
: Transitions of marked petrinet
VisNetwork from PN
Description
Visualize a Petri Net with an interactive network
Usage
visNetwork_from_PN(PN)
Arguments
PN |