20
>> SOAL TABEL SIMPLEKS << >> Penyelesaian << Dari kasus diatas dapat dibuat suatu program untuk menunjang kemajuan perusahaan. Tujuan memaximalkan Z = 50 x1 + 40 x2 Kendala-kendala: 0,4x1 + 0,5x2 < 326 0,5x1 + 0,3x2 < 354

Tabel Simpleks

Embed Size (px)

Citation preview

Page 1: Tabel Simpleks

>> SOAL TABEL SIMPLEKS <<

>> Penyelesaian <<

Dari kasus diatas dapat dibuat suatu program untuk menunjang kemajuan perusahaan.

Tujuan memaximalkan Z = 50 x1 + 40 x2

Kendala-kendala:

0,4x1 + 0,5x2 < 326

0,5x1 + 0,3x2 < 354

0,05x1 + 0,1 < 62

Bentuk bakunya :

Z = 50x1 + 40x2 + 0.s1 +0.s2 + 0.s3

Page 2: Tabel Simpleks

0,4x1 + 0,4x2 + s1 = 326

0,5x1 + 0,3x2 + s2 = 354

0,05x1 + 0,1 + s3 = 62

Tabel simpleks

VD Z X1 X2 S1 S2 S3 NK

Z 1 -50 -40 0 0 0 0

S1 0 0,4 0,5 1 0 0 326

S2 0 0,5 0,3 0 1 0 354

S3 0 0,05 0,1 0 0 1 62

Kolom kerja adalah nilai negatif terbesar

Baris pivot adalah perbandingan nilai solusi dengan nilai pada kolom kerja

S1 326 : 0,4 = 815

S2 354 : 0,5 = 708

S3 62 : 0,05 = 1240

Rubah semua nilai pada baris Pivot dengan cara membagi nilai lama bari pivot dengan baris pivot (0,5)

Maka tabel simpleks alan berubah

VD Z X1 X2 S1 S2 S3 NK

Z 1 -50 -40 0 0 0 0

S1 0 0,4 0,5 1 0 0 326

CB 0 1 0,6 0 2 0 708

S3 0 0,05 0,1 0 0 1 62

KOLOM KERJA

BARIS PIVOT

BARIS PIVOT

Page 3: Tabel Simpleks

Lakukan interasi pertama

Rubah nilai dengan nilai baru dengan cara:

Nilai baru = nilai lama – (nilai kolom kerja X nilai baru baris pivot)

Tabel simpleks

VD Z CB X2 S1 S2 S3 NK

Z 1 0 -10 0 100 0 35400

S1 0 0,4 0,26 1 -0,8 0 32,8

CB 0 1 0,6 0 2 0 708

S3 0 0 0,07 0 -0,1 1 26,6

Karena masih terdapat nilai negatif pada baris CB dan PR, lakukan interasi kedua

Lakukan hal yang sama, yaitu tentukan dulu kolom kerja sampai menghitung nilai baru.

Tabel simpleks

VD Z CB PR S1 S2 S3 NK

Z 1 0 0 38,46 69,23 0 37046,15

PR 0 0 1 3,84 -3,07 0 164,61

CB 0 1 0 -2,30 3,84 0 609,23

S3 0 0 0 -0,26 0,11 1 15,07

Pada tabel diatas sudah tidak terdapat nilai negatif pada baris CB dan PR, maka didapatkan nilai :

max CB = 609,23

max PR = 164,61

Page 4: Tabel Simpleks

__LANGKAH-LANGKAH MEMBUAT PROGRAM__ __TABEL SIMPLEKS__

1. Kita buat dahulu tabelnya, seperti berikut:2. Kita buat dalam 2 form

Form1

Koding Proses

Private Sub cmdproses_Click()

Form2.X1Z.Text = Form1.NCB.Text * -1

Form2.X2Z.Text = Form1.NPR.Text * -1

Form2.CBS1.Text = Form1.CB1.Text

Form2.PRS1.Text = Form1.PR1.Text

Form2.CBS2.Text = Form1.CB2.Text

Form2.PRS2.Text = Form1.PR2.Text

Untuk Menampilkan form2 dari Form1

Page 5: Tabel Simpleks

Form2.CBS3.Text = Form1.CB3.Text

Form2.PRS3.Text = Form1.PR3.Text

Form2.HNK1.Text = Form1.NK1.Text

Form2.HNK2.Text = Form1.NK2.Text

Form2.HNK3.Text = Form1.NK3.Text

Form2.Show

End Sub

Koding UlangPrivate Sub cmdulang_Click()

NCB.Text = ""

NPR.Text = ""

CB1.Text = ""

PR1.Text = ""

CB2.Text = ""

PR2.Text = ""

CB3.Text = ""

PR3.Text = ""

NK1.Text = ""

NK2.Text = ""

NK3.Text = ""

End Sub

Koding KeluarPrivate Sub cmdkeluar_Click()

End

End Sub

Form2

Page 6: Tabel Simpleks

Koding ProsesPrivate Sub cmdproses_Click()

ZZ.Text = 1

S1Z.Text = 0

S2Z.Text = 0

S3Z.Text = 0

NKZ.Text = 0

S1CB.Text = 1

S2PR.Text = 1

S3INS.Text = 1

ZS1.Text = 0

S2CB.Text = 0

S3CB.Text = 0

Page 7: Tabel Simpleks

ZS2.Text = 0

S1PR.Text = 0

S3PR.Text = 0

ZS3.Text = 0

S1INS.Text = 0

S2INS.Text = 0

gembul:

For i = 1 To 2

If X1Z.Text < X2Z.Text Then

VKK.Text = "KOLOM PORTABLE"

End If

If X2Z.Text < X1Z.Text Then

VKK.Text = "KOLOM CB"

Else

If X1Z.Text = X2Z.Text Then

VKK.Text = "KOLOM CB"

End If

End If

Next i

Dim S1 As Integer

Dim S2 As Integer

Dim S3 As Integer

If VKK.Text = "KOLOM CB" Then

S1 = Val(HNK1.Text / CBS1.Text)

S2 = Val(HNK2.Text / CBS2.Text)

S3 = Val(HNK3.Text / CBS3.Text)

Page 8: Tabel Simpleks

If S1 < S2 Then

VPB = "S1"

Else

If S2 < S3 Then

VPB = "S2"

Else

VPB = "S3"

End If

End If

End If

If VKK.Text = "KOLOM PORTABLE" Then

S1 = Val(HNK1.Text / PRS1.Text)

S2 = Val(HNK2.Text / PRS2.Text)

S3 = Val(HNK3.Text / PRS3.Text)

If S1 < S2 Then

VPB = "S1"

Else

If S2 < S3 Then

VPB = "S2"

Else

VPB = "S3"

End If

End If

End If

Page 9: Tabel Simpleks

If VKK.Text = "KOLOM CB" Then

If VPB = "S1" Then

PRS1.Text = Val(PRS1.Text / CBS1.Text)

HNK1.Text = Val(HNK1.Text / CBS1.Text)

S1CB.Text = Val(S1CB.Text / CBS1.Text)

CBS1.Text = Val(CBS1.Text / CBS1.Text)

LabelS1.Caption = "CB"

End If

End If

If VKK.Text = "KOLOM CB" Then

If VPB = "S2" Then

S2PR.Text = Val(S2PR.Text / CBS2.Text)

PRS2.Text = Val(PRS2.Text / CBS2.Text)

HNK2.Text = Val(HNK2.Text / CBS2.Text)

CBS2.Text = Val(CBS2.Text / CBS2.Text)

LabelS2.Caption = "CB"

End If

End If

If VKK.Text = "KOLOM CB" Then

If VPB = "S3" Then

PRS3.Text = Val(PRS3.Text / CBS3.Text)

Page 10: Tabel Simpleks

S3INS.Text = Val(S3INS.Text / CBS3.Text)

HNK3.Text = Val(HNK3.Text / CBS3.Text)

CBS3.Text = Val(CBS3.Text / CBS3.Text)

LabelS3.Caption = "CB"

End If

End If

If VKK.Text = "KOLOM PORTABLE" Then

If VPB = "S1" Then

CBS1.Text = CBS1.Text / (PRS1.Text)

HNK1.Text = Val(HNK1.Text / PRS1.Text)

S1CB.Text = Val(S1CB.Text / PRS1.Text)

PRS1.Text = Val(PRS1.Text / PRS1.Text)

LabelS1.Caption = "PR"

End If

End If

If VKK.Text = "KOLOM PORTABLE" Then

If VPB = "S2" Then

S2PR.Text = Val(S2PR.Text / PRS2.Text)

HNK2.Text = Val(HNK2.Text / PRS2.Text)

CBS2.Text = Val(CBS2.Text / PRS2.Text)

PRS2.Text = Val(PRS2.Text / PRS2.Text)

LabelS2.Caption = "PR"

Page 11: Tabel Simpleks

ElseIf VKK.Text = "KOLOM PORTABLE" Then

If VPB = "S3" Then

S3INS.Text = Val(S3INS.Text / PRS3.Text)

HNK3.Text = Val(HNK3.Text / PRS3.Text)

CBS3.Text = Val(CBS3.Text / PRS3.Text)

PRS3.Text = Val(PRS3.Text / PRS3.Text)

LabelS3.Caption = "PR"

End If

End If

End If

If VKK.Text = "KOLOM CB" Then

If VPB.Text = "S1" Then

ZZ.Text = Val(ZZ.Text) - Val(X1Z.Text * ZS1.Text)

X2Z.Text = Val(X2Z.Text) - Val(X1Z.Text * PRS1.Text)

S1Z.Text = Val(S1Z.Text) - Val(X1Z.Text * S1CB.Text)

S2Z.Text = Val(S2Z.Text) - Val(X1Z.Text * S2CB.Text)

S3Z.Text = Val(S3Z.Text) - Val(X1Z.Text * S3CB.Text)

NKZ.Text = Val(NKZ.Text) - Val(X1Z.Text * HNK1.Text)

X1Z.Text = Val(X1Z.Text) - Val(X1Z.Text * CBS1.Text)

ZS2.Text = ZS2.Text - Val(CBS2.Text * ZS1.Text)

PRS2.Text = Val(PRS2.Text) - Val(CBS2.Text * PRS1.Text)

Page 12: Tabel Simpleks

S1PR.Text = Val(S1PR.Text) - Val(CBS2.Text * S1CB.Text)

S2PR.Text = Val(S2PR.Text) - Val(CBS2.Text * S2CB.Text)

S3PR.Text = Val(S3PR.Text) - Val(CBS2.Text * S3CB.Text)

HNK2.Text = Val(HNK2.Text) - Val(CBS2.Text * HNK1.Text)

CBS2.Text = Val(CBS2.Text) - Val(CBS2.Text * CBS1.Text)

ZS3.Text = ZS3.Text - Val(CBS3.Text * ZS1.Text)

PRS3.Text = Val(PRS3.Text) - Val(CBS3.Text * PRS1.Text)

S1INS.Text = Val(S1INS.Text) - Val(CBS3.Text * S1CB.Text)

S2INS.Text = Val(S2INS.Text) - Val(CBS3.Text * S2CB.Text)

S3INS.Text = Val(S3INS.Text) - Val(CBS3.Text * S3CB.Text)

HNK3.Text = Val(HNK3.Text) - Val(CBS3.Text * HNK1.Text)

CBS3.Text = Val(CBS3.Text) - Val(CBS3.Text * CBS1.Text)

Else

If VPB.Text = "S2" Then

ZZ.Text = Val(ZZ.Text) - Val(X1Z.Text * ZS2.Text)

X2Z.Text = Val(X2Z.Text) - Val(X1Z.Text * PRS2.Text)

S1Z.Text = Val(S1Z.Text) - Val(X1Z.Text * S1PR.Text)

S2Z.Text = Val(S2Z.Text) - Val(X1Z.Text * S2PR.Text)

S3Z.Text = Val(S3Z.Text) - Val(X1Z.Text * S3PR.Text)

NKZ.Text = Val(NKZ.Text) - Val(X1Z.Text * HNK2.Text)

X1Z.Text = Val(X1Z.Text) - Val(X1Z.Text * CBS2.Text)

ZS1.Text = Val(ZS1.Text) - Val(CBS1.Text * ZS2.Text)

PRS1.Text = Val(PRS1.Text) - Val(CBS1.Text * PRS2.Text)

S1CB.Text = Val(S1CB.Text) - Val(CBS1.Text * S1PR.Text)

S2CB.Text = Val(S2CB.Text) - Val(CBS1.Text * S2PR.Text)

Page 13: Tabel Simpleks

S3CB.Text = Val(S3CB.Text) - Val(CBS1.Text * S3PR.Text)

HNK1.Text = Val(HNK1.Text) - Val(CBS1.Text * HNK2.Text)

CBS1.Text = Val(CBS1.Text) - Val(CBS1.Text * CBS2.Text)

ZS3.Text = Val(ZS3.Text) - Val(CBS3.Text * ZS2.Text)

PRS3.Text = Val(PRS3.Text) - Val(CBS3.Text * PRS2.Text)

S1INS.Text = Val(S1INS.Text) - Val(CBS3.Text * S1PR.Text)

S2INS.Text = Val(S2INS.Text) - Val(CBS3.Text * S2PR.Text)

S3INS.Text = Val(S3INS.Text) - Val(CBS3.Text * S3PR.Text)

HNK3.Text = Val(HNK3.Text) - Val(CBS3.Text * HNK2.Text)

CBS3.Text = Val(CBS3.Text) - Val(CBS3.Text * CBS2.Text)

Else

If VPB = "S3" Then

ZZ.Text = Val(ZZ.Text) - Val(X1Z.Text * ZS2.Text)

X2Z.Text = Val(X2Z.Text) - Val(X1Z.Text * PRS3.Text)

S1Z.Text = Val(S1Z.Text) - Val(X1Z.Text * S1INS.Text)

S2Z.Text = Val(S2Z.Text) - Val(X1Z.Text * S2INS.Text)

S3Z.Text = Val(S3Z.Text) - Val(X1Z.Text * S3INS.Text)

NKZ.Text = Val(NKZ.Text) - Val(X1Z.Text * HNK3.Text)

X1Z.Text = Val(X1Z.Text) - Val(X1Z.Text * CBS3.Text)

ZS1.Text = Val(ZS1.Text) - Val(CBS1.Text * ZS3.Text)

PRS1.Text = Val(PRS1.Text) - Val(CBS1.Text * PRS3.Text)

S1CB.Text = Val(S1CB.Text) - Val(CBS1.Text * S1INS.Text)

S2CB.Text = Val(S2CB.Text) - Val(CBS1.Text * S2INS.Text)

S3CB.Text = Val(S3CB.Text) - Val(CBS1.Text * S3INS.Text)

Page 14: Tabel Simpleks

HNK1.Text = Val(HNK1.Text) - Val(CBS1.Text * HNK3.Text)

CBS1.Text = Val(CBS1.Text) - Val(CBS1.Text * CBS3.Text)

ZS2.Text = Val(ZS2.Text) - Val(CBS2.Text * ZS3.Text)

PRS2.Text = Val(PRS2.Text) - Val(CBS2.Text * PRS3.Text)

S1PR.Text = Val(S1PR.Text) - Val(CBS2.Text * S1INS.Text)

S2PR.Text = Val(S2PR.Text) - Val(CBS2.Text * S2INS.Text)

S3PR.Text = Val(S3PR.Text) - Val(CBS2.Text * S3INS.Text)

HNK2.Text = Val(HNK2.Text) - Val(CBS2.Text * HNK3.Text)

CBS2.Text = Val(CBS2.Text) - Val(CBS2.Text * CBS3.Text)

End If

End If

End If

End If

If VKK.Text = "KOLOM PORTABLE" Then

If VPB.Text = "S1" Then

ZZ.Text = Val(ZZ.Text) - Val(X2Z.Text * ZS1.Text)

S1Z.Text = Val(S1Z.Text) - Val(X2Z.Text * S1CB.Text)

S2Z.Text = Val(S2Z.Text) - Val(X2Z.Text * S2CB.Text)

S3Z.Text = Val(S3Z.Text) - Val(X2Z.Text * S3CB.Text)

NKZ.Text = Val(NKZ.Text) - Val(X2Z.Text * HNK1.Text)

X1Z.Text = Val(X1Z.Text) - Val(X2Z.Text * CBS1.Text)

X2Z.Text = Val(X2Z.Text) - Val(X2Z.Text * PRS1.Text)

ZS2.Text = Val(ZS2.Text) - Val(PRS2.Text * ZS1.Text)

S1PR.Text = Val(S1PR.Text) - Val(PRS2.Text * S1CB.Text)

S2PR.Text = Val(S2PR.Text) - Val(PRS2.Text * S2CB.Text)

Page 15: Tabel Simpleks

S3PR.Text = Val(S3PR.Text) - Val(PRS2.Text * S3CB.Text)

HNK2.Text = Val(HNK2.Text) - Val(PRS2.Text * HNK1.Text)

CBS2.Text = Val(CBS2.Text) - Val(PRS2.Text * CBS1.Text)

PRS2.Text = Val(PRS2.Text) - Val(PRS2.Text * PRS1.Text)

ZS3.Text = Val(ZS3.Text) - Val(PRS3.Text * ZS1.Text)

CBS3.Text = Val(CBS3.Text) - Val(PRS3.Text * CBS1.Text)

S1INS.Text = Val(S1INS.Text) - Val(PRS3.Text * S1CB.Text)

S2INS.Text = Val(S2INS.Text) - Val(PRS3.Text * S2CB.Text)

S3INS.Text = Val(S3INS.Text) - Val(PRS3.Text * S3CB.Text)

HNK3.Text = Val(HNK3.Text) - Val(PRS3.Text * HNK1.Text)

PRS3.Text = Val(PRS3.Text) - Val(PRS3.Text * PRS1.Text)

Else

If VPB = "S2" Then

ZZ.Text = Val(ZZ.Text) - Val(X2Z.Text * ZS2.Text)

S1Z.Text = Val(S1Z.Text) - Val(X2Z.Text * S1PR.Text)

S2Z.Text = Val(S2Z.Text) - Val(X2Z.Text * S2PR.Text)

S3Z.Text = Val(S3Z.Text) - Val(X2Z.Text * S3PR.Text)

NKZ.Text = Val(NKZ.Text) - Val(X2Z.Text * HNK2.Text)

X1Z.Text = Val(X1Z.Text) - Val(X2Z.Text * CBS2.Text)

X2Z.Text = Val(X2Z.Text) - Val(X2Z.Text * PRS2.Text)

ZS1.Text = Val(ZS1.Text) - Val(PRS1.Text * ZS2.Text)

CBS1.Text = Val(CBS1.Text) - Val(PRS1.Text * CBS2.Text)

S1CB.Text = Val(S1CB.Text) - Val(PRS1.Text * S1PR.Text)

S2CB.Text = Val(S2CB.Text) - Val(PRS1.Text * S2PR.Text)

Page 16: Tabel Simpleks

S3CB.Text = Val(S3CB.Text) - Val(PRS1.Text * S3PR.Text)

HNK1.Text = Val(HNK1.Text) - Val(PRS1.Text * HNK2.Text)

PRS1.Text = Val(PRS1.Text) - Val(PRS1.Text * PRS2.Text)

ZS3.Text = Val(ZS3.Text) - Val(PRS3.Text * ZS2.Text)

CBS3.Text = Val(CBS3.Text) - Val(PRS3.Text * CBS2.Text)

S1INS.Text = Val(S1INS.Text) - Val(PRS3.Text * S1PR.Text)

S2INS.Text = Val(S2INS.Text) - Val(PRS3.Text * S2PR.Text)

S3INS.Text = Val(S3INS.Text) - Val(PRS3.Text * S3PR.Text)

HNK3.Text = Val(HNK3.Text) - Val(PRS3.Text * HNK2.Text)

PRS3.Text = Val(PRS3.Text) - Val(PRS3.Text * PRS2.Text)

Else

If VPB.Text = "S3" Then

ZZ.Text = Val(ZZ.Text) - Val(X2Z.Text * ZS2.Text)

X1Z.Text = Val(X1Z.Text) - Val(X2Z.Text * CBS3.Text)

S1Z.Text = Val(S1Z.Text) - Val(X2Z.Text * S1INS.Text)

S2Z.Text = Val(S2Z.Text) - Val(X2Z.Text * S2INS.Text)

S3Z.Text = Val(S3Z.Text) - Val(X2Z.Text * S3INS.Text)

NKZ.Text = Val(NKZ.Text) - Val(X2Z.Text * HNK3.Text)

X2Z.Text = Val(X2Z.Text) - Val(X2Z.Text * PRS3.Text)

ZS1.Text = Val(ZS1.Text) - Val(PRS1.Text * ZS3.Text)

CBS1.Text = Val(CBS1.Text) - Val(PRS1.Text * CBS3.Text)

S1CB.Text = Val(S1CB.Text) - Val(PRS1.Text * S1INS.Text)

S2CB.Text = Val(S2CB.Text) - Val(PRS1.Text * S2INS.Text)

S3CB.Text = Val(S3CB.Text) - Val(PRS1.Text * S3INS.Text)

Page 17: Tabel Simpleks

HNK1.Text = Val(HNK1.Text) - Val(PRS1.Text * HNK3.Text)

PRS1.Text = Val(PRS1.Text) - Val(PRS1.Text * PRS3.Text)

ZS2.Text = Val(ZS2.Text) - Val(CBS2.Text * ZS3.Text)

CBS2.Text = Val(CBS2.Text) - Val(PRS2.Text * CBS3.Text)

S1PR.Text = Val(S1PR.Text) - Val(PRS2.Text * S1INS.Text)

S2PR.Text = Val(S2PR.Text) - Val(PRS2.Text * S2INS.Text)

S3PR.Text = Val(S3PR.Text) - Val(PRS2.Text * S3INS.Text)

HNK2.Text = Val(HNK2.Text) - Val(PRS2.Text * HNK3.Text)

PRS2.Text = Val(PRS2.Text) - Val(PRS2.Text * PRS3.Text)

End If

End If

End If

End If

If X1Z.Text < 0 Then

GoTo gembul:

End If

End Sub

Koding KeluarPrivate Sub cmdkeluar_Click()

End

End Sub