Yes, it is possible. You can add your If-Then condition to linprog
using one 0-1 binary variable and Big-M.
To realize the Logical rule:
if ChargeThermalTES<0,
DischargeThermalTES=0
end
Condition: If ChargeThermalTES<0, then DischargeThermalTES=0
Let's introduce a binary variable y
So we can rewrite the condition as
ChargeThermalTES - M y < 0
which implies that
if y = 0, then DischargeThermalTES must be = 0
if y=1, DischargeThermalTES can be anything
Let's split the equal to
constraint into two inequalities
DischargeThermalTES < M y
DischargeThermalTES > -M y
If y=1, the above two are essentially non-binding.
If y= 0, it will force DischargeThermalTES to become 0.
So with the following constraints combined, you can enforce your logical constraint to the Linear Program.
ChargeThermalTES - M y < 0
DischargeThermalTES < M y
DischargeThermalTES > -M y
y = {0,1} binary, M is a large number.
Hope that helps.