Setting equation limits

Problems with modeling
Post Reply
KhB
User
User
Posts: 4
Joined: 2 years ago

Setting equation limits

Post by KhB »

Hello,

I do have equations and I want to set upper and lower limits, I did it by using the following code

Code: Select all

con1(r)..                ((tds(r) * 0.14) / (vcPower((pf(r) / (f(r)* cti(r))),0.02) - 1)) =g= 0.2;
con2(r)..                ((tds(r) * 0.14) / (vcPower((pf(r) / (f(r)* cti(r))),0.02) - 1)) =l= 0.5;
however, what I did is by setting con1.up(r)=0.5, but it didn't work, is there any efficient way to do it?

Thanks,
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Setting equation limits

Post by bussieck »

This is a classical ranged constraint. GAMS (and most solvers) do not support this. If you want to reuse the code for the expression you can turn it into a macro

Code: Select all

$macro con1Expr(r)  ((tds(r) * 0.14) / (vcPower((pf(r) / (f(r)* cti(r))),0.02) - 1))
con1(r)..                con1Expr(r) =g= 0.2;
con2(r)..                con1Expr(r) =l= 0.5;
or introduce a defined variable and set bounds on that:

Code: Select all

variable con1Expr(r);
con1(r)..  con1Expr(r) =e= ((tds(r) * 0.14) / (vcPower((pf(r) / (f(r)* cti(r))),0.02) - 1));
con1Expr.lo(r) = 0.2; con1Expr.up(r) = 0.5;
-Michael
Post Reply