0

I'm trying to implement conditional statements in the equations part of GAMS non-linear optimisation. I know that $ statements or for loops are not allowed. I also tried big M method but also failed. What I need is something like this:

Energy_Exported(t) = PV_Generation(t) -Demand(t);

Energy_Exported(t)$[Energy_Exported(t)<0] = 0; 

That would work if implemented on both parameters. But Demand(t) is an optimised positive variable.

I tried enforcing Demand(t) to be positive variable and then

Energy_Imported(t) =g= Demand(t) - PV_Generation(t);

but that also doesn't work - I got unbounded solution.

The problem is that in some cases the outcome of PV_Generation(t) -Demand(t) may be positive or negative. The trick is that variable Demand(t)is optimised.

Many thanks for your help!

  • There's no code here. You're better off posting on Operations Research. – Reinderien May 29 '23 at 14:14
  • 1
    Not sure if I got the whole problem, but focussing on the first code block: Shouldn't it be enough to declare Energy_Exported as positive variable? – Lutz May 30 '23 at 07:25
  • @Lutz unfortunately no as this is variable and Demand that is part of this variable is optimised and it would be set to lower bound all the time when I impose what you suggested. – Liliana Nowakowska May 31 '23 at 13:57

0 Answers0