Filter löschen
Filter löschen

Hi , I get the following error using intlinprog : The number of columns in Aeq must be the same as the length of f. anyway to overcome it?Error using intlinprog (line 135)

9 Ansichten (letzte 30 Tage)
clc;
close all;
clear all;
soc=[30,20,25,45,48,27,29,34,36,29]; %soc
minsoc = 20;
maxsoc = 90;
pevmax=10*1e3;
pevmin=1*1e3;
pevchg=[1,2,2,3.1,4,3.1,2,2,2.5,2.3,3,3.1,3.2,3.3,2.7,2.9,2,2.9,2.5,2,2.1,2,1.5,3,1];
pevdchg=[0.5,1,1.1,1.2,1,1.1,1.1,1,1.9,2.0,1.5,1.4,1.2,1.1,1.3,1.1,1,1.1,1.2,1,1.0,1,1,1,1];
cgrid=[3.26;3.08;2.9;2.68;2.62;2.61;2.56;2.52;2.3;2.47;2.32;2.3;2.05;2.1;2.41;2.51;2.45;2.33;2.48;3.14;3.5;4.6;5.5;5.06;3 ]';
% cgrid=[3, 3.2, 3.2,3,3,3,3,3,4,4,4,4,4,4,2,2,2,6,6,6,3,2,3,3,2]';
delt=1;
cev=24; %battery capacity
chg_eff=0.91;
for n=1:10 % no of vehicles
for i=1:25 % time interval
if (soc(n)>=20) & (soc(n)<=90)
f_SOC_C(n,i)=soc(n)+(pevchg(i)*delt/cev)*100; % charging soc
temp(i)=f_SOC_C(n,i);
soc(n)=temp(i);
elseif (soc(n) > 90)
f_SOC_D(n,i)=soc(n)-(pevdchg(i)*delt/cev)*100; %discharging soc
temp1(i)=f_SOC_D(n,i);
soc(n)=temp1(i);
end
end
end
% chg_time=((f_SOC_D(n,i)- f_SOC_C(n,i)*cev)/(pevchg(n,i)*chg_eff))
for i=1:25
A(:,i)=f_SOC_C(:,i);
end
Z=(f_SOC_D-f_SOC_C); % final soc value stored in Z
%
pchg=[4,3.3,3.3,5.5,3.7,3.9,4.9,4.3,4.5,4.9,5.3,5.5,5.3,5.6,4.9,5.7,2.7,4.5,3.8,5.5,4.7,3.9,2.6,4.4,3.9]*1e3;
pdchg=[1,1.3,1.2,1.5,1.5,1.4,1.2,1,1.4,1,1.2,1.3,1.5,1.7,1.6,1.2,1.5,1.7,1.3,1.4,1.3,1.7,1.8,1.5,1.2]*1e3;
% pevch=((pchg(i)*delt)/(0.9)+(cev*Z))/(1e3)
pevch=(pchg(i)*f_SOC_C)./(1e3); % charging power
pevdch=(pdchg(i)*f_SOC_D)./(1e3); % discharging power
Totalchargingpower=sum(pevch)./(1e3);
Totaldischargingpower=sum(pevdch)./(1e3);
% EV INPUT PARAMETERS
i_ev=[5,9,11,7,10,14,17,19,21,18]; % arrival time
o_ev=[10,12,15,10,14,17,20,22,24,23]; % leaving time
soc=[30,20,25,45,48,27,29,34,36,29]; % Incoming SOC
pchg=[4,3.3,3.3,5.5,3.7,3.9,4.9,4.3,4.5,4.9,5.3,5.5,5.3,5.6,4.9,5.7,2.7,4.5,3.8,5.5,4.7,3.9,2.6,4.4,3.9]*1e3; % Initial charging power
pdchg=[1,1.3,1.2,1.5,1.5,1.4,1.2,1,1.4,1,1.2,1.3,1.5,1.7,1.6,1.2,1.5,1.7,1.3,1.4,1.3,1.7,1.8,1.5,1.2]*1e3; % INITIAL DISCHARGING POWER
pevchg=[1,2,2,3.1,4,3.1,2,2,2.5,2.3,3,3.1,3.2,3.3,2.7,2.9,2,2.9,2.5,2,2.1,2,1.5,3,1]; % maximum charging power
pevdchg=[0.5,1,1.1,1.2,1,1.1,1.1,1,1.9,2.0,1.5,1.4,1.2,1.1,1.3,1.1,1,1.1,1.2,1,1.0,1,1,1,1]; % minimum discharging power
for j=1:10
for n=i_ev(j):o_ev(j)
CHG_COST(j,n)=(pevch(j,n)*cgrid(n)*delt); % charging cost
DCHG_COST(j,n)=(pevdch(j,n)*cgrid(n)*delt); % discharging cost
end
end
%predefined variables
cpv=[0.01;0.02;0.05;0.01;0.02;0.03;0.04;0.02;0.05;0.04;0.03;0.04;0.05;0.06;0.07;0.08;0.09;0.10;0.02;0.02;0.03;0.04;0.1;0.03;0.01];
cevdchg=[0.01;0.02;0.05;0.01;0.02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.5 3.7 3.9 4.2 4.5 5.2 4.7 2.8 6.4 3.6 2.3];
totalload=sum(lddata);
finalload=sum(totalload);
%solar power data for 24 hrs in kW
PV=[0.02,0.02,0.02,0.03,0.01,0.03,0.03,0.04,1.5,1.7,2,2.5,4.8,5.5,7,8.1,9.2,10.2,12.1,15,0.01,0.02,0.01,0.02,0;
0.01,0.05,0.05,0.06,0.05,0.03,0.5,1.3,1.5,1.78,2.5,2.89,3.65,3.97,4.14,4.16,4.1,0.02,0.05,0.06,0.05,0.05,0.03,0.03,0;
0.02,0.02,0.03,0.03,0.03,0.04,0.5,1.2,1.4,1.67,2.3,2.45,2.67,3.56,3.89,4.12,4.15,0.02,0.03,0.03,0.03,0.02,0.02,0.02,0;
0,0,0,0,0,0,0,1.34,1.38,2.56,2.78,3.12,3.17,3.98,4.15,4.17,3.67,5.1,5.2,0.04,0.05,0.06,0.06,0.06,0;
0.16,0.12,0.19,0.15,0.17,0.13,1.45,1.56,1.78,2.12,2.35,2.76,3.12,3.16,3.18,0.045,0.047,0.047,0.049,0.048,0.023,0.012,0.12,0.16,0;
0.01,0.012,0.011,0.1,0.1,0.1,0.1,1.2,1.45,1.55,2.35,2.78,2.89,2.99,3.12,0.13,0.14,0.16,0.17,0.18,0.189,0.145,0.145,0.178,0;
0.1,0.1,0.1,0.1,0.1,0.1,0.15,1.56,1.89,2.34,2.56,2.67,3.13,3.16,3.19,4.2,0.1,0.12,0.13,0.15,0.11,0.12,0.13,0.14,0;
0.1,0.1,0.1,0.1,0.1,0.1,0.1,1.23,1.35,1.89,1.45,1.67,1.98,2.13,2.56,2.98,3.12,3.15,0.01,0.03,0.03,0.02,0.04,0.01,0;
0.01,0.05,0.06,0.07,0.08,0.09,1.34,1.35,1.45,1.56,1.78,1.89,1.98,2.3,2.45,2.67,2.76,3.14,3.16,3.18,3.19,0.1,0.012,0.014,0;
0.05,0.05,0.05,0.06,0.06,0.06,0.07,1.1,1.3,1.35,1.39,1.59,2.34,2.78,3.15,3.18,3.18,2.18,0.02,0.03,0.03,0.03,0.01,0.05,0];
totalsolar=sum(PV);
t=0:24;
plot(t,totalsolar)
xlabel('time(hrs)');ylabel('power(kW)');
for j=1:10 % no of houses
for m=1:25
generation(j,m)= PV(j,m)+pevdch(j,m); % generation
TOTALGEN=sum(generation)./(1e3);
demand(j,m)=lddata(j,m)+pevch(j,m); % demand
TOTALDEM=sum(demand)./(1e3);
TOTAL_PGRID(j,m)=generation(j,m)-demand(j,m); % grid power
totalpgrid=sum(TOTAL_PGRID);
end
end
% for j=1:10
% for n=i_ev(j):o_ev(j)
% grid_cost(j,n)=(TOTAL_PGRID(j,n).*cgrid(n)*delt)
% end
% end
for s=1:10
for k=1:25
PV_COST(s,k)=PV(s,k).*cpv(k)*delt;
T_PVCost=sum(PV_COST); % total PV COST
finalpv=sum(T_PVCost);
PEVDCH_COST(s,k)=pevdch(s,k).*cevdchg(k)*delt;
T_PEVDCHcost=sum(PEVDCH_COST);% TOTAL PEV DISCHARGING COST
finalpevdchcost=sum(T_PEVDCHcost);
PEVCH_COST(s,k)=pevch(s,k).*cevchg(k)*delt;
T_PEVCHcost=sum(PEVCH_COST); % TOTAL PEV CHARGING COST
finalpevchcost=sum(T_PEVCHcost);
end
end
fq=[T_PVCost+T_PEVDCHcost+T_PEVCHcost];
for h=1:10
for d=1:25
grid_cost(h,d)=TOTAL_PGRID(h,d).*cgrid(d)*delt;
totalgridcost=sum(grid_cost);
end
end
F=((PV_COST+PEVDCH_COST-PEVCH_COST)-(grid_cost))./(1e3);
f=[T_PVCost;T_PEVDCHcost;T_PEVCHcost]';
size(f)
ans = 1×2
25 3
intcon=1;
%linear Inequality constraints
A=[];
b=[];
%linear Equality constraints
Aeq=[T_PVCost;T_PEVDCHcost;T_PEVCHcost];
% Aeq=[18.5403;
% 686.4570;
% 1.2357e3];
[m,n] = size(Aeq)
m = 3
n = 25
Aeq = Aeq';
beq=[totalload];
size(beq)
ans = 1×2
1 25
%bound constraints
lb=[1; 3.3; 0.2];
ub=[Inf;Inf;1];
x0=[];
options=optimoptions('intlinprog','display','iter');
x=intlinprog(f,intcon,A,b,Aeq,beq,lb,ub,x0,options);
Error using intlinprog
The number of columns in Aeq must be the same as the number of elements of f.
  1 Kommentar
Torsten
Torsten am 21 Mär. 2023
How many solution variables do you have ?
How many equality constraints do you have ?
How many integer constraints do you have ?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 21 Mär. 2023
You have 3 unknown variables, but your Aeq matrix has only 1 column. That makes it impossible for intlinprog to form the matrix-vector product Aeq*x(:).

Kategorien

Mehr zu Linear Programming and Mixed-Integer Linear Programming 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