-1

I am minimizing my objective function.

I have a parameter > param Preq{i in 1..n:=Uniform(0.002,Pmax/n) Where Pmax is .0095 and n is 12.

How can I introduce Monte Carlo Simulation in my model file using this Uniform parameter?

Amigo
  • 41
  • 6

1 Answers1

0

The AMPL language has loops. The next example should work for any solver:

param n := 3;
set I := 1..n;

# 
# random numbers
#
param p{i in I} := Uniform(0,1);
display p;

#
# minimal model
# uses a scalar q
#
param q;
var x;
minimize z:x;
e: x = 2*q;

#
# solve in loop
# assign q before solving
#
param results{I};
for {i in I} {
   let q := p[i];
   solve;
   let results[i] := z;
} 
display results;

end;

The AMPL web site has more information: e.g. https://ampl.com/NEW/loop1.html

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39