Interface
Being a work in progress, there will be obsolete, optimistic or incoherent bits.
Eventually this section will cover interfaces in a useful way.
The intermediate representation is used to implement networks expressed in a pnml model. The consumer of the IR is a network is most naturally a varity of Petri Net.
We start a description of the net IR here.
Dict Type
XmlDictType used by:
Top Level: Model, Net, Page
At the top level[layers] a <pnml> model is one or more networks::PnmlNet, each described by a <net> tag and one or more <page> tags.
Page is a required element mostly present for visual presentation to humans. It contains AbstractPnmlObject types that implement the Petri Net Graph (PNG).
While Graphics is implemented it is not dicussed further (until someone extends/uses it).
ToolInfo used to attach well-formed XML almost anywhere in the PNG. TODO: document toolparser.
Parse pnml for input, worry about writing back out and interchange later (future extensions). Another future extension may be to use pages for distributed computing.
The pnml standard permits that multiple pages canto be flattened (by flatten_pages!) to a single Page before use. We do that.
PNet.AbstractPetriNet subtypes wrap and extend PnmlNet. Note the Pnml to Petri.
PnmlNet and its contents can be considered an intermediate representation (IR). A concrete PNet.AbstractPetriNet type uses the IR to produce higher-level behavior. This is the level at which flatten_pages! and deref! operate.
PNet.AbstractPetriNet is the level of most Petri Net Graph semantics. One example is enforcing integer, non-negative, positive. One mechanism used is type parameters.
Remember, the IR trys to be as promiscuous as possible.
XML <net> tags are parsed by parse_net into a PnmlNet.
XML <page> tags are parsed by parse_page! into a Page.
Places
Properties that various places may have one or more of:
- discrete
- continuous
- timed
Transitions
Properties that various transitions may have one or more of:
- discrete
- continuous
- hybrid of discrete & continuous subnets
- stochastic
- immediate
- deterministically time delayed
- scheduled
The pnml schemas and primer only try to cover the discrete case as Place-Transition and High-Level Petri Nets.
Extensions to PNML
Continuous Values
Continous support is present where possible. For instance, when a number appers in the XML number_value is used to parse the string to Int or Float64. This is currently (2022) "non-standard" so such pnml files will not be generally interchangable with other tools.
'Discrete, Continuous, and Hybrid Petri Nets' by Rene David and Hassane Alla
See rate_value for a use of non-standard labels. Implements a stochastic petri net as part of the first working use-case. Demonstrates the expressiveness of pnml.
Petri Net Graphs and Networks
There are 3 top-level forms:
PNet.AbstractPetriNetsubtypes wraping a singlePnmlNet.PnmlNetmaybe multiple pages.Pageas the only page of the only net in aAbstractpetrinet.
The simplest arrangement is a pnml model with a single <net> element having a single <page>. Any <net> may be flatten to a single page.
The initial PNet.AbstractPetriNet subtypes are built using the assumption that multiple pages will be flattened to a single page.
Simple Interface Methods
What makes a method simple? No other arguments besides the object it operates upon.
pid(x) - get PNML ID symbol
Many things within a pnml net have unique identifiers, which are used for referring to the object.
# 4 methods for generic function pid from [35mPNML[39m:- pid(decl::PNML.Declarations.AbstractDeclaration) in PNML.Declarations at /home/runner/work/PNML.jl/PNML.jl/src/Declarations/declarations.jl:13
- pid(a::PNML.Declarations.ArbitrarySort) in PNML.Declarations at /home/runner/work/PNML.jl/PNML.jl/src/Declarations/arbitrarydeclarations.jl:20
- pid(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:63
- pid(x) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/types.jl:79
name(x) - get name
AbstractPnmlObjects and PnmlNets have a name label. PNML.Labels.Declarations have a name attribute. ToolInfos have a toolname attribute.
- name(ti::PNML.ToolParser) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/toolparser.jl:17
- name(decl::PNML.Declarations.AbstractDeclaration) in PNML.Declarations at /home/runner/work/PNML.jl/PNML.jl/src/Declarations/declarations.jl:14
- name(a::PNML.Declarations.ArbitrarySort) in PNML.Declarations at /home/runner/work/PNML.jl/PNML.jl/src/Declarations/arbitrarydeclarations.jl:21
- name(ti::PNML.Labels.ToolInfo) in PNML.Labels at /home/runner/work/PNML.jl/PNML.jl/src/Labels/toolinfos.jl:17
- name(x) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/types.jl:87
tag(x) - access XML tag symbol
# 8 methods for generic function tag from [35mPNML[39m:- tag(lp::PNML.LabelParser) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/labelparser.jl:16
- tag(p::Pair{Symbol, PNML.Labels.PnmlLabel}) in PNML.Labels at /home/runner/work/PNML.jl/PNML.jl/src/Labels/labels.jl:119
- tag(::PNML.BooleanConstant) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/terms/constterm.jl:123
- tag(a::PNML.AnyElement) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/anyelement.jl:59
- tag(op::PNML.Operator) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/terms/operators.jl:46
- tag(label::PNML.Labels.PnmlLabel) in PNML.Labels at /home/runner/work/PNML.jl/PNML.jl/src/Labels/labels.jl:118
- tag(d::OrderedCollections.LittleDict{Union{String, Symbol}, Any, KS, VS} where {KS<:Union{Tuple{Vararg{Union{String, Symbol}}}, AbstractVector{Union{String, Symbol}}}, VS<:Union{Tuple, AbstractVector{Any}}}) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/anyelement.jl:8
- tag(::PNML.FiniteIntRangeConstant) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/terms/constterm.jl:73
nettype(x) - return PnmlType identifying PNTD
# 2 methods for generic function nettype from [35mPNML[39m:- nettype(pg::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:25
- nettype(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:61
Nodes of Petri Net Graph
Return vector of nodes. Assumes flattened net so that the PnmlNet and Page refer to the same net-level AbstractDict data structure.
places
# 2 methods for generic function places from [35mPNML[39m:- places(page::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:40
- places(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:121
transitions
# 2 methods for generic function transitions from [35mPNML[39m:- transitions(page::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:41
- transitions(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:122
arcs
# 2 methods for generic function arcs from [35mPNML[39m:- arcs(page::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:42
- arcs(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:123
refplaces
# 2 methods for generic function refplaces from [35mPNML[39m:- refplaces(page::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:43
- refplaces(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:124
reftransitions
# 2 methods for generic function reftransitions from [35mPNML[39m:- reftransitions(page::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:44
- reftransitions(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:125
Node Predicates - uses PNML ID
has_place
# 2 methods for generic function has_place from [35mPNML[39m:- has_place(page::Page, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:54
- has_place(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:113
has_transition
# 2 methods for generic function has_transition from [35mPNML[39m:- has_transition(page::Page, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:57
- has_transition(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:114
has_arc
# 2 methods for generic function has_arc from [35mPNML[39m:- has_arc(page::Page, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:60
- has_arc(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:115
has_refplace
# 2 methods for generic function has_refplace from [35mPNML[39m:- has_refplace(page::Page, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:63
- has_refplace(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:116
has_reftransition
# 2 methods for generic function has_reftransition from [35mPNML[39m:- has_reftransition(page::Page, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:66
- has_reftransition(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:117
Node Access - uses PNML ID
place
# 2 methods for generic function place from [35mPNML[39m:- place(page::Page, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:53
- place(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:127
transition
# 2 methods for generic function transition from [35mPNML[39m:- transition(page::Page, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:56
- transition(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:128
arc
# 3 methods for generic function arc from [35mPNML[39m:- arc(net, src::Symbol, tgt::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:136
- arc(page::Page, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:59
- arc(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:129
refplace
# 2 methods for generic function refplace from [35mPNML[39m:- refplace(page::Page, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:62
- refplace(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:130
reftransition
# 2 methods for generic function reftransition from [35mPNML[39m:- reftransition(page::Page, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:65
- reftransition(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:131
Node ID Iteratables
Better to iterate than allocate. Using a set abstraction that iterates consistently, perhaps in insertion order.
place_idset
| Object | Synopsis | Comment |
|---|---|---|
| PnmlNet | keys(placedict(net)) | Iterates PnmlNetData OrderedDict keys |
| Page | place_idset(netsets(page)) | Iterates PnmlNetKeys OrderedSet |
| PnmlNetKeys | OrderedSet | Iterates PnmlNetKeys OrderedSet |
Both iterate over REFIDs that are indices into PnmlNetData., To access a Place in the PnmlNetData use place(refid).
The contents of PnmlKeySet are indices into PnmlNetData. When there is only one page, the keys of the placedict and place_set will be (must be) the same.
For the foreseeable future, there will be little use of multi-page APIs. It is expected that flattened PNML nets will be the fully supported, tested, thought-through API.
The discussion using place_idset also applies to other *_idsets.
# 3 methods for generic function place_idset from [35mPNML[39m:- place_idset(s::PNML.PnmlNetKeys) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/pnmlnetdata.jl:96
- place_idset(page::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:47
- place_idset(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:84
transition_idset
# 3 methods for generic function transition_idset from [35mPNML[39m:- transition_idset(s::PNML.PnmlNetKeys) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/pnmlnetdata.jl:97
- transition_idset(page::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:48
- transition_idset(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:85
arc_idset
# 3 methods for generic function arc_idset from [35mPNML[39m:- arc_idset(s::PNML.PnmlNetKeys) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/pnmlnetdata.jl:98
- arc_idset(page::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:49
- arc_idset(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:86
refplace_idset
# 3 methods for generic function refplace_idset from [35mPNML[39m:- refplace_idset(s::PNML.PnmlNetKeys) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/pnmlnetdata.jl:100
- refplace_idset(page::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:51
- refplace_idset(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:87
reftransition_idset
# 3 methods for generic function reftransition_idset from [35mPNML[39m:- reftransition_idset(s::PNML.PnmlNetKeys) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/pnmlnetdata.jl:99
- reftransition_idset(page::Page) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/page.jl:50
- reftransition_idset(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:88
Arc Related
all_arcs - source or target is PNML ID
# 1 method for generic function all_arcs from [35mPNML[39m:- all_arcs(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:142
src_arcs - source is PNML ID
# 1 method for generic function src_arcs from [35mPNML[39m:- src_arcs(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:146
tgt_arcs - target is PNML ID
# 1 method for generic function tgt_arcs from [35mPNML[39m:- tgt_arcs(net::PnmlNet, id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:149
inscription - evaluate inscription value (or return default)
# 2 methods for generic function inscription from [35mPNML[39m:- inscription(arc::Arc) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/nodes.jl:146
- inscription(net::PnmlNet, arc_id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:154
deref! - dereference all references of flattened net
# 1 method for generic function deref! from [35mPNML[39m:- deref!(net::PnmlNet; trim, verbose) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/flatten.jl:136
deref_place - dereference one place
# 1 method for generic function deref_place from [35mPNML[39m:- deref_place(net::PnmlNet, id::Symbol; trim, verbose) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/flatten.jl:173
deref_transition - dereference one transition
# 1 method for generic function deref_transition from [35mPNML[39m:- deref_transition(net::PnmlNet, id::Symbol; trim, verbose) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/flatten.jl:197
Place Related
initial_marking - evaluate marking value (or return default)
# 2 methods for generic function initial_marking from [35mPNML[39m:- initial_marking(place::Place) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/nodes.jl:27
- initial_marking(net::PnmlNet, placeid::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:153
Transition Related
conditions - collect evaluated conditions
# 2 methods for generic function conditions from [35mPNML[39m:- conditions(net::PnmlNet) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/NetAPI/netutils.jl:45
- conditions(net::PNML.PnmlTypes.AbstractHLCore) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/NetAPI/netutils.jl:49
condition - evaluate condition of one transition
# 2 methods for generic function condition from [35mPNML[39m:- condition(transition::Transition) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/nodes.jl:103
- condition(net::PnmlNet, trans_id::Symbol) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/nodes/net.jl:155
Labels - Annotation and HLAnnotation
Both kinds (all labels) have Graphics and ToolInfo. Labels.HLAnnotation adds optional <text>, <structure>.
text
# 2 methods for generic function text from [35mPNML.Labels[39m:- text(t::PNML.Labels.SortType) in PNML.Labels at /home/runner/work/PNML.jl/PNML.jl/src/Labels/sorttype.jl:75
- text(l::PNML.AbstractLabel) in PNML.Labels at /home/runner/work/PNML.jl/PNML.jl/src/Labels/labels.jl:68
value
# 8 methods for generic function value from [35mPNML[39m:- value(bc::PNML.BooleanConstant) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/terms/constterm.jl:128
- value(v::PNML.Variable) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/terms/variables.jl:27
- value(nc::PNML.NumberConstant) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/terms/constterm.jl:20
- value(op::PNML.Operator) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/terms/operators.jl:51
- value(r::PNML.Labels.Rate) in PNML.Labels at /home/runner/work/PNML.jl/PNML.jl/src/Labels/rates.jl:29
- value(r::PNML.Labels.Time) in PNML.Labels at /home/runner/work/PNML.jl/PNML.jl/src/Labels/times.jl:31
- value(r::PNML.Labels.Priority) in PNML.Labels at /home/runner/work/PNML.jl/PNML.jl/src/Labels/priorities.jl:32
- value(c::PNML.FiniteIntRangeConstant) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/terms/constterm.jl:83
get_label - get a specific label
# 1 method for generic function get_label from [35mPNML[39m:- get_label(x, tag::Union{SubString{String}, String, Symbol}) in PNML at /home/runner/work/PNML.jl/PNML.jl/src/Core/types.jl:111
ToolInfo
get_toolinfo - get a specific toolinfo exist
# 1 method for generic function get_toolinfo from [35mPNML.Labels[39m:- get_toolinfo(infos, name, version) in PNML.Labels at /home/runner/work/PNML.jl/PNML.jl/src/Labels/toolinfos.jl:92
Type Lookup
Petri Net Graph Object Types are parameterized by Label Types. What labels are "allowed" (syntax vs. semantics vs. schema vs. standard) is parameterized on the PNTD (Petri Net Type Definition).
See PnmlNets & AbstractPnmlObjects, and PnmlTypes for details of the singleton types used.
Value Types
TBD
Parser.parse_sorttype is used to parse an XML <type> element. It is not one of these look-up a type trait methods.
- layers
Pageinside aPnmlNetinside aPNet.AbstractPetriNet. Where the Petri Net part is expressed as a Petri Net Type Definition XML schema file (.pntd) identified by a URI. Or would if our nonstandard extensions had schemas defined. Someday there will be such schemas.