About a few days ago, I asked a similar question.
I used to ask the scalar loop(Thanks Mr. Michael solve this problem), now I have problems when it becomes a matrix.
This is a scalar solution. The key code is this paragraph
Code: Select all
scalar minc1 /inf/, bestns1 /1/,n1;
while(bestns1 < 10,
bestns1=bestns1+1;
ns1.fx=bestns1;
option optcr=0.0001;
solve exchanger1 using minlp minimizing c1;
* Optimal or feasible solution
if ((exchanger1.modelstat=1 or exchanger1.modelstat=8)and(c1.l<minc1),
minc1 = c1.l;
n1=bestns1;
);
);
display minc1,n1;
Now I want to ask how to make a code when it comes to solving seven kinds of data at the same time.(7 kinds of data brought to the above file can have 7 answers) Would not describe the part of the code. (I don't know how to turn "" ns1.fx(heatx)"" into scalar)
Meaning is probably like this.
Code: Select all
parameters
minc1(heatx) /ex1*ex7 inf/
bestns1(heatx)/ex1*ex7 1/
;
bestns1(heatx)$(r(heatx) ne 1)=1;
parameter n1,bestp121,bestft1,besta1;
while(bestns1(heatx)<10,
ns1.fx(heatx)=bestns1(heatx)+1;
solve exchanger1 using minlp minimizing z1;
if ((exchanger1.modelstat=1 or exchanger1.modelstat=8) and (c1.l(heatx) < minc1(heatx)),
minc1(heatx) = c1.l(heatx);
n1(heatx)=bestns1(heatx);
bestp121(heatx)=p121.l(heatx);
bestft1(heatx)=ft1.l(heatx);
besta1(heatx)=a1.l(heatx);
);
);
option decimals = 4;
display minc1,n1,bestp121,bestft1,besta1;