Conditional Equations with Variable in GAMS
Posted: Mon May 29, 2023 4:53 pm
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:
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
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. If it's negative I want to set the variable to 0.
Many thanks for your help!
Code: Select all
Energy_Exported(t) = PV_Generation(t) -Demand(t);
Energy_Exported(t)$[Energy_Exported(t)<0] = 0;
I tried enforcing Demand(t) to be positive variable and then
Code: Select all
Energy_Imported(t) =g= Demand(t) - PV_Generation(t);
The problem is that in some cases the outcome of PV_Generation(t) -Demand(t) may be positive or negative. If it's negative I want to set the variable to 0.
Many thanks for your help!