I am trying to write an optimization problem based on simulation. Specifically, I have an unknown variable that is the variance of a normal distribution I would like to solve by maximizing some objective function. This objection function involves a sample mean of some complicated expression, where this sample mean is calculated based on a series (1000) of random draws from the normal distribution.
So I declare a variable, which is the variance first:
var theta_y >= 0.00001;
Then I declare a series of random draws as:
var state_y {SIM};
where SIM is just a set of length 1000 (for example) meaning the number of draws.
Then I add the following constraint after the objective function:
subject to Random_State {j in SIM}: state_y[j] = Normal(0, theta_y);
However, this gives me the following warning:
Warning:
line 63 offset 2090
variable argument to random function Normal
context: subject to Random_State {j in SIM}: state_y[j] = Normal(0, >>> theta_y) <<< ;
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:
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.
Thanks very much! Now I understand the issue! I will create a series of random numbers from Uniform distribution, and use the Normal distribution function!