Random number in Uppaal

☆樱花仙子☆ 提交于 2019-12-21 16:44:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!