model

package
v0.0.0-...-d77e8f6 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PLACE      nodeType = 0
	TRANSITION nodeType = 1

	ARC       arcType = 0
	INHIBITOR arcType = 1
)
View Source
const CapacityVar varType = 2
View Source
const InitialVar varType = 0
View Source
const WeightVar varType = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor = label

Actors are granted roles in the system

type Arc

type Arc struct {
	Source *Node
	Target *Node
	Weight uint64
	Type   arcType
}

arcs connect nodes

type Cell

type Cell = label

Cells designate places in the petri-net model

type Coords

type Coords struct {
	X int
	Y int
}

position on x/y grid for visualization

type Fn

type Fn = label

Fn is a state-transition between cells

type MetaModel

type MetaModel struct {
	ProtoModel  `json:"-"`
	Schema      string                                           `json:"schema"`
	Places      map[string]*ptnet.Place                          `json:"places"`
	Transitions map[statemachine.Action]*statemachine.Transition `json:"transitions"`
	VectorSize  int                                              `json:"-"`
	// contains filtered or unexported fields
}

an MetaModel is used as scaffolding for constructing petri-nets

func FromAny

func FromAny(n *any.Any) (m *MetaModel, err error)

func New

func New(Schema string) *MetaModel

func (*MetaModel) AppendArc

func (m *MetaModel) AppendArc(a Arc)

store are declaration in model arcs are indexed only after model is frozen

func (*MetaModel) AssertFrozen

func (m *MetaModel) AssertFrozen()

func (*MetaModel) Freeze

func (m *MetaModel) Freeze() *MetaModel

re-indexes model and marks as frozen

func (*MetaModel) GetVars

func (m *MetaModel) GetVars() []*VarMap

func (*MetaModel) IsFrozen

func (m *MetaModel) IsFrozen() bool

func (*MetaModel) NewVar

func (m *MetaModel) NewVar() Var

func (*MetaModel) PTNet

func (m *MetaModel) PTNet() *ptnet.PTNet

export model as Petri-Net

func (*MetaModel) Place

func (m *MetaModel) Place(label string, place ptnet.Place) *Node

func (*MetaModel) Role

func (m *MetaModel) Role(label string) statemachine.Role

func (*MetaModel) ToAny

func (m *MetaModel) ToAny() (n *any.Any, err error)

func (*MetaModel) Transition

func (m *MetaModel) Transition(label string, transition statemachine.Transition) *Node

type Node

type Node struct {
	Label string

	*ptnet.Place
	*statemachine.Transition
	// contains filtered or unexported fields
}

nodes are used to generate state machine model

func (*Node) Inhibitor

func (n *Node) Inhibitor(weight uint64, target *Node) *Node

create inhibitor function

func (*Node) IsPlace

func (n *Node) IsPlace() bool

test if node is a place

func (*Node) IsTransition

func (n *Node) IsTransition() bool

test if node is a transition

func (*Node) TX

func (n *Node) TX(val uint64, cell *Node) *Node

declare part of a transaction

type ProtoModel

type ProtoModel interface {
	Freeze() *MetaModel
	Place(ptnet.Place) *Node
	Transition(ptnet.Place) *Node
	Role(string) statemachine.Role
	ToAny() (*any.Any, error)
}

type Ref

type Ref struct {
	Target string
	Source string
}

allow relative addressing for variable binding Ref{Target, source} points to an arc place -> tx or tx -> place Ref{source} points to a place

type Var

type Var interface {
	// set max capacity
	Capacity(t string) Var

	// set input values
	Initial(t string) Var

	// adjust multiple on arc
	Weight(n ...string) Var

	Bind(bindFunc binding)
	// contains filtered or unexported methods
}

syntactic sugar for variable declaration

func NewVar

func NewVar() Var

begin a new var definition

type VarMap

type VarMap struct {
	Var
	Ref
	Coords
	Label       string
	Offset      int
	Description string
	// contains filtered or unexported fields
}

map input vars to MetaModel

func (*VarMap) Bind

func (v *VarMap) Bind(bindFunc binding)

bind variable to a value producing function

func (*VarMap) Capacity

func (v *VarMap) Capacity(t string) Var

set max capacity

func (*VarMap) GetVal

func (v *VarMap) GetVal() uint64

bind variable to a value producing function

func (*VarMap) Initial

func (v *VarMap) Initial(t string) Var

set initial input

func (*VarMap) Type

func (v *VarMap) Type() varType

func (*VarMap) Weight

func (v *VarMap) Weight(n ...string) Var

set a transacted value Cell -> Fn or Fn -> Cell

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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