EV charging price optimization

I am currently working on EV charging price optimization. In the fitness function we have the price of charging, battery values (voltage capacity power) and we have Sv, it represents the selection variable of the state of the vehicle "1" for charging state "-1" for discharging and " 0 " for neither charging nor discharging. The main idea is finding the best combination between those three states during 10 intervals to get the best charging price and my question is : what's the correct form of code this part to make the optimization algorithm find the optimal distribution of "1","-1","0" to attain the best price. I have heard a lot of suggestions "rand form,loops.." and I wasn't sure about the adequate form to choose,thank you so much !
function [F, J, x, R] = costfunction(x)
dx = diff(x);%charged value
ds = -dx;%discharged value
V = 360; %voltage of the battery
Q = [80, 80, 80, 80, 80, 80, 80, 80, 80, 80]; %capacity of the battery
N = 0.5; %charging effeciency
M = 1; %dicharging effeciency
R = [1, 5, 6, 7, 2, 9, 5, 9, 3,7];% Price of electricity of the 10 intervals
Sv = [, , , , , , , , ]; %%that is the variable that should be a combination of 1 ,-1 or 0 during 10 intervals
%%for example Sv can be: Sv = [1,-1 ,0 ,-1 , 1, -1,0 ,-1 ,1,1]%%
C = (V * dx .* Q .* R * (1 / N)) .* ((1 + Sv) / 2) .* Sv.^2; % charging cost of one interval
D = (V * ds .* Q .* R * (1 / M)) .* ((-1 + Sv) / 2) .* Sv.^2;% discharging cost of one interval
J = C + D;%Final cost of one interval
y = sum(J);%Final cost at the end of 10 intervals
end

7 个评论

Explain more about these suggestions you got to use the algorithm "rand form,loops.." I've never heard of it.
Whoever suggested you to use that, can't you ask them for help?
Your code just looks like alphabet soup. Did you remove the comments? Or you just never put any in there? Can you at least put in comments and give descriptive variable names? I have no idea what all those single letter variables are.
the idea is that the optimization algorithm finds x values which are charging states (60% 40% 30%....) that gives the best final price after a series of (charging 1 discharging -1 none 0) "which is the Sv" during 10 intervals, what i exactly seek is making the algorithm make the right choice of Sv combination that leads to the best final cost.If there is any thing else to add or clarify please tell me and thanks again !
I don't see that the decision at stage k (Sv(k)) influences C+D at previous or future stages.
Thus as stated, you can choose Sv(k) to minimize C(k)+D(k), and the result will be the global optimal decision strategy minimizing sum(C+D).
But I guess that you forgot to mention some constraints on C+D, didn't you ?
is it possible to treat the Sv(k) as a second input variable and optimize the cost function based on two variables S, Sbk ? thank you
I don't know. Is it somehow related to your question (because I don't see variables S and Sbk in your code) ?
It is x and Sv(k)
Of course you can do this. If you use "ga" to solve, the only thing you must have in mind is that if you define integer variables as the Sv, you cannot have nonlinear equality constraints in your problem formulation.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Surrogate Optimization 的更多信息

产品

版本

R2022b

提问:

2024-2-17

评论:

2024-2-20

Community Treasure Hunt

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

Start Hunting!

Translated by