Interface

Warning

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

DictType 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: Need way to parse <toolspecific> that is flexible/extendable.

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.

AbstractPetriNet subtypes wrap and extend PnmlNet. Note the Pnml to Petri.

PnmlNet and its contents can be considered an intermediate representation (IR). A concrete AbstractPetriNet type uses the IR to produce higher-level behavior. This is the level at which flatten_pages! and deref! operate.

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

VANESA

See rate_value for a use of non-standard labels by SimpleNet. 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:

  • AbstractPetriNet subtypes wraping a single PnmlNet.
  • PnmlNet maybe multiple pages.
  • Page as the only page of the only net in a Abstractpetrinet.

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 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.

PNML.pid

# 4 methods for generic function pid from PNML:

name(x) - get name

AbstractPnmlObjects and PnmlNets have a name label. PNML.Labels.Declarations have a name attribute. ToolInfos have a toolname attribute.

PNML.name

# 5 methods for generic function name from PNML:

tag(x) - access XML tag symbol

PNML.tag

# 11 methods for generic function tag from PNML:

nettype(x) - return PnmlType identifying PNTD

PNML.nettype

# 3 methods for generic function nettype from PNML:

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

PNML.places

# 2 methods for generic function places from PNML:

transitions

PNML.transitions

# 2 methods for generic function transitions from PNML:

arcs

PNML.arcs

# 2 methods for generic function arcs from PNML:

refplaces

PNML.refplaces

# 2 methods for generic function refplaces from PNML:

reftransitions

PNML.reftransitions

# 2 methods for generic function reftransitions from PNML:

Node Predicates - uses PNML ID

has_place

PNML.has_place

# 2 methods for generic function has_place from PNML:

has_transition

PNML.has_place

# 2 methods for generic function has_transition from PNML:

has_arc

PNML.has_arc

# 2 methods for generic function has_arc from PNML:

has_refplace

PNML.has_refplace

# 2 methods for generic function has_refplace from PNML:

has_reftransition

PNML.has_reftransition

# 2 methods for generic function has_reftransition from PNML:

Node Access - uses PNML ID

place

PNML.place

# 2 methods for generic function place from PNML:

transition

PNML.transition

# 2 methods for generic function transition from PNML:

arc

PNML.arc

# 3 methods for generic function arc from PNML:

refplace

PNML.refplace

# 2 methods for generic function refplace from PNML:

reftransition

PNML.reftransition

# 2 methods for generic function reftransition from PNML:

Node ID Iteratables

Better to iterate than allocate. Using a set abstraction that iterates consistently, perhaps in insertion order.

place_idset

ObjectSynopsisComment
PnmlNetkeys(placedict(net))Iterates PnmlNetData OrderedDict keys
Pageplace_idset(netsets(page))Iterates PnmlNetKeys OrderedSet
PnmlNetKeysOrderedSetIterates 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.

PNML.place_idset

# 3 methods for generic function place_idset from PNML:

transition_idset

PNML.transition_idset

# 3 methods for generic function transition_idset from PNML:

arc_idset

PNML.arc_idset

# 3 methods for generic function arc_idset from PNML:

refplace_idset

PNML.refplace_idset

# 3 methods for generic function refplace_idset from PNML:

reftransition_idset

PNML.reftransition_idset

# 3 methods for generic function reftransition_idset from PNML:

all_arcs - source or target is PNML ID

PNML.all_arcs

# 1 method for generic function all_arcs from PNML:

src_arcs - source is PNML ID

PNML.src_arcs

# 1 method for generic function src_arcs from PNML:

tgt_arcs - target is PNML ID

tgt_arcs

# 1 method for generic function tgt_arcs from PNML:

inscription - evaluate inscription value (or return default)

inscription

# 2 methods for generic function inscription from PNML:

deref! - dereference all references of flattened net

deref!

# 1 method for generic function deref! from PNML:

deref_place - dereference one place

deref_place

# 1 method for generic function deref_place from PNML:

deref_transition - dereference one transition

deref_transition

# 1 method for generic function deref_transition from PNML:

initial_marking - evaluate marking value (or return default)

initial_marking

# 2 methods for generic function initial_marking from PNML:

initial_markings - return Vector of pairs

initial_markings

# 4 methods for generic function initial_markings from PNML.PNet:

conditions - collect evaluated conditions

conditions

# 1 method for generic function conditions from PNML:

condition - evaluate condition of one transition

condition

# 2 methods for generic function condition from PNML:

transition_function - return LVector of in_out for all transitions

transition_function

# 2 methods for generic function transition_function from PNML.PNet:

in_out - tuple of ins, outs of one transition

PNet.in_out

# 2 methods for generic function in_out from PNML.PNet:

ins - LVector of source arc evaluated inscriptions.

PNet.ins

# 1 method for generic function ins from PNML.PNet:

outs - LVector of target arc evaluated inscriptions.

PNet.outs

# 1 method for generic function outs from PNML.PNet:

Labels - Annotation and HLAnnotation

Both kinds (all labels) have Graphics and ToolInfo. Labels.HLAnnotation adds optional <text>, <structure>.

text

text

# 2 methods for generic function text from PNML.Labels:

value

value

# 6 methods for generic function value from PNML:

has_labels - do any exist

has_labels

# 3 methods for generic function has_labels from PNML:

has_label - does a specific label exist

has_label

# 2 methods for generic function has_label from PNML:

get_label - get a specific label

get_label

# 2 methods for generic function get_label from PNML:

ToolInfo

has_toolinfo - does a specific toolinfo exist

PNML.Labels.has_toolinfo

# 4 methods for generic function has_toolinfo from PNML.Labels:

get_toolinfo - get a specific toolinfo exist

PNML.Labels.get_toolinfo

# 5 methods for generic function get_toolinfo from PNML.Labels:

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

parse_sorttype is different

Parser.parse_sorttype is used to parse an XML <type> element. It is not one of these look-up a type trait methods.

  • layersPage inside a PnmlNet inside a 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.