问题
How can I create a random number when I define a global declaration in an Uppaal program?
I want to have a variable that contains a random number as in a C program:
int x = rand (100);
回答1:
According to folks at Uppaal mailing list , this code snippet select: i : int[0,3]
will non-deterministically bind i to an integer in the range 0 to 3.
So, in Your case just use select: x : int[0, 100]
.
回答2:
I think the proper answer is: it is not possible when defining the global declaration.
The syntax that @Kamiccolo provided I think is misleading: there does not exist a syntactic construct like "select: ..." in Uppaal.
The only possible way, at now, is:
- add a global variable "int x = 0;"
- add an initial transition whose "select" clause assign "x : int[0,100]", as the mailing list (and the manual) suggest
来源:https://stackoverflow.com/questions/19522823/random-number-in-uppaal