scalars thi temperature hot in /410/ tho temperature hot out /110/ tci temperature cold in /0/ tco temperature cold out /360/ q heat duty /2000/ u overall heat coefficient /0.1/ a constants of heatX cost function /8600/ b constants of heatX cost function /670/ c constants of heatX cost function /0.83/ r heat capacity ratio p thermal effectiveness tlm1 log mean temperature r ne 1 tlm2 log mean temperature r eq 1 nsmin1 min number of exchanger r ne 1 nsmin2 min number of exchanger r eq 1 ; r = (thi - tho)/ (tco - tci); p = (tco - tci)/ (thi - tci); nsmin1$(r ne 1) = [log([1-r*p]/[1-p])]/[log([1-r+sqrt(r**2+1)]/[r-1+sqrt(r**2+1)])]; nsmin2$(r eq 1) = (sqrt(2)/2)*(p/1-p); tlm1$(r ne 1) = [(thi-tco)-(tho-tci)]/[log((thi-tco)/(tho-tci))]; tlm2$(r eq 1) = thi - tco; display r,p,nsmin1,nsmin2,tlm1,tlm2; variables ft1 correction fator r ne 1 ft2 correction fator r eq 1 p121 effctive p12 r ne 1 p122 effctive p12 r eq 1 a1 heat exchanger area a2 heat exchanger area c1 cost r ne 1 c2 cost r eq 1 ; integer variables ns1 number of exchanger for nsmin1 ns2 number of exchanger for nsmin2 ; equations eq_ft1 correction fator r ne 1 eq_ft2 correction fator r eq 1 eq_ns1 number of exchanger for nsmin1 eq_ns2 number of exchanger for nsmin2 eq_p121 effctive p12 r ne 1 eq_p122 effctive p12 r eq 1 eq_a1 heat exchanger area eq_a2 heat exchanger area eq_c1 cost r ne 1 eq_c2 cost r eq 1 ; eq_ns1.. ns1 =g= nsmin1; eq_ns2.. ns2 =g= nsmin2; eq_p121$(r ne 1).. p121 =e= (1-((1-r*p)/(1-p))**(1/ns1))/((r-((1-r*p)/(1-p))**(1/ns1))); eq_p122$(r eq 1).. p122 =e= p/(p-ns2*p+ns2); eq_ft1$(r ne 1).. ft1 =e= [sqrt(r**2+1)*log([1-r*p121]/[1-p121])]/((r-1)*log((2-p121*(r+1+sqrt(r**2+1)))/(2-p121*(r+1-sqrt(r**2+1))))); eq_ft2$(r eq 1).. ft2 =e= (sqrt(2)*p122)/((1-p122)*log((2-p122*(2-sqrt(2)))/(2-p122*(2+sqrt(2))))) ; eq_a1$(r ne 1).. a1 =e= q/(u*ft1*tlm1); eq_a2$(r eq 1).. a2 =e= q/(u*ft2*tlm2); eq_c1$(r ne 1).. c1 =e= a+b*ns1*[(a1/ns1)**(c)] ; eq_c2$(r eq 1).. c2 =e= a+b*ns2*[(a2/ns2)**(c)] ; model exchanger1 /eq_ft1,eq_ns1,eq_p121,eq_a1,eq_c1/; model exchanger2 /eq_ft2,eq_ns2,eq_p122,eq_a2,eq_c2/; ns1.lo = 1; ns2.lo = 1; p121.l =0.001; p122.l =0.001; ft1.lo = 0; ft1.up = 1; ft1.l=0.5; ft2.lo = 0.8; ft2.up = 1; option optcr=0; *First solve model exchanger1 *Following I need to use ns to gradually +1 to find out that ft>0.8. Get the minimum c1 *the answer is ns1=6 ns1.l=0; repeat( ns1.fx=ns1.l+1; solve exchanger1 using minlp minimizing c1; until ft1.l >= 0.8 ); ns1.fx=ns1.l+1; solve exchanger1 using minlp minimizing c1; ft1.lo = 0.8; ns1.lo=1; ns1.up=100; solve exchanger1 using minlp minimizing c1; $ontext if (r <> 1, solve exchanger1 using minlp minimizing c1 ; else if (r = 1, solve exchanger2 using minlp minimizing c2 ; ); ); $offtext display ns1.l *ns2.l p121.l *p122.l ft1.l *ft2.l a1.l *a2.l c1.l *c2.l ;