Can someone please know from the following code what’s the reason for in-feasibility error and suggest the solution of error?
cvx_clear
%------------input data --------------------------------------%
Input_data = xlsread(‘h-24-realtestdata.xlsx’);
% -------------- Parameters --------------------------- %
n = Input_data(:,20);
T = 24; % Time horizon
e = 2; % Number of eVB’s
alpha_e = 1.5; % eVB depreciation cost coefficent
soc_cap = 60; % eVB’s capacity
soc_min = 0.15soc_cap; % eVB’s lower bound
soc_max = 0.9soc_cap; % eVB’s upper bound
P_max = 10; % Maximum charging power
P_gridmax = 1000;
soc_inc(1:T,1:e) = 15;
P_min = 0;
% --------------- CVX Begin ---------------------%
cvx_begin
% -------------------Define solver -----------------------%
cvx_solver MOSEK
% ------------------- Continuous Variables -----------------------------%
variables P_gridbuy(T,1) P_gridsell(T,1) P_cha(T,e) P_discha(T,e) soc_short(T,e);
% ------------------ Expressions -------------------------------------%
expressions soc(T,e) A(T,e) B(T,e) C(T,e)
% -------------------- Binary Variables ----------------------%
variable b_buysell(T,1) binary;
variable b_chadischa(T,e) binary;
variable b_sw(T,e) binary;
% ------------------- Initial SOC ---------------------%
soc(1,1:e) = 40;
% --------------------- SOC evolution equations ----------------------%
for t=1:T-1
soc(t+1,1:e) = soc(t,1:e) + P_cha(t,1:e)- P_discha(t,1:e) -(A(t,1:e) + B(t,1:e)- C(t,1:e)) + soc_inc(t+1,1:e).*b_sw(t,1:e);
end
% --------------------- Objective function ----------------------------%
minimize(sum(Input_data(:,19).(P_gridbuy - P_gridsell) + sum(soc_short(T,1:e),2) + sum(alpha_eP_cha.^2,2)…
+ sum(alpha_e*P_discha.^2,2)));
%------------------------- Constraints -----------------------------%
subject to
P_gridbuy + sum(P_discha,2) == P_gridsell + sum(P_cha,2);
soc + soc_short >= soc_max.b_sw
P_gridbuy >= 0;
P_gridsell >= 0;
P_gridbuy <= P_gridmax(1 - b_buysell);
P_gridsell <= P_gridmaxb_buysell;
P_cha >= 0;
P_discha >= 0;
P_cha <= P_maxb_chadischa;
P_discha <= P_max*(1 - b_chadischa);
soc_min <= soc_short <= soc_max
soc_min <= soc <= soc_max;
sum(b_sw,2) >= n;
0 <= P_cha <= (1-b_sw)*P_max
0 <= P_discha <= (1-b_sw)*P_max
% ----------- Linearization constraints -------------%
% following constraints converts the product of continuous and binary variables {(soc + P_cha - P_discha)b_sw} in the soc evolution
% to the auxilary variables (A, B, C)-----------------------%
A <= soc_maxb_sw;
A >= soc_minb_sw;
A <= soc - soc_min(1-b_sw);
A >= soc - soc_max*(1-b_sw);
B <= P_maxb_sw;
B >= P_minb_sw;
B <= P_cha - P_min*(1-b_sw);
B >= P_cha - P_max*(1-b_sw);
C <= P_maxb_sw;
C >= P_minb_sw;
C <= P_discha - P_min*(1-b_sw);
C >= P_discha - P_max*(1-b_sw);
cvx_end