Documentation ¶
Overview ¶
Package petrinet where: P => places T => transitions F subset of (P X T) U (T X P) => arcs F0 subset of (P X T) => inhibitor arcs W: F -> {1,2,3,...} => weights of arcs W0: F0 -> {1,2,3,...} => weights of inhibitor arcs M_0: P -> {0, 1, 2, 3, ...} => Initial marking
{ P: Number => 1...P places T: Number => 1...T transitions Fpt: [{p: Number, t: Number, w: Number}] => Arcs from P to T list Ftp: [{p: Number, t: Number, w: Number}] => Arcs from T to P list Inhibitors: [{p: Number, t: Number, w: Number}] => Inhibitor Arcs from P to T list M: [{p: Number, m: Number}] => Initial marking list, }
eg.
{ P: 4, T: 2, Fpt: [{p: 1, t: 1, w: 1}, {p: 2, t: 2, w: 1}, {p: 3, t: 2, w: 1}], Ftp: [{t: 1, p: 2, w: 1}, {t: 1, p: 3, w: 1}, {t: 2, p: 4, w: 1}], Inhibitors: [{t: 2, p: 4, w: 1 }], M: [{p: 1, m: 1}, {p: 3, m: 2}, {p: 4, m: 1}], }
Index ¶
- type Arc
- type PetriNet
- func (pn *PetriNet) AddInArc(from, _transition, _weight int)
- func (pn *PetriNet) AddOutArc(_transition, to, _weight int)
- func (pn *PetriNet) AddPlace(_id int, _label, _name string)
- func (pn *PetriNet) AddRemoteOutArc(_transition, weight int, serviceName string)
- func (pn *PetriNet) AddTransition(_id, _priority int)
- func (pn *PetriNet) Init()
- func (pn *PetriNet) InitService()
- type Place
- type RemoteArc
- type ServiceNode
- type Token
- type Transition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arc ¶
type Arc struct { Place *Place `json:"place"` Weight int `json:"weight"` PlaceID int `json:"placeId"` }
Arc between Petri net components
type PetriNet ¶
type PetriNet struct { ID int `json:"id"` Transitions map[int]*Transition `json:"transitions"` Places map[int]*Place `json:"places"` MaxPriority int `json:"priority"` Interf string `json:"intreface"` }
PetriNet struct, has an id, transitions and places
func (*PetriNet) AddRemoteOutArc ¶
AddRemoteOutArc adds a remote arc
func (*PetriNet) AddTransition ¶
type Place ¶
type Place struct { ID int `json:"id"` Marks []Token `json:"tokens"` Label string `json:"label"` Name string `json:"name"` ServiceName string `json:"serviceName"` }
Place of the Petri net
func (*Place) GetNumMarks ¶
GetNumMarks gets the quantity of tokens in the place
func (*Place) InitService ¶
InitService creates and runs the node containing the net
type RemoteArc ¶
type RemoteArc struct { ServiceName string `json:"serviceName"` Weight int `json:"weight"` Client *sleuth.Client }
RemoteArc for arcs crossing nodes
type ServiceNode ¶
ServiceNode structure of a node associated to its place
func (*ServiceNode) RunService ¶
func (sn *ServiceNode) RunService()
RunService executes the node's server and client
type Transition ¶
type Transition struct { ID int `json:"id"` Priority int `json:"priority"` InArcs []Arc `json:"inArcs"` OutArcs []Arc `json:"outArcs"` RemoteOutArcs []RemoteArc `json:"remoteArcs"` }
Transition of a PetriNet
func (*Transition) AddInArc ¶
func (t *Transition) AddInArc(_arc Arc)
AddInArc adds an arc to \cdot t
func (*Transition) AddRemoteOutArc ¶
func (t *Transition) AddRemoteOutArc(_rarc RemoteArc)
AddRemoteOutArc arcs crossing nodes, alwasys from transition to place
func (*Transition) CanFire ¶
func (t *Transition) CanFire() bool
CanFire checks if the transition can fire
func (*Transition) Init ¶
func (t *Transition) Init()