In CPN-Tools create a integer colset that acts as an index

162 Views Asked by At

I am new to CPN-Tools, and have gone over some of the Real world examples on the website. In my net, I would like to have a col set with positive integer values as shown in this figure.

The issue with the above MWE is, whenever the transition is fired, I get a token with the value 1. I would like the integer value to be incremented every time the transition fires.

Related questions/resources:

I looked at a related unanswered question, which has a similar issue, but they want to range from 1 to n. In my case, I don't know beforehand how many times the transition will be fired.

The examples in the website (protocols, network simulations etc) have nets where there are some fixed number of data that is passed around. However, this does not solve my problem.

1

There are 1 best solutions below

0
On

If you want to have an infinite index, you need another place to store and keep its current value. Then, you can use a variable on the arc to increment the original value.

I did an example to help you see how it is possible with cpn:

Increment cpn

As you can see, when t0 is fired, the value in p0 is incremented by 1. You just need to create variables with the right colset, var x,y: INT in this example. I just gave an initial marking with 0 in p0 to start the counter.