Petri Net: nnNET1 Matrix Configuration in C

Below is the code for nnNET1.c. In order to understand the matrices and math see this link:

http://www.techfak.uni-bielefeld.de/~mchen/BioPNML/Intro/MRPN.html

There are two matrices I and O, input and output, with below C expressions to configure the Petri Net. The programmer needs only to specify the 1s since the use of calloc in memory allocation guarantees the 0 content memory:

net.PetriNet.I[0][0] = 1.0;

or

net.PetriNet.O[0][1] = 1.0;


printf("I am nnNET1\n");
nnDebug = TRUE;

/* Petri Net has to be configured before it can be executed, therefore these
lines of codes are in the main() to configure the Petri Net and cannot be
placed in the progXXX functions.

*/

nnPetriMatrices(&net, 8, 11);

printf("matrices alloted \n");

/* map the transitions into progs */
InitProgs();

/* FIXME: these should be in a file */
net.PetriNet.progs[0] = nnBoot2;
net.PetriNet.progs[1] = nnListen;
net.PetriNet.progs[2] = nnGenesis;
net.PetriNet.progs[3] = nnPartitionI2;
net.PetriNet.progs[4] = nnTraining;
net.PetriNet.progs[5] = nnNil;
net.PetriNet.progs[6] = nnAxonTOInput;
net.PetriNet.progs[7] = nnNil;

/* FIXME: Petri Net should be read from a text file */
/* TODO: Option should be provided for over the net Petri Net specification */

/* initialize the petri net, only do 1s since we used calloc */
net.PetriNet.I[0][0] = 1.0;
net.PetriNet.I[1][1] = 1.0;
net.PetriNet.I[2][2] = 1.0;
net.PetriNet.I[2][3] = 1.0;
net.PetriNet.I[2][4] = 1.0;
net.PetriNet.I[3][2] = 1.0;
net.PetriNet.I[3][4] = 1.0;
net.PetriNet.I[3][5] = 1.0;
net.PetriNet.I[4][2] = 1.0;
net.PetriNet.I[4][6] = 1.0;
net.PetriNet.I[5][2] = 1.0;
net.PetriNet.I[5][7] = 1.0;
net.PetriNet.I[6][8] = 1.0;
net.PetriNet.I[7][2] = 1.0;
net.PetriNet.I[7][9] = 1.0;

net.PetriNet.O[0][1] = 1.0;
net.PetriNet.O[1][2] = 1.0;
net.PetriNet.O[1][3] = 1.0;
net.PetriNet.O[1][4] = 1.0;
net.PetriNet.O[2][4] = 1.0;
net.PetriNet.O[2][8] = 1.0;
net.PetriNet.O[3][8] = 1.0;
net.PetriNet.O[4][8] = 1.0;
net.PetriNet.O[5][8] = 1.0;
net.PetriNet.O[6][2] = 1.0;
net.PetriNet.O[7][10] = 1.0;

nnPetriPostProc(&net);
This entry was posted in C/C++, Documentation, Software. Bookmark the permalink.

Leave a Reply