/**
* This file demonstrates how to generate custom delay distributions
* as described in Uppaal SMC Tutorial, Section 7.2.
*/
const double PI = 3.14159265358979323846;
double stdNormal() { // N(0, 1)
return sqrt ( -2*ln(1-random(1))) * cos(2*PI*random(1));
}
double Normal(double mean, double stdDev ) {
return mean + stdDev * stdNormal();
}
double f() { // generates N(10.0, 1.0)
double res = -1.0;
// negative values violate the invariant "x<=delay", where x==0,
// thus avoid them:
while (res < 0)
res = Normal(10.0, 1.0);
return res;
}
P1clock x, delay;doneP2clock x;
double delay; // instead of clockdone
//system P1, P2; // slow due to small step integration in P2
system P1; // fast due to large step integration.
//system P2; // slow due to small step integration in P2
Pr[<=10] (<> P1.done)
Let's wait for the mean delay and estimate what is the probability of reaching done.
Expect ~0.5 and the probability density distribution to be half of the bell curve.
Set the statistical parameter ε to 0.005 or smaller for more data and better resolution.
Pr[<=10] (<> P2.done)
The same as above, except using double instead of stopwatch.
Uncomment "system P1, P2" in the system declaration to include process P2.
E[<=100; 1000](max: P1.x)
Generate runs of up to 100 time units (far beond the f() distribution) and estimate the final/largest value of x.
Expect ~10.0, and full bell curve around 10 in the probability density distribution plot.
E[<=100; 1000](max: P2.x)
The same as above.
E[<=1; 1000](max: P2.delay)
we can also inspect the distribution of the delay variable without waiting for the actual delay.