Infeasible or unbounded model

43 views
Skip to first unread message

bishal

unread,
May 7, 2019, 7:59:48 AM5/7/19
to YALMIP


Hi Professor,
I am been trying to figure out the cause of infeasibility or unboundness in my programme since past few days but i couldn't take a lead. I have copied the matlab code below. Can you please look at it and say where might have i done wrong. With Objective function, the problem arises .
Thank you in advance.
%% optimzation
clc;
clear all;
load chargeLoad.mat; % load the data
stn_load1=chargeLoad(1,1:144);%per 10 minutes of load;
%% taking average of each 6 points 10 minutes to get per hour load
stn_load2=reshape(stn_load1,6,24);
temp=sum(stn_load2)./6; % average
temp1=repmat(temp,4,1);%per 15 minutes load
stn_load=reshape(temp1,1,[]); %making row vector of load per 15 minutes
P_buy_before=stn_load(1,41:64);
P_DR(5:24)=500;
%% power reduction during DR period
M_t1=zeros(1,4);
% for i=5:24
% M_t(1,i)=P_buy_before(1,i)-P_DR(1,i);
% end
M_temp=300+(450-300).*rand(1,20);
M_t=[M_t1 M_temp];
%% medium price range
M_price=[72.75 69.34 64.14 60.00 64.25 81.87 106.00 106 106 106 98.93 98.28 94.90 93.60 94.43 97.09 109.20 130.10 106.00 88.69 75.42 80.12 86.77 63.79]./1000;
price_temp=repmat(M_price,4,1);
price_temp1=reshape(price_temp,1,[]);
price_buy=price_temp1(1,41:64);
k=2; %k= 1 to 4
price_sell=price_buy*k;
price_DR(1:24)=0.2;
income_before=0;
for i=1:24;
    income_before=income_before+P_buy_before(i)*(price_sell(i)-price_buy(i));
end
income_before;
%% optimization problem formulation using yalmip tools
horizon=24;
U_d=binvar(1,horizon);
U_c=binvar(1,horizon);
P_giveup=sdpvar(1,horizon);
P_buy_after=sdpvar(1,horizon);
P_discharge=sdpvar(1,horizon);
P_charge=sdpvar(1,horizon);
soc_bes=sdpvar(1,horizon+1);
P_reduce=sdpvar(1,horizon);
%equlity constraints
F=[];
C_bes=200;
dis_min=5;
dis_max=40;
ch_min=7;
ch_max=20;
for i=1:4
    F=[F,P_buy_after(i)==P_buy_before(i),P_discharge(i)==0];   
end
for i=5:24
    F=[F,dis_min*U_d(1,i)<=P_discharge(1,i)<=dis_max*U_d(1,i)];
end

for i=1:horizon
    F=[F,ch_min*U_c(1,i)<=P_charge(1,i)<=ch_max*U_c(1,i)];
    F=[F,U_d(i)+U_c(i)==1];
end


for i=1:horizon
    F=[F,P_reduce(i)==P_giveup(i)+P_discharge(i)-P_charge(i)];
 F=[F,P_reduce(i)>=M_t(1,i)];
end
for i=1:24
 F=[F,P_buy_after(i)==P_buy_before(i)-P_giveup(i)-P_discharge(i)+P_charge(i)];
end
%% BESS constraint
F=[F,soc_bes(1,1)==0.85];
for i=1:horizon
   F=[F,soc_bes(1,i+1)==soc_bes(1,i)-1/4*(P_discharge(1,i)/(0.85*C_bes))+1/4*(P_charge(1,i)*0.85/C_bes)];
   F=[F,0.2<=soc_bes(1,i+1)<=0.85];
end
% Objective=0;
% for i=1:24
%     Objective=Objective-(1/4*(P_buy_after(i)+P_discharge(i))*price_sell(i));
% end
% for i=1:24
%     Objective=Objective-1/4*(P_reduce(i)*0.25);
% end
% for i=1:24
%     Objective=Objective+1/4*P_buy_after(i)*price_buy(i);
% end
ops=sdpsettings('solver','gurobi');
optimize(F);
% optimize(F,Objective,ops);
a=value(P_giveup)
b=value(P_buy_after)    
value(P_discharge)
value(P_charge)
value(soc_bes)

Johan Löfberg

unread,
May 7, 2019, 8:25:06 AM5/7/19
to YALMIP
Error using load
Unable to read file 'chargeLoad.mat'. No such file or directory.
 

bishal

unread,
May 7, 2019, 10:42:41 PM5/7/19
to YALMIP
Hi professor,
thank you for your response.
Here, I have attached the data file.


chargeload.mat

Johan Löfberg

unread,
May 8, 2019, 2:23:37 AM5/8/19
to YALMIP
Well, as you say, it is obviously unbounded. Adding an arbitrary lower bound on Objective and solving leads to an arbitrarily low objective, and, e.g., 
>> value(P_reduce)

ans =

   1.0e+07 *

  Columns 1 through 8

         0         0         0         0    0.0000    2.6345    0.0000    0.0000

  Columns 9 through 16

    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000

  Columns 17 through 24

    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000


btw, you create an options structure to select solver, but you never use it

bishal

unread,
May 8, 2019, 3:11:11 AM5/8/19
to YALMIP
Hi Professor,
thank you for your quick response.
I got the same result too. I don't know what does that mean. Can you please elaborate it? How to make objective function bounded? and I have an understanding that if we create an option then "Optimize(constraint,objective,option)" yalmip will use the solver by default, isn't that true? 
Hoping for your advice
Thank you.

Johan Löfberg

unread,
May 8, 2019, 3:17:00 AM5/8/19
to YALMIP
It means that the problem formulation you have doesn't make sense, as it is missing some constraints

It's like solving the problem "build the most power generating plant possible, subject to the constraint that is generates at-least 55MW, and the color is green etc etc". Turns out that the solution generates infinite amount of energy, i.e. unbounded. Whoops, forgot the constraint that there is an upper limit on the cost and size of the plant.

To specify solver explicitly, you must send an options argument. otherwise YALMIP decides based on it's own logic
Reply all
Reply to author
Forward
0 new messages