I am writing a code on mimimising hourly load using mixed integer linear programming. Error returned is that number of cols in Aeq must equal number of elements in f, but actually they are both equal to 168. Kindly explain why this error?

%total 168 decision variables
%%5*24 as power shiftable variables for power distribution over time
%%%remaining 2*24 for time shiftable appliances to determine the time shift
%%%power pattern will remain same for them
x1=zeros(1,24); x1(1,19)=1;x1(1,20)=1;
x2=zeros(1,24); x2(1,3:5)=1; x2(1,21:22)=1;
x3=ones(1,24);
x4=ones(1,24);
x5=zeros(1,24); x5(1,1:8)=1; x5(1,20:24)=1;
p6=[1 0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]';
P6(:,1)= p6(:);
for k=1:23
P6(:,k+1)=circshift(p6,k);
end
s6=sum(P6);
p7=[0.8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]';
P7(:,1)=p7(:);
for k=1:23
P7(:,k+1)=circshift(p7,k);
end
s7=sum(P7);
f=[x1 x2 x3 x4 x5 s6 s7];
%bounds
lb1=ones(1,24); ub1=Inf(1,24);
lb2=ones(1,24); ub2=Inf(1,24);
lb3(:,1:24)=0.12; ub3=Inf(1,24);
lb4=zeros(1,24); ub4(:,1:24)=1.5;
lb5(:,1:24)=0.1; ub5(:,1:24)=3;
lbs6=zeros(1,24); ubs6=ones(1,24);
lbs7=zeros(1,24); ubs7=ones(1,24);
lbi=[lb1 lb2 lb3 lb4 lb5 lbs6 lbs7]; ubi=[ub1 ub2 ub3 ub4 ub5 ubs6 ubs7];
lb=lbi'; ub=ubi';
%constraints
Ai=zeros(7,168); Ai(1,1:24)=1; Ai(2,25:48)=1; Ai(3,49:72)=1; Ai(4,73:96)=1; Ai(5,97:120)=1; Ai(6,121:144)=1; Ai(7,145:168)=1;
A=Ai;
B=[1;3;2.88;3;5;1;1];
intcon=(121:168);
size(A)
size(f)
[x,fval,eflag] = intlinprog(-f,intcon,A,B,lb,ub)

6 commentaires

Please mark your code using the {} Code button to make it easier for us to read.
Alan Weiss
MATLAB mathematical toolbox documentation
Sir, i have edited my code. size(A) and size(f) show that number of columns in matrix A is same as number of elements in f. Then why the error?
@nishtha mehta: Please do not ignore the question about formatting your code. Your code is not readable yet. All you have to do is marking it with the mouse and pressing the "{} Code" button. It is in your interest that we are able to read your code.
My problem basically is to minimise the hourly load and obtain an optimal schedule for the day. I have taken x(a,h) power consumption of appliance a during hour h as scheduling variable. From table, non shiftable appliances have x(a,h)>= p for all h belonging to preffered hours (4th constraint). power shiftable appliances have (minimum power)<= x(a,h) <=(maximum power) (5th constraint). time shiftable appliances have fixed power pattern for day like p6=[1 0.5 0 0...0]', but the switching hour may vary for them. so P6 is a matrix of all possible cyclic shifts of pattern p6. and s6 is introduced as a switch vector to obtain schedule for 6th appliance. s6 has only one element 1 and all other elements 0(last 2 constraints). Total consumption of an appliance for all 24 hours has to be equal to total daily requirement (constraint 2). constraint 1 shows that scheduled power consumption of all power shiftable and time shiftable appliances for each hour has to be less than peak hourly load.
Okay.. but your problem was that you passed lower bound and upper bound in the position reserved for equality constraints.

Connectez-vous pour commenter.

 Réponse acceptée

Although you assume that the sizes of the arrays are matching, they do not match. You can use the debugger to find out wh. Type this in the command winodw:
dbstop if error
Now run your code again until it stops in the failing line. Now inspect the values of the used variables to find out, which array has the unexpected size. In addition you can set a breakpoint in the code and step through the program line by line to observe the reasons of the unexpected size.
Please format your code and post a copy of the complete error message. Currently we have to guess, where the error occurres, and this is very hard when the code is not readable.

Plus de réponses (3)

Aeq = []; beq = [];
[x,fval,eflag] = intlinprog(-f, intcon, A, B, Aeq, beq, lb, ub)

2 commentaires

Thank you Sir, it did work. Though it is returning no feasible point that satisfies the constraints and eflag = -2 , but the error that I was encountering previously has disappeared. I will try to reform my code again so as to get a feasible point.
Have you got the feasible solution..?If it is so please send the code that will be better for understanding.

Connectez-vous pour commenter.

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by