[AMPL 25055] Warning: variable argument to random function Normal (simulation based optimization)

Hi everyone,

Thanks very much for your help in advance!

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) <<< ;

And I cannot solve this optimization problem

Thanks again very much for your help!

All the best,
Jun

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.

Your question has been moved to our new user forum at discuss.ampl.com, and a response has been posted there. To see the response, use this link:

https://discuss.ampl.com/t/ampl-25055-warning-variable-argument-to-random-function-normal-simulation-based-optimization/1216/2

To reply, click the red “Reply” button that follows the response. (Do not send an email reply to this message.)

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!

Again, thanks a lot!