Hi I have the following code for a linprog optimisation.
for j = 1:2
for i = 1:24
for K = 1:3
for M = 1:3
PV_output(:,:,:) = real(PV_power_output(:,:,:));
WT_output(:,:,:) = WT_power_output(:,:,:);
PVenergy = sum(sum(PV_output(:,:,1)));
WTenergy = sum(sum(WT_power_output(:,:,1)));
f= [((CRF*CC_PV)/PVenergy)+OM_PV; ((CRF*CC_WT)/WTenergy)+OM_WT];
A(:,:,:) = [-PV_output(:,:,K) -WT_output(:,:,M)];
b(:,:) = -Demand(j,i);
lb = zeros(2,1);
ub = [max_PV_area/PV_area max_WT_area/WT_area]';
end
end
end
end
x(:,j,i,K,M) = linprog(f,A,b,[],[],lb,ub)
Where WT_output and PV_output are 3 dimensional 365x24 arrays and Demand is 365x24
I am trying to optimise x1 and x2 for each of the 365x24 elements of Demand and for each dimension so as to find the optimum K and M combination
However as the code currently stands I keep getting the error - "The number of rows in A must be the same as the number of elements of b."
Does anyone have any suggestions?
What does your workspace say about the sizes of A and B? ChrisJamesC right.. It happened with me too.. I forgot to transpose the matrix while performing operations. Try to check the workspace at each step by placing breakpoints. That might help