63 views (last 30 days)

Hi all!

I am currently working on an optimization problem to maximize the revenue from a combined wind turbine and energy storage system. With the code below, the system charges and discharges simultaneously at certain times. I am able to change the charge and discharge variables to a single variable with the lowerbound as a negative and positive number corresponding to discharging and charging, respectively. But in doing this, I cannot accurately apply the charge and discharge efficiencies of the storage device.

prob = optimproblem;

% Decision variables

% Energy storage system decision variables

ESS_ch = optimvar('ESS_ch',T,'LowerBound',0,'UpperBound',ESS_Pmax);

ESS_disch = optimvar('ESS_disch',T,'LowerBound',0,'UpperBound',ESS_Pmax);

ESS_SOC = optimvar('ESS_SOC',T,'LowerBound',0,'UpperBound',ESS_Cmax);

% Output power to the grid variables

Grid_E = optimvar('Grid_E',T,'LowerBound',0);

% Energy storage operational constraints

prob.Constraints.energyStorage = optimconstr(T);

prob.Constraints.energyStorage(1) = ESS_SOC(1) == 10;

prob.Constraints.energyStorage(2:T) = ESS_SOC(2:T) == ESS_SOC(1:T-1)*(1-d) - ESS_disch(1:T-1)/eff + ESS_ch(1:T-1)*eff;

% Energy balance constraint (WT_E = wind turbine power output as vector of

% length T)

prob.Constraints.EnergyBalance = Grid_E == WT_E + ESS_disch - ESS_ch;

prob.ObjectiveSense = 'maximize';

prob.Objective = sum(Grid_E.*Price);

I have also attempted to apply a constraint that dictates the charge power multilied by the discharge power of the storage device is equal to zero at any single time step, see below.

prob.Constraints.chargeonoff = optimconstr(T);

for i = 1:T

prob.Constraints.chargeonoff(i) = ESS_disch(i)*ESS_ch(i) == 0;

end

However, when I add this the following error occurs.

Error using optim.problemdef.OptimizationProblem/solve

SOLVE requires a non-empty initial point structure to solve a nonlinear problem.

Any assistance or insight on how to force the program to either charge or discharge at each time step would be greatly appreciated.

Alan Weiss
on 12 Aug 2020

The error message is spot on: when you multiply variables, the problem becomes nonlinear. However, I am sure that you would rather keep the problem linear if you can.

Choose a value M that upper bounds a nonnegative decision variable x. I mean x is ESS_disch or ESS_ch. Create a binary variable z_x that will indicate when x is positive. Set a linear constraint so that z tracks whether x is positive or not.

x <= M*z_x; % if x is positive, z_x has to be positive

Include z in the objective function, so the objective is minimized when z_x = 0.

Now to make the constraint that x and y cannot both be positive, create the linear constraint

z_x + z_y <= 1;

I may have some detail wrong, but I think that you see the idea. You are creating extra integer variables and linear constraints, and turning the problem from a linear programming problem to a mixed-integer linear programming problem. That keeps the problem out of the general nonlinear framework, which is a good thing.

Alan Weiss

MATLAB mathematical toolbox documentation

Ali Almarzooqi
on 23 Aug 2020

Dear James,

I am working on a similar optimization problem except that my renewable source is Solar. I wrote my code in a different way, but it’s still not working correctly.

I would like to use your code if you don’t mind, and can I know what “d” represent in the SOC constraint?

Best regards,

Ali

Ali Almarzooqi
on 24 Aug 2020

Hi James,

Thank you a lot for your clarification and support!! Appreciated.

Best regards,

Ali

Opportunities for recent engineering grads.

Apply TodayFind the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 3 Comments

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/577642-energy-storage-optimisation-problem-separate-charge-and-discharge-constraint#comment_973974

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/577642-energy-storage-optimisation-problem-separate-charge-and-discharge-constraint#comment_973974

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/577642-energy-storage-optimisation-problem-separate-charge-and-discharge-constraint#comment_983090

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/577642-energy-storage-optimisation-problem-separate-charge-and-discharge-constraint#comment_983090

## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/577642-energy-storage-optimisation-problem-separate-charge-and-discharge-constraint#comment_1006108

⋮## Direct link to this comment

https://uk.mathworks.com/matlabcentral/answers/577642-energy-storage-optimisation-problem-separate-charge-and-discharge-constraint#comment_1006108

Sign in to comment.