0% found this document useful (0 votes)
5 views4 pages

TP - Matlab Program

Thanks

Uploaded by

vijay10ms
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

TP - Matlab Program

Thanks

Uploaded by

vijay10ms
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
@% CHECKED BALANCED{UNBALANCED Problem if sum(A)==sum(B) fprintf (‘Given Transportation Problem is Balanced\n")+ else fprintf ("Given Transportation Problem is UnBalanced\n')s if sum(A)> Cosi cost = 3 44 a2 4 2 1 5 2 VAM MATLAB CODE Icost = Cost: Save the Cost Copy X = zeros(size(Cost)) + Shitaize Aloeation [m,n] = size (Cost)? Finding Rows-Coloan BES = mén-1; ‘Total BFS. FINDING PENALTY VALUES =. Col = sort (Cost, 1); ‘1 Ascending Order Row = sort (Cost, 2); PRow = Row(:,2)-Row(:,1)7 —% Penalty ROW PCol = Col(2,:)-Col(1,:); —% Penalty Col. R = max(pRow) “Find Max Penalty ROW = max(pcol) ‘Find Max Penatty Col Rmax = find (pRow==max (R,C))7 max = indipcoi=max r, cy); * Ma Pasir Va (Cr = Cost (Rmax, :)# Af max (pRow)~= max (pCol) if max (pRow) >max (pCol) [rowind, colind)= find (min (min (cr)) ==Cost (Rmax, :))5 row] = Rnax(rowind) + % Finding Row index coll = colind; ‘% Preserve Column else (rowind, colind} = find (min (min (Cc) ) ==Cost (:,Cmax)) rowl = rowinds ‘B Precers ROW coll = Cmax(colind) + % Fina Coumn index x11 = min (A(rowl) ,B(col1))+ else [rowindl, colindl]= find (min (min (cr) ) ==Cost (Rmax, :)) 7 owl = Rmax(rowindl); % Finding Row index coll = colindl; ‘% Preserve Column CL = Cost (rowl, coll); % Allocated Cost {rowinda, col ind2] =find (min (nin (cc)) cost (:,Cnax)) row? = rowind2: ‘Preserve ROW col2 = Cmax (colind2); —% Find Cohn Index 2 = Cost:(row2,col2); % Aloeated Cost i i it cece x11 = min(A(rowt) ,B(co11)) {val,ind} = max(c11) + ‘find Ma Acton ii = rowl (ind); identity ROW Position 33 = coll Ging); ident. Postion else x11 = min(A(row2) ,B(co12)) + Ivalyind) = max (11) Find Max Abaton AL = rowa ind); lant OW Peston 35 = col2Cind) tanya Peston end ‘end <= END of IF LOOP yA = min(a(ii),BG3))5 ‘$n the Value "Cal = sort (cost,1)7 Rou = sort (Cost, 2); [pRow = Row(:, 2) -Row(:,1)2 Jpcol = Col (2, :)-Col (1,2) Ai) = AGi)-yla: G3) = BG3)-ylls 8% PRINT THE INITIAL BFS fprintf£('Intial BFS = \n')z IB = array2table (X)+ TotalBFS = length(nonzeros (X))+ if TotalBFS == BFS fprintf('Intial BFS is Not ite \nt ; n~Regenerate \n'); %% Compute the Initial ‘Transportation Cost InitialCost = sum(sum(ICost.*X))7 fprintf('Intial BFS Cost = d\n", Initialcost) 7

You might also like