A company receives orders to deliver its good to three differ cities as follows:
ID: 3814601 • Letter: A
Question
Explanation / Answer
NOTE you didin't gave data for variable cost of transportation from Q to other cities. You only gave for P, R. I am using some dummy values for now.
% North west corner rule
x= [[6000 5000 6000 22]
[1000 7000 5500 21] % Modify first three elements of this row as per your data
[9000 8500 8000 25]
[17 31 26 0 ]];
[m n]=size(x);
x1=zeros(m,n);
totalDemand=0;
totalSupply=0;
% Total Demand
for i=1:m-1
totalDemand=totalDemand+x(i,n);
end
% Total Supply
for j=1:n-1
totalSupply=totalSupply+x(m,j);
end
% Northwest algorithm
if(totalSupply >= totalDemand)
for i=1:m
for j=1:n
x11=min(x(i,n),x(m,j));
x1(i,j)=x11;
x(i,n)=x(i,n)-x11;
x(m,j)=x(m,j)-x11;
end
end
else
disp('insufficient supply');
end
totalCost=0;
for i=1:m-1
for j=1:n-1
totalCost=totalCost+(x(i,j).*x1(i,j));
end
end
disp(['Total cost of transportation is ',num2str(totalCost)]);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.