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!