I have a model like the one shown below. In its current form, the model yields the same solution in each iteration. How can I modify the loop statement to solve the model n times (n=10 in my example) where in each iteration set p1 contains 50 observations but instead of being the first 50 ones (as is the case in my model) they are drawn randomly from the larger set i with or without replacement?
Thank you.
Code: Select all
SETS i /1*100/
p1(i) /1*50/
j /y, x1,x2/
outp(j) /y/
inp(j) /x1, x2/
ALIAS (i,ii) ;
Parameter
data(i,j);
data(i,j) = uniform(0,1);
display data;
PARAMETERS
x(inp,i)
y(outp,i)
;
Positive variables
f(i,p1)
b(i)
;
Variables
z1
;
loop(i,
x(inp,i)=data(i,inp);
y(outp,i)=data(i,outp);
);
Equations
objective1
output1(i,outp)
vinput1(i,inp)
;
objective1.. z1=E=sum(i$p1(i),b(i));
output1(i,outp).. sum(p1,f(i,p1)*y(outp,p1))=G=y(outp,i);
vinput1(i,inp).. sum(p1,f(i,p1)*x(inp,p1))=L=x(inp,i)*b(i);
model m /all/;
set k /1*10/
loop(k,
solve m using nlp minimizing z1;
);