Question

I'm having issues with matlab linprog code. The optimisation function is the overall cost for the 24 period, just considering fuel costs of the boiler.

Purpose of simulation:

Optimisation of the charge/discharge behaviour of a Thermal Energy Storage (TES) for a 24h operation of a system consisting of a boiler, heat demand, and the TES. The price of the gas are time-varying.

Problem:

If the TES is ideal (efficiency=100%), I have no constraint that stops the system from charging and discharging at the same time. I CANNOT use one variable to describe charge and discharge. I do need them separated

At the moment I have the following constraints to describe the min/max charge/discharge rates (and of course some others):

maxChargeThermalTES>=ChargeThermalTES<=0
maxDischargeThermalTES >= DischargeThermalTES <=0

is it possible to realise the following logical rule within the constraints of linprog?

if ChargeThermalTES<0,
   DischargeThermalTES=0
end

all approaches, e.g. with a binary variable (to describe if the system is charging or discharging) do not work, as the binary variable always depends on the output of the optimisation.

Was it helpful?

Solution 2

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.

OTHER TIPS

You cannot enforce such logical rule in linear programming.

However, what you can do is the following :

1\ solve your linear program, without this constraint. Get the optimal cost of your objective function (lets name it OldCost).

2\ Then change your linear program this way :

  • add a constraint : old objective function should be between OldCost * (1-Epsilon) and OldCost * (1+Epsilon)

  • the new objective function to minimize is ChargeThermalTES + DischargeThermalTES.

Cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top