penego

command module
v0.0.0-...-9a2d19c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2018 License: GPL-3.0 Imports: 17 Imported by: 0

README

Penego

Multi-platform petri-net visualisator written in Go.

Penego can work with Petri nets having following properties:

  • Standard Petri net with indistinguishable tokens
  • Prioritized transitions
  • Timed transtions
    • Deterministic
    • Stochastic (Random time with given distribution function)
      • Uniform
      • Exponential
      • Erlang
  • Propabilities of transitions
  • Weighted arcs
  • Inhibitory edges
  • Capacity of places

Screenshots

simple test 1
gui gui gui gui

Build

go get -u git.yo2.cz/drahoslav/penego/
Requirements
windows
  • mingw-64 5.x (req. by andlabs/ui)
linux
  • apt install:
    • libgl1-mesa-dev xorg-dev (req. by go-gl/gl, go-gl/glfw)
    • libgtk-3-dev (req. by andlabs/ui)

Usage

Gui mode
./penego [file.pn]

Where file.pn is file with penego notation.

Headless mode
./penego [file.pn] [-i file.pnml] -o file.ext

(Where ext has to be one of png, svg or pdf.)

It will either load net saved earlier from penego file, of it will import net from pnml file produced by another Petri net editor (PIPE5, CPN tools), and export it to an image based on extension.

Penego notation

Penego uses its own language to represent Petri nets.

It's meant to be easy to learn, and easier to use.

Example
g (1)
e ( ) "exit"
----
g -> [exp(30us)] -> g, 2*e
Definition

It consist of two types of lines:

  • Place definition. The one with parenthesis ()
    • Must start with place identificator. (These are used in Transition definitions.)
    • May contain marking of place (number of tokens in place) within parentheses.
    • An optional description in quotes may follow after parentheses.
  • Transition definition. The one with brackets []
    • It may start/end with list of incomming/outcomming arcs, followed/foregoing by arrow ->.
      • Arc means directed edge.
        • Arc is defined by place identificator. Eg. p.
        • Irt may be multipled by arcs's weight. Eg 2*p
        • Arc prefixed with ! indicates inhibitory edge. Eg !p
      • List of arcs is comma-separated.
    • It may contain additional attribute within brackets. Priority or timing.
      • Transition may be timed od may have greater priority, but not both.
      • [p=N] where N is non-negative integer indicates transition with given priority N (graeter N means greater priority)
      • [TIME] where TIME is some time string (compatible with Duration String format of go's time package) eg. 1s, 4h15m or 45ns indicates transition with constant duration time.
      • [exp(TIME)] indicates transition with timed duration given by exponential random function with mean TIME.
      • [erlang(k,TIME)] indicates transition with timed duration given by erlang random function with mean TIME and shape k.
      • [TIME..TIME] or [TIME-TIME] indicates transition with timed duration given by uniform random function with given range.

The text beginning with // or -- is ignored by parser until the end of the line (comments).

Example of more complex network described in penego notation
// common places
g (1) // generator of students
f (0) "queue"
k (5) "attendant"
v ( ) "serving"
s ( ) "eating"
o ( ) // exit

// places related to interruption
z ( ) // icterus alert
c ( ) // emptying loop
i ( ) "quarantine"

----------------------------

// common transitions
g	-> [exp(3m)] "incoming" -> g,f
f,k	-> [] -> v
v	-> [exp(1m)] -> s,k
s 	-> [10m..15m] -> o
// o	-> [] "outcoming"

// transisions related to interruption
[exp(100d)]  -> z
z,g	-> [p=1] -> c
c,f	-> [p=3] -> c,o
c,v	-> [p=2] -> c,o,k
c,s	-> [p=1] -> c,o
c	-> [p=0] -> i
i	-> [10d] -> g

Modules

Module penego/net can be used separately.

Module penego/gui can be used separately.

Usage of net

Following petri net…

  (1)<-----
   |       |
   |       |    2    exit
    ----->[ ]------->( )
         exp(30s)

… can be created like this…

	g := &net.Place{Tokens:1} // generator
	e := &net.Place{Description: "exit"}
	t := &net.Transition{
		Origins: net.Arcs{{1,g}},
		Targets: net.Arcs{{1,g},{2,e}},
		TimeFunc: net.GetExponentialTimeFunc(30*time.Second),
	}
	network = net.New(net.Places{g, e}, net.Transitions{t})

… or rather like this using penego notation.

	network, err = net.Parse(`
		g (1)
		e ( ) "exit"
		----
		g -> [exp(30us)] -> g, 2*e
	`)
TODO simulation

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
This package implements Composition which is a stuct defining 2-dimensional placeme of petri net elements * Network Simplex Algorithm for Ranking Nodes of a directed acyclic graph (DAG) * this is strongly based on algorithm described in here https://graphviz.gitlab.io/_pages/Documentation/TSE93.pdf
This package implements Composition which is a stuct defining 2-dimensional placeme of petri net elements * Network Simplex Algorithm for Ranking Nodes of a directed acyclic graph (DAG) * this is strongly based on algorithm described in here https://graphviz.gitlab.io/_pages/Documentation/TSE93.pdf
Package draw contains drawing procedures which defines grapical representations of several entities including gui elements, such as menu and also petri net components - places, transitions, arcs
Package draw contains drawing procedures which defines grapical representations of several entities including gui elements, such as menu and also petri net components - places, transitions, arcs
Package export defines ImageDrawer - implementation of draw.Drawer interface which support drawing to various image formats So far following are supported: PNG, SVG, PDF
Package export defines ImageDrawer - implementation of draw.Drawer interface which support drawing to various image formats So far following are supported: PNG, SVG, PDF
Package gui handles user interface related stuff eg.: window creation, graphic context preparation and rendering (but not drawing rutines itself) event handling - mouse, keyboard, resize,...
Package gui handles user interface related stuff eg.: window creation, graphic context preparation and rendering (but not drawing rutines itself) event handling - mouse, keyboard, resize,...
Package net defines internal representation of petri net - Net struct It implements simulation of such net and also parser from textual representation (custom pn format) to Net
Package net defines internal representation of petri net - Net struct It implements simulation of such net and also parser from textual representation (custom pn format) to Net
Package pnml implements parser of pnml format Currently supported dialects are those from PIPE 5 and CPN tools 4 Not all features might be supported
Package pnml implements parser of pnml format Currently supported dialects are those from PIPE 5 and CPN tools 4 Not all features might be supported
Storage is package used for sharing various dynamic values across several modules
Storage is package used for sharing various dynamic values across several modules

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL