arraysprocessdeclarationuppaal

Declaration of multiple processes from the same Template in Uppaal


Is there a way to instantiate multiple processes obtained from the same Template in Uppaal?

For example currently I write (in the System declarations file):

// Template instantiations
P1 = Template(var1);
P2 = Template(var2);
P3 = Template(var3);
P4 = Template(var4);
// Processes into the system
system P1, P2, P3, P4;

But I would like to obtain a more compact form to do so (maybe into an array?) since I actually have to create 50 processes (not just 4). How can I do that?

Note: the variables are of type int[0,1] and I currently define them in the Declarations file as follows:

int[0,1] var1, var2, var3, var4;

Solution

  • Yes, through partial instantiation, here is an example:

    const int N=50; // number of items
    typedef int[1,N] id_t; // bounded integer type with values [1..N]
    int[0,1] var[id_t]; // array of bounded integers indexed by id_t range [1..N]
    P(const id_t id) = Template(var[id]); // template P with argument id
    system P; // instantiate P(1)..P(N) by filling the constant values from id_t range
    

    On the last line Uppaal will auto-fill the constant integer arguments resulting in N processes.

    Note that bool can be used instead of int[0,1].