Anda di halaman 1dari 5

TUGAS INPUT OUTPUT

KELOMPOK 3 KELAS SUMBER DAYA INDUSTRI

Disusun Oleh:

Ennol Endrianto - 1706082103

Hilmy F. Jabbar - 1706989746

Iwan Setiaji - 1706989784

Saiful Anham - 1706990110

PROGRAM PASCASARJANA DEPARTEMEN TEKNIK INDUSTRI

FAKULTAS TEKNIK

UNIVERSITAS INDONESIA

2018
TUGAS 7 : INPUT OUTPUT
Soal:

Industri pemerintah
Jual kepada total
1 2 3 investasi pemerintah expor
1 320 150 210 20 30 70 800
Beli dari 2 80 60 140 10 - 10 300
3 160 210 280 15 20 15 700
Σ buruh dll 400 240 280 60 980

 Tabel diatas disusun menjadi tabel koefisien per unit produk, sebagai berikut:

Jual kepada 1 2 3 I G X Total


1 0.4 0.5 0.3 20 30 70 800
Beli dari 2 0.1 0.2 0.2 10 - 10 300
3 0.2 0.7 0.4 15 20 15 700
Σ buruh dll 0.5 0.8 0.4 60 0 0 980

 Tabel diatas diterjemahkan menjadi matriks B = matriks identitas - matriks A

1 0 0 0.4 0.5 0.3 0.6 -0.5 -0.3


0 1 0 - 0.1 0.2 0.2 = -0.1 0.8 -0.2
0 0 1 0.2 0.7 0.4 -0.2 -0.7 0.6

 Matriks B diterjemahkan menjadi persamaan linear dengan memenuhi 3 persyaratan yaitu:


o (I-A)X ≥ D
o Al X ≤ L
o X≥0

Maka persamaan yang harus diselesaikan adalah sebagai berikut:

0.6X1 – 0.5X2 – 0.3X3 ≥ 105

-0.1X1 + 0.8X2 – 0.2X3 ≥ 40

-0.2X1 – 0.7X2 + 0.6X3 ≥ 75

0.5X1 + 0.8X2 + 0.4X3 ≥ 1300

 Persamaan diatas kemudian diselesaikan menggunakan program MATLAB dengan rincian sebagai
berikut:
 Program untuk Input Output
% Gauss-Seidel Method in MATLAB

function x = gauss_seidel(A , B)
disp ('Enter the system of linear equations in the form of AX=B')

%Inputting mstrix A

A = input ( 'Enter matrix A : \n')


% check if the entered matrix is a square matrix

[na, ma] = size (A);


if na ~= ma
disp('ERROR: Matrix A must be a square matrix')
return
end

%Inputting matrix B

B = input ( 'Enter matrix B : ')


% check if B is a column matrix

[nb, mb] = size (B);


if nb ~= na || mb~=1
disp('ERROR: Matrix B must be a column matrix')
return
end

% Separation of matrix A into lower triangular and upper triangular


% matrices

% A = D + L + U

D = diag(diag(A));
L = tril(A)- D;
U = triu(A)- D;

% check for convergence condition for Gauss-Seidel method

e= max (eig(-inv(D+L)*(U)));
if abs(e) >=1
disp ('Since the modulus of the largest Eigen value of iterative matrix
is not less than 1')
disp ('this process is not convergen.')
return
end

% initial guess for X..?


% deault guess is [1 1 .... 1]

r = input ('Any initial guess for X? (y/n): ','s');


switch r
case 'y'
% asking for initial guess
X0 = input('Enter initial guess for X :\n')
% check for initial guess
[nx, mx] = size(X0);
if nx ~= na || mx ~= 1
disp('ERROR: Check input')
return
end
otherwise
X0 = ones(na,1);
end

% allowable error in final answer

t = input ( 'Enter the error allowable in final answer: ')


tol = t*ones(na,1);
k= 1;

X( : , 1 ) = X0;
err= 1000000000*rand(na,1);% initial error assumption for looping
while sum(abs(err) >= tol) ~= zeros(na,1)
X ( : ,k+ 1 ) = -inv(D+L)*(U)*X( : ,k) + inv(D+L)*B;% Gauss-Seidel
formula
err = X( :,k+1) - X( :, k);% finding error
k = k + 1;

end

fprintf ('The final answer obtained after %g iterations is \n', k)


X( : ,k)
 Hasil Input Ouput
Enter the system of linear equations in the form of AX=B
Enter matrix A : [0.6 -0.5 -0.3; -0.1 0.8 -0.2; -0.2 -0.7 0.6]

A=
0.6 -0.5 -0.3
-0.1 0.8 -0.2
-0.2 -0.7 0.6

Enter matrix B : [105; 40; 75]

B=
105
40
75

Any initial guess for X? (y/n): 1


Enter the error allowable in final answer: 0.01

t = 0.01

 Didapati hasil X1, X2, dan X3 setelah 42 iterasi dimana nilai:


X1 = 1,316.70126351987
X2 = 204.048702758478
X3 = 608.215263510847