Filter löschen
Filter löschen

To minimize the charging cost of electric vehicles

4 Ansichten (letzte 30 Tage)
Suganthi D
Suganthi D am 22 Jun. 2022
Kommentiert: Suganthi D am 23 Jun. 2022
clc;
clear all;
close all;
timelen=0:10:50;
finaltime=timelen;
for kgen=1:23
finaltime=[finaltime kgen*100+timelen];
end
elec_price=ones(1,length(finaltime))*4;
loc=find(finaltime>=1100 & finaltime<1500);
elec_price(loc)=5.2;
loc=find(finaltime>=1500 & finaltime<2000);
elec_price(loc)=5.5;
loc=find(finaltime>=2000 & finaltime<2300);
elec_price(loc)=6;
total_elec_price=sum(4+5.2+5.5+6)
pmax=6.6*1e3;
pmin=6.6*1e3;
Emax=24*1e3;
socthlow=20;
socthhigh=90;
soclower_accept=20;
delt=10/60;
gamma=0.9500; %%% denotes charging/discharging rate (-1,1)
gamma1=-0.9500;
del_gamma=0.0225;
del_gamma1=-0.0225;
data_pass{1}=pmax;
data_pass{2}=Emax;
data_pass{3}=socthlow;
data_pass{4}=socthhigh;
data_pass{5}=soclower_accept;
data_pass{6}=elec_price;
data_pass{7}=delt;
data_pass{8}=gamma;
data_pass{9}=gamma1;
data_pass{10}=del_gamma;
data_pass{11}=del_gamma1;
alphadata=[];
obj_sel=1;
data_pass{21}=obj_sel;
data_pass{22}=alphadata;
socintij1=[38 40 55 60 79];
EVSE1_arr_time=[0500 0912 1312 2102 2302];
EVSE1_leave_time=[0900 1306 2100 2300 0459];
k1=2.64;
j=0;
to=0:23/143:23
for t1=1:length(to)
for i=1:length(to)
for m=length(EVSE1_arr_time)
for k=1:length(socintij1)
if socthlow >= 20 & socthhigh<= 90
if j<=EVSE1_arr_time & j<=EVSE1_leave_time
j=j+1
end
soc_chg= k1*delt+socintij1;
soc_dchg=socintij1-(k1*delt);
to
gamma=gamma+(del_gamma);
end
end
end
end
end
% if pmax >=6.6 & pmin<=6.6
chg_power=(gamma*pmax)/(1e4)
dischg_power=(gamma1*pmax)/(1e4)
% end
t=0:1:23;
plot(t, chg_power)
xlabel('time((h)');ylabel('power(kW)');
chg_cost=elec_price*chg_power*delt
total_value=sum(chg_cost);
dschg_cost=elec_price*dischg_power*delt
total=sum(dschg_cost);
subplot(2,2,1)
plot(finaltime,chg_cost);
xlabel('time(h)');ylabel('cost(rs/kWh)')
legend('charging cost')
subplot(2,2,2)
plot(finaltime,dschg_cost);
xlabel('time(h)');ylabel('cost(rs/kWh)')
legend('discharging cost')
  2 Kommentare
DGM
DGM am 22 Jun. 2022
So what's the question?
Other than the unsuppressed output wasting a ton of time and the random indentation (which I fixed), the code runs without error.
Sam Chak
Sam Chak am 22 Jun. 2022
@Suganthi D, eh... Where is the mathematics of the "Charging Cost" function that you want to minimize?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Karim
Karim am 22 Jun. 2022
Which error do you obtain?
I changed
if j<=EVSE1_arr_time & j<=EVSE1_leave_time
into
if all(j<=EVSE1_arr_time) && all(j<=EVSE1_leave_time)
and then it seems to run and produce a figure, see below
timelen=0:10:50;
finaltime=timelen;
for kgen=1:23
finaltime=[finaltime kgen*100+timelen];
end
elec_price=ones(1,length(finaltime))*4;
loc = finaltime>=1100 & finaltime<1500;
elec_price(loc)=5.2;
loc = finaltime>=1500 & finaltime<2000;
elec_price(loc)=5.5;
loc = finaltime>=2000 & finaltime<2300;
elec_price(loc)=6;
total_elec_price=sum(4+5.2+5.5+6);
pmax=6.6*1e3;
pmin=6.6*1e3;
Emax=24*1e3;
socthlow=20;
socthhigh=90;
soclower_accept=20;
delt=10/60;
gamma=0.9500; %%% denotes charging/discharging rate (-1,1)
gamma1=-0.9500;
del_gamma=0.0225;
del_gamma1=-0.0225;
data_pass{1}=pmax;
data_pass{2}=Emax;
data_pass{3}=socthlow;
data_pass{4}=socthhigh;
data_pass{5}=soclower_accept;
data_pass{6}=elec_price;
data_pass{7}=delt;
data_pass{8}=gamma;
data_pass{9}=gamma1;
data_pass{10}=del_gamma;
data_pass{11}=del_gamma1;
alphadata=[];
obj_sel=1;
data_pass{21}=obj_sel;
data_pass{22}=alphadata;
socintij1=[38 40 55 60 79];
EVSE1_arr_time=[0500 0912 1312 2102 2302];
EVSE1_leave_time=[0900 1306 2100 2300 0459];
k1=2.64;
j=0;
to=0:23/143:23;
for t1=1:length(to)
for i=1:length(to)
for m=length(EVSE1_arr_time)
for k=1:length(socintij1)
if socthlow >= 20 && socthhigh<= 90
if all(j<=EVSE1_arr_time) && all(j<=EVSE1_leave_time)
j=j+1;
end
soc_chg= k1*delt+socintij1;
soc_dchg=socintij1-(k1*delt);
gamma=gamma+(del_gamma);
end
end
end
end
end
% if pmax >=6.6 & pmin<=6.6
chg_power=(gamma*pmax)/(1e4);
dischg_power=(gamma1*pmax)/(1e4);
% end
t=0:1:23;
% plot(t, chg_power)
% xlabel('time((h)');ylabel('power(kW)');
chg_cost=elec_price*chg_power*delt;
total_value=sum(chg_cost);
dschg_cost=elec_price*dischg_power*delt;
total=sum(dschg_cost);
figure
subplot(2,1,1)
plot(finaltime,chg_cost);
xlabel('time(h)');ylabel('cost(rs/kWh)')
grid on
legend('charging cost','Location','northwest')
subplot(2,1,2)
plot(finaltime,dschg_cost);
xlabel('time(h)');ylabel('cost(rs/kWh)')
grid on
legend('discharging cost','Location','southwest')
  5 Kommentare
Suganthi D
Suganthi D am 23 Jun. 2022
i didn't use any algorithm on the above code, but i have decided to work on mixed integer linear programming algorithm .

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Workspace Variables and MAT-Files finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by