The AMPL function Normal(mean,var) returns a pseudo-random sample from the normal distribution with specified mean and variance. Called repeatedly, it returns a different value each time:
ampl: print Normal(0,3.5);
-1.8547285751205824
ampl: print Normal(0,3.5);
5.316445484560852
ampl: print Normal(0,3.5);
-2.078602454572513
Normal can be called from AMPL to generate random data for a model, but it is not accessible to solvers. Thus models that apply Normal to decision variables are rejected:
ampl: option solver knitro;
ampl: solve;
Error executing "solve" command:
error processing constraint Random_State[1]:
can't evaluate Normal
(random function of variable argument).
If you only want to assign random initial values to the state_y variables, based on some initial value of theta_y, that is possible:
var theta_y >= 0.00001;
var state_y {SIM};
.......
let theta_y := 0.5;
let {j in SIM} state_y[j] := Normal(0, theta_y);
.......
solve;
Also, it is possible to use a variable as an argument to a Normal distribution function in a model. Several forms of the normal distribution function are available from AMPL’s extended function library.