Energy Storage Optimization with PV to Increase the Revenue

8 次查看(过去 30 天)
Dear All,
I am currently working on an optimization problem for a combined Solar energy and Energy Storage. The objective of the optimization is to increase revenue from controlling the battery when to charge and when to discharge depending on when the tariff electricity rate price is high or low. The optimization is fed with one week of data of electricity tariff rate price, demand, and PV.
According to the below code, I am getting an error in the SOC constraint, which is “the following error occurred converting from optim.problemdef.OptimizationExpression to double: Conversion to double from optim.problemdef.OptimizationExpression is not possible.” Therefore, how can I solve this error, please?
% Initializtion
T = size(demand,1);
MaxGenerationLevel = ones (T,1)*MaxGenerationLevel(:,1);
MinGenerationLevel = ones(T,1)*MinGenerationLevel(:,1);
SOC = optimexpr(T,1)*SOC;
BESScap = double(T)*BESScap;
BESScapmax = ones(T,1)*7.200; %
BESScapmin = zeros(T,1);
% initialize the optimization problem
prob = optimproblem ('ObjectiveSense', 'max');
% Decision Variables
Pwr = optimvar('Pwr',T, 1, "LowerBound",-MaxGenerationLevel,"UpperBound",MaxGenerationLevel) %my Decision Variables is the battery power
% Constraints:
% Meet Demand constraints:
%
prob.Constraints.demand = sum(Pwr,2) <= demand;
% % % BESS capacity constraints:
% prob.Constraints.BESScap = BESScapmin <= BESScap <= BESScapmax;
% SOC constraint:
prob.Constraints.SOC = optimconstr(T,1);
for t = 2:T
if BESScapmin <= BESScap(t-1) <= BESScapmax
BESScap(t) = BESScap(t-1) + Pwr(t,1);% first place
SOC(t-1) = BESScap(t-1)/7.200;
else
continue
end
% BESScap(t) = BESScap(t-1) + Pwr(t); % second place
end
prob.Objective = sum(Pwr.*ElectpriceFChourly) %+ sum(PV.*ElectpriceFChourly); % the timing is per hour
Solution = solve(prob);
Moreover, I am happy to modify my code if there are more errors to get the correct optimization solution.
Appreciate your support in advance.
Best regards,
Ali

回答(1 个)

Payam
Payam 2023-3-27
HI Ali,
Did you ever firgure this out? I am facing a similar problem.

类别

Help CenterFile Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by