This repository has been archived on 2021-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
NC/mp6/Project_6_Maggioni_Claudio/printSol.m

18 lines
No EOL
484 B
Matlab

function [x_B,index_B] = printSol (z,x_B,index_B,m,n)
% this function prints the solution while distinguishing between original variables and slack variables
[sorted, index] = sort(index_B);
x_B = x_B(index);
index_B = sorted;
fprintf('Variables and optimal solution:\n\n');
for i = 1:m
if(index_B(i)<n+1)
fprintf('x%d = %f\n', sorted(i), x_B(i));
else
fprintf('s%d = %f\n', sorted(i)-n, x_B(i));
end
end
fprintf('\nOptimal value of z = %d\n\n', z);
end