sarahtattersall / PIPECore

Core libraries for building and editing Petri nets
6 stars 12 forks source link

Embedding data in petrinets? #87

Open fkleedorfer opened 5 years ago

fkleedorfer commented 5 years ago

For my use case, I'd like to add data to the petrinets so as to make integration with a client application easier. Ideally, it would be possible to make annotations in the GUI and use them programatically after loading the petri net using the java api. Thus the client application can query the petri net about enabled transitions and marked places and use the annotations on those items to interpret them and decide which transitions to fire.

Is there any way to embed data that can be accessed via the java api? So far, the only solution I see is to use the id field (the 'name' is not shown/accessible in the GUI), which is ok as long as there are no duplicates in the data I want to annotate, and as long as a simple ID is all I need (but I am thinking about a solution that would require more data to be embedded).

sjdayday commented 5 years ago

Hi Florian,

The general approach to integrating with external systems is outlined here: https://github.com/sjdayday/PIPECore/wiki

This paper shows how it was done for a working project: https://arxiv.org/abs/1607.06875

In general, the decision about which of multiple enabled transitions to fire next, is random. If you want to exercise more control, add an external input place to your petri net, and mark it (or not) from your program through the Runner interface. Another approach is to create an external transition, which receives control with a context and access to the entire petri net when the transition is about to fire. The context is an arbitrary Java object, which your program and the external transition code can each access and update.

If you explain a bit more about your use case, I can suggest how you might approach the integration. Or we could Skype at some point.

best, Steve stevedoubleday@gmail.com

On Sun, Oct 14, 2018 at 9:40 AM Florian Kleedorfer notifications@github.com wrote:

For my use case, I'd like to add data to the petrinets so as to make integration with a client application easier. Ideally, it would be possible to make annotations in the GUI and use them programatically after loading the petri net using the java api. Thus the client application can query the petri net about enabled transitions and marked places and use the annotations on those items to interpret them and decide which transitions to fire.

Is there any way to embed data that can be accessed via the java api? So far, the only solution I see is to use the id field (the 'name' is not shown/accessible in the GUI), which is ok as long as there are no duplicates in the data I want to annotate, and as long as a simple ID is all I need (but I am thinking about a solution that would require more data to be embedded).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sarahtattersall/PIPECore/issues/87, or mute the thread https://github.com/notifications/unsubscribe-auth/ACAHxk5WfZmj8ZMcPa2_RN8jGALbGNkTks5uk1r1gaJpZM4XbL3M .

-- Steve Doubleday PhD candidate, Mathematical Behavioral Sciences UC Irvine stevedoubleday@gmail.com 818-648-8381

fkleedorfer commented 5 years ago

Hi Steve,

In general, the decision about which of multiple enabled transitions to fire next, is random.

In our case, control is reversed: the client decides which transition fires, the net provides the information which transitions are available and which places are marked.

My question was more about embedding third-party data in the net. The solution to use the id field isn't bad at all. Using the id, we assign URIs to all the places/transitions that we are interested in for firing or querying. Everything else is handled on the client side.

The only downside for me with this solution is that we have to use the URIs in the GUI, too, which just looks cumbersome. It would be better for readability if we could give places and transitions human readable names in addition to id field. The xml structure suggests that that's possible, but name and id are always the same (at least in uk.ac.imperial:pipe-core:1.0.3).