Page 1 of 1

Setting equation limits

Posted: Tue Sep 28, 2021 5:08 pm
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,

Re: Setting equation limits

Posted: Wed Sep 29, 2021 5:38 am
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