Hi Guys.. I need to print X values from intlinprog output from all 24 iterations as a matrix, when am trying to assign the values to A matrix its not happening. PLz help

2 visualizaciones (últimos 30 días)
clc
[load_data,txt,raw] = xlsread('Load profile data.xlsx');
schedule=zeros(24,8);
for i=1:24
f=[12 8 9 10 0 0 0 0];
intcon=[5,6,7,8];
A=[ 1 0 0 0 -1080 0 0 0;
-1 0 0 0 360 0 0 0;
0 1 0 0 0 -540 0 0;
0 -1 0 0 0 180 0 0;
0 0 1 0 0 0 -540 0;
0 0 -1 0 0 0 180 0;
0 0 0 1 0 0 0 -108;
0 0 0 -1 0 0 0 360];
b=[0 0 0 0 0 0 0 0];
Aeq=[1 1 1 1 0 0 0 0];
beq=[load_data(i,2)];
lb=[0 0 0 0 0 0 0 0];
ub=[1080 540 540 1080 1 1 1 1];
X=intlinprog(f,intcon,A,b,Aeq,beq,lb,ub);
schedule(i,:)=X'; %% here am getting dimension error??????
end
disp(schedule);

Respuestas (1)

John D'Errico
John D'Errico el 26 de Sept. de 2021
Editada: John D'Errico el 26 de Sept. de 2021
Of course, we cannot answer your question in more depth, since you have not provided your data. But if we look at the screenshot you supplied, it tells us the left hand side of an assignment was 1x8. On the right hand side of the assignment the result was 0x0.
What size is an empty array?
size([])
ans = 1×2
0 0
But consider what intlinprog will return if no solution is found? Yes. An empty array. And then MATLAB will complain. In fact, it will complain for exactly that reason, with exactly that error message. For example...
schedule = zeros(24,8);
schedule(1,:) = zeros(0,0);
Unable to perform assignment because the size of the left side is 1-by-8 and the size of the right side is 0-by-0.
Do you KNOW that a solution ALWAYS exists for all such possible problems? (Clearly not, since in at least one case, no solution is found.)
  2 comentarios
Manikanta Chennu
Manikanta Chennu el 27 de Sept. de 2021
Hi Mr Jhon, thanks for the prompt response.
Basically i am trying to solve unit commitment and electrical generator schedule problem using MILP with matlab builtin function intlinprog. There are eight variable in my problem first four being non integers and last four integers(unit commitmnet solution either 1 or 0) so the X output is a all the 8 variables in 8x1 matrix. This 8x1 output matrix is formed in every iteration (you can see the result in screenshot). so my requirement is to store this result in a form of matrix (as the reslt is 8*1 matrix , i want to convert it into row matrix of 1x8 by transposing it) and then save the results of all 24 iterations as one matrix of size 24x8 and use it for further processing..
I hope i have explained my problem clearly now. for better reference i have attached .m file and excel sheet (.xlsx)used for the program as attachment. Thank you
Manikanta Chennu
Manikanta Chennu el 27 de Sept. de 2021
Do you KNOW that a solution ALWAYS exists for all such possible problems? (Clearly not, since in at least one case, no solution is found.... This satement solved my problem.. Thank you so much Mr. John

Iniciar sesión para comentar.

Categorías

Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by