Infeasibility Problem

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.9
soc_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_max
b_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_max
b_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_min
b_sw;
B <= P_cha - P_min*(1-b_sw);
B >= P_cha - P_max*(1-b_sw);
C <= P_maxb_sw;
C >= P_min
b_sw;
C <= P_discha - P_min*(1-b_sw);
C >= P_discha - P_max*(1-b_sw);

 cvx_end

If you google

debugging infeasible models

you’ll get some tips on how to proceed.

Hi Mark!

Thanks for the suggestion. I followed your suggestion, it proved very helpful to me. I have diagnosed that the constraints that constraints that linearize the multiplication of continuous and binary variable. I followed the linearization process from https://orinanobworld.blogspot.com/2010/10/binary-variables-and-quadratic-terms.html?showComment=1510547164758#c8374919667843927690. But it doesn’t worked here in CVX. Is there anything to comply further with?? Please help.

What do you mean by “doesn’t work”? Do you have reason to believe that your model is actually feasible, at least if properly implemented?

Hi Mark!
I have a query related to the product of continuous and binary variables at different times intervals.
My original constraint looks like this;

for t = 1:T-1
X(t+1) = X(t) - X(t)*b(t+1) ------------- (Original Eq:)
end
The above equation dictates how X evolves over time t.
In above equation, X is a continuous and b is binary variable, so the constraint is clearly non-convex and violet the CVX rule set. I used the following trick to make the problem comply with “DCP rule set”;
Let A = X(t)*b(t+1) then we have;

      A(t)  <= U*b(t+1)
      A(t)  >= L*b(t+1)
      A(t)  <= X(t) - L*(1 - b(t+1))
      A(t)  >= X(t) - U*(1 - b(t+1))

(Note: these four inequalities are outside above mentioned “for loop” for original equation)
Where U and L are upper and lower bound of X.
Now “Original equation” becomes;
X(t+1) = X(t) - A(t) this is now in compliant with DCP ruleset and can be programmed using CVX.
But I don’t know how do I do it???

Thanks in advance!
Shami

If it is compliant with DCP ruleset and can be programmed using CVX, then what do you not know how to do? Either put the constraints in a for loop, or redefine (shift) b so that your variables in the constraints will be in terms of index t, thereby allowing you to avoid use of a for loop and avoid explicit mention of the indices…