Skip to content

oris-tool/sirio-examples

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

ORIS Tool: Sirio Library Examples

A ready-to-use project for the Sirio API

This repository provides a ready-to-use Maven project that you can easily import into an Eclipse workspace to start working with the Sirio API within minutes.

Just follow these steps:

  1. Install Java 17.

  2. Download Eclipse. The Eclipse IDE for Java Developers package is sufficient.

  3. Clone this project. Inside Eclipse:

    • Select File > Import > Maven > Check out Maven Projects from SCM and click Next.
    • If the SCM URL dropbox is grayed out, click on m2e Marketplace and install m2e-egit. You will have to restart Eclipse (be patient...).
    • As SCM URL, type: https://github.com/oris-tool/sirio-examples.git and click Next and then Finish.

Your Eclipse project is ready!

Just navigate to src/main/java and open ProducerConsumer.java inside the package org.oristool.examples. You will find the following example:

public class ProducerConsumer {
  public static void main(String[] args) {
    PetriNet pn = new PetriNet();

    // first produce-consume loop
    Place producing1 = pn.addPlace("producing1");
    Transition produce1 = pn.addTransition("produce1");
    Place buffer1 = pn.addPlace("buffer1");
    Transition consume1 = pn.addTransition("consume1");

    pn.addPrecondition(producing1, produce1);
    pn.addPostcondition(produce1, buffer1);
    pn.addPrecondition(buffer1, consume1);
    pn.addPostcondition(consume1, producing1);

    // second produce-consume loop
    Place producing2 = pn.addPlace("producing2");
    Transition produce2 = pn.addTransition("produce2");
    Place buffer2 = pn.addPlace("buffer2");
    Transition consume2 = pn.addTransition("consume2");

    pn.addPrecondition(producing2, produce2);
    pn.addPostcondition(produce2, buffer2);
    pn.addPrecondition(buffer2, consume2);
    pn.addPostcondition(consume2, producing2);

    // consume1 has priority over consume2
    pn.addInhibitorArc(buffer1, consume2);

    // durations are all uniform over [1,2]
    produce1.addFeature(StochasticTransitionFeature.newUniformInstance("1", "2"));
    produce2.addFeature(StochasticTransitionFeature.newUniformInstance("1", "2"));
    consume1.addFeature(StochasticTransitionFeature.newUniformInstance("1", "2"));
    consume2.addFeature(StochasticTransitionFeature.newUniformInstance("1", "2"));

    // initial state
    Marking m = new Marking();
    m.addTokens(producing1, 1);
    m.addTokens(producing2, 1);

    // transient until time=12, error 0.005 (per epoch), integration step=0.02
    RegTransient analysis = RegTransient.builder()
        .greedyPolicy(new BigDecimal("12"), new BigDecimal("0.005"))
        .timeStep(new BigDecimal("0.02"))
        .build();

    TransientSolution<DeterministicEnablingState, Marking> solution =
        analysis.compute(pn, m);

    // display transient probabilities
    new TransientSolutionViewer(solution);
  }
}

This code models the following stochastic time Petri net (STPN):

By clicking on the menu Run > Run as > Java Application you can start the analysis. You will see the following plot of transient probabilities:

Analysis Results

For a detailed introduction, check the Sirio Wiki. The Sirio Javadoc is also available.

About

A ready-to-use project for the Sirio API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published