logical condition with equation definitions and variables

Problems with syntax of GAMS
Post Reply
M.Walde
User
User
Posts: 16
Joined: 6 years ago

logical condition with equation definitions and variables

Post by M.Walde »

Hi guys,

I got another question about logical conditions for equations. As I saw in the documentation it is illegal to use if-else operations for the definition of equations.
That's why I wanted to use the $ operator to put logical conditions into account.

This is the important code:

sets i time steps /0*720/;

variables
m_rc_ts(i) mass flow from receiver to thermal energy storage
m_pb_ts(i) mass flow from power block to thermal energy storage
dec(i) decision variable stating the mode of storage operation;


equations
e_charge setting decision variable for charging tank operation mode
e_discharge settings decision variable for discharging tank operation mode
e_no_use setting decision variable for no use tank operation mode
e_m_rc_ts_restrict restrict the mass flow from receiver for discharging mode
e_m_pb_ts_restrict restrict the mass flow from power block for charging mode
e_T_ti_charge equ for inlet temperature of thermal energy storage for charging mode
e_T_ti_discharge equ for inlet temperature of thermal energy storage for discharging mode;

e_charge(i+1) .. dec(i+1)$(m_rc_ts(i+1) > 0) =e= 1;

e_discharge(i+1) .. dec(i+1)$(m_pb_ts(i+1)) =e= 2;

e_no_use(i+1) .. dec(i+1)$(m_rc_ts(i+1) = 0 and m_pb_ts(i+1) = 0) =e= dec(i);

e_m_rc_ts_restrict(i+1) .. m_rc_ts(i+1)$(dec(i+1) = 2) =e= 0;

e_m_pb_ts_restrict(i+1) .. m_pb_ts(i+1)$(dec(i+1) = 1) =e= 0;

e_T_ti_charge(nfirst,i+1) .. T_fl(nfirst,i+1)$(dec(i+1)= 1) =e= T_ro;

e_T_ti_discharge(nfirst,i+1) .. T_fl(nfirst,i+1)$(dec(i+1)= 2) =e= T_po(i+1);


When I run the model I get the compilation error 53 and 256:

*** Error 53 in 180312_decision_model.gms
Endogenous $ operation not allowed
*** Error 256 in 180312_decision_model.gms
Error(s) in analyzing solve statement. More detail appears
Below the solve statement above


Out of research I found some people saying, that you can't use variables with logical conditions, and that's why this error pops up.
My question would be, how to use equations and variables with logical conditions, since this is an essential part of my model.

For better understanding: The model is about a thermal energy storage. The storage can be run in 3 stages: charge, discharge and no use. For charge and discharge mode the inlet temperature is different and the massflow enter from a different direction. That's why I need to involve logical conditions.

I hope, that you guys understand my problem. I would be glad, if you could give me some tips about it.
Anyway thanks in advance!

Cheers
Max
Manassaldi
User
User
Posts: 118
Joined: 7 years ago
Location: Rosario - Argentina

Re: logical condition with equation definitions and variables

Post by Manassaldi »

Hi, logical conditions apply to the equations.

e_charge(i+1)$(m_rc_ts(i+1) > 0).. dec(i+1) =e= 1;

Best
M.Walde
User
User
Posts: 16
Joined: 6 years ago

Re: logical condition with equation definitions and variables

Post by M.Walde »

Thanks a lot for your help. I see, that my declaration didn't really make sense. I corrected it.

Anyway unfortunately this doesn't solve my problem. Now I get "error 52 Endogenous $-control operations not allowed" as an error, which is basically the same.

I found this threat in the archive: viewtopic.php?f=13&t=6795
There it is quite understandable explained, why you can't use the $ operation on equations with decision variables.

My question is now, whether there is any possible way to use make variables logically dependent on other variables.
Or is this with GAMS simply not possible? I'm using minlp with scip solver by the way.
Manassaldi
User
User
Posts: 118
Joined: 7 years ago
Location: Rosario - Argentina

Re: logical condition with equation definitions and variables

Post by Manassaldi »

Hi, the equations can not vary during the resolution. To relate variables or take logical decisions you will need to use binary variables.
Best!
M.Walde
User
User
Posts: 16
Joined: 6 years ago

Re: logical condition with equation definitions and variables

Post by M.Walde »

Thank you very much for your fast answer!
It was really helpful.
Post Reply