PetriSim Tour (3/4)

Suppose that the user is going to build a simulation model based on the P-net TRANS. After downloading PetriSim, you have an "empty" user model called EMPTY in the subdirectory C:\PETRISIM\EMPTY. There are all files needed by PetriSim models and the units USER and USERDATA in their initial form. To start work on a new model, the best way is creating a subdirectory - here C:\PETRISIM\TRANS - and copying all files from C:\PETRISIM\EMPTY to this subdirectory. Then the user has made a shortcut to the file S.BAT in this directory and started it.
There is no default net, so the next step is loading the net TRANS to RAM. If the options are saved now, next time the net TRANS will be loaded automatically.

Let's assume, that there are three possible message transmission times (0.5, 1.2 and 1.9 sec) with corresponding probabilities 0.7, 0.2 and 0.1 respectively. This may model a situation with none, one or two re-transmissions. The model should find the number of transmitted messages and the average message trasmission time.

A possible solution is this: generate a random delay in the transition t1 (message transmission). At the end of the experiment get the statistics of the transition t1 and display the number of firings (number of transmitted messages) and the average firing duration (average message transmission time). Both is provided by PetriSim. So first the user has to write a starting snippet of the trasition t1 to generate its random firing delay. The following screen has been captured after clicking t1 by the right button and after selecting the menu option to start writing/editing the starting snippet:

After clicking the left button (or Enter or "S") PetriSim opens a warning window, giving a chance to cancel the operation, because the snippet so far does not exist. After confirmation PetriSim creates an empty snippet procedure, here this one:

Procedure _PS1; {Starting snippet of the transition t1 (t1)}
Begin
End;

Then it starts the text editor and passes the file name as a parameter. The following screen has been captured after writing the code in the standard editor C:\WINDOWS\COMMAND\EDIT.COM (that can be changed):

After return from the editor PetriSim generates all necessary source files. Writing this snippet is all that is needed provided that the user is satisfied with the standard PetriSim outputs. Note that the unit USER has not been modified (though you may change the value of the constant UserNetInfo to identify the model). To incorporate the new snippet into the model the whole program PETRISIM.EXE must be re-compiled. When first entering the Pascal IDE you have to modify Pascal directories: activate Options - Directories ... and change the EXE & TPU directory to C:\PETRISIM\TRANS. Then save Pascal options. Compile and run the program PETRISIM.PAS. In PetriSim session you can change simulation setup and change simulation mode to User experiment (5). You may save PetriSim options to keep these settings. Start the simulation to get the results on the screen and in a text file. The following is the beginning of the table with statistics on all transitions:

Transitions:

Name      Utilization   MeanFire        Min       Max    StDev   Firings
========================================================================
t1              1.000      0.795   0.500000     1.900    0.479      1259
....

The experiment duration was the default 1000 time units (in this model interpreted as seconds). The figures will slightly change in each experiment according to the random values generated. Note that the above snippet uses the function Random - the standard Pascal random generator. PetriSim performs Randomize before starting a user experiment. Use functions from the unit RANDOMS to generate random numbers with theoretical and empirical distributions - see the manual. You can also set the seed RandSeed of the random generator to generate the same sequence of random numbers in each experiment. This has to be done in the model initialization procedure UserInit in the unit USER.

To get model-related outputs there are few necessary changes in the unit USER. They can be done out of PetriSim by Pascal's editor or during the PetriSim session. The following screen has been captured before activating the menu option (the pull down menu is open by selecting the P-net name) that will start editing on the file USER.PAS:

These are the modifications in the unit USER:

Look at the complete unit USER.PAS. You can also save it as the USER.PAS text file provided you remove the HTML tags.
After editing USER.PAS the whole program PETRISIM.EXE must be re-compiled.

[ Next page | Previous page | Petrisim home page ]