Giter Site home page Giter Site logo

lukoerfer / simple-pnml-dotnet Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 229 KB

Simple .NET implementation of the Petri Net Markup Language (PNML), limited to Place-Transition-(PT)-Nets

License: MIT License

C# 86.44% PowerShell 9.83% Shell 3.73%
dotnet csharp pnml petri-nets

simple-pnml-dotnet's Introduction

SimplePNML for .NET

License Build Coverage

Simple .NET implementation of the Petri Net Markup Language (PNML), limited to Place-Transition-(PT)-Nets

Check out SimplePNML for JVM to handle PNML files from JVM languages like Java, Kotlin or Groovy!

Motivation

The Petri Net Markup Language (PNML) was developed as an interchange format for petri nets and can describe the logical relations between the components as well as information required for visualization. It is highly extendable and provides support for a variety of different petri net types, which comes with the price of high complexity. Since most use cases and applications are focused on Place-Transition-(PT)-Nets, this library provides a simple way to access and modify this kind of petri nets programmatically.

Installation

Usage

SimplePNML implements the elements and relations defined by the PNML specification as simple classes with their respective properties.

The additional class Document is a container that represents a PNML file and its content. The utility functions of the static class PNML can be used to read and write Document instances:

Document example = PNML.Read(new FileInfo("example.pnml"));
PNML.Write(example, Console.Out);

As an example, the following code can be used to print the identifiers of all places on the first page of the first net in a given Document:

example.Nets.First().Pages.First().Places
    .ForEach(place => Console.Out.WriteLine(place.Id));

To build new petri nets just create the required PNML elements. While possible, it is not necessary to explicitly define identifiers for the elements, as they will be generated automatically (using Guid.NewGuid().ToString()).

// Create a place, a transition and an arc
Place place = new Place() 
{
	Id = "my-place",
    InitialMarking = new Label("1")
};
Transition transition = new Transition()
{
	Id = "my-transition"
};
Arc arc = new Arc()
{
	// no explicit identifier
    Inscription = new Label("1")
};

// Let the arc connect the place and the transition
arc.Connect(place, transition);

// Add all the elements to a new page
Page page = new Page();
page.Places.Add(page);
page.Transitions.Add(transition);
page.Arcs.Add(arc);

Differences to JVM version

  • The element relations can be accessed as properties.
  • Some names are changed to follow language-specific naming conventions:
    • Methods are named using PascalCase.
    • Enum members are named using PascalCase.

License

This software is licensed under the MIT license.

simple-pnml-dotnet's People

Contributors

lukoerfer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.