1. Tampilan Program
Gambar 1. Tampilan program
Analisis Program
Gambar 2. Analisis program pertama
Rata-rata waktu kedatangan : 1
Rata-rata waktu pelayanan : 0.5
Banyak pelanggan : 300
Rata-rata penundaan antrian : 31.82
Rata-rata banyak antrian : 63.09
Waktu total : 210.61
Gambar 3. Analisis program kedua
Rata-rata waktu kedatangan : 1
Rata-rata waktu pelayanan : 0.75
Banyak pelanggan : 300
Rata-rata penundaan antrian : 14.49
Rata-rata banyak antrian : 21.27
Waktu total : 201.00
Gambar 4. Analisis program ketiga
Rata-rata waktu kedatangan : 1
Rata-rata waktu pelayanan : 0.6
Banyak pelanggan : 500
Rata-rata penundaan antrian : 31.52
Rata-rata banyak antrian : 44.86
Waktu total : 389.90
2. Source Code
Option Explicit
Dim jum_pelanggan_skrg, jum_antrian, jumpelanggan, status, berikut As Integer
Dim waktutunggu, waktu, tot_tunggu, rata_antrian, tL, tiba, pelayanan As Double
Dim Ttiba(1 To 1000) As Double
Dim TN(1 To 2) As Double
Dim R_m As Double
Dim i As Integer
'Validasi angka
Public Sub OnlyNUMERIC(KeyAscii As Integer)
If Not (Chr$(KeyAscii) Like "[0-9,.]" Or _
KeyAscii = 8) Then
Beep
KeyAscii = 0
End If
End Sub
Private Sub cmdabout_Click()
frmabout.Show (1)
End Sub
Private Sub cmdkeluar_Click()
End
End Sub
Private Sub cmproses_Click()
Dim acak As Double
Dim A As Integer
Dim i As Integer
acak = Rnd
A = 1
msproses.Rows = 1
'Jika terjadi error
On Error GoTo salah
'validasi
If (txttiba = "" And txtpelayanan = "" And txtpelanggan = "") Then
MsgBox "Pengisian data tidak lengkap !!", vbInformation, "Informasi"
txttiba.SetFocus
Else
tiba = CDbl(txttiba.Text)
pelayanan = CDbl(txtpelayanan.Text)
jumpelanggan = CDbl(txtpelanggan.Text)
waktu = 0
status = 0
jum_antrian = 0
tL = 0
jum_pelanggan_skrg = 0
tot_tunggu = 0
rata_antrian = 0
TN(1) = waktu + Exp(-tiba * acak)
TN(2) = 1E+30
While jum_pelanggan_skrg < jumpelanggan
berikut = 0
R_m = 1E+29
For i = 1 To 2
If Not (TN(i) >= R_m) Then
R_m = TN(i)
berikut = i
End If
If berikut > 0 Then
waktu = TN(berikut)
Else
MsgBox ("Tidak terjadi even !")
End If
Next
If berikut = 1 Then
TN(1) = waktu + Exp(-tiba * acak)
If status = 1 Then
rata_antrian = rata_antrian + jum_antrian * (waktu - tL)
tL = waktu
jum_antrian = jum_antrian + 1
If jum_antrian <= 1000 Then
Ttiba(jum_antrian) = waktu
Else
MsgBox ("Array Overflow")
End If
Else
waktutunggu = 0
jum_pelanggan_skrg = jum_pelanggan_skrg + 1
status = 1
TN(2) = waktu + Exp(-pelayanan * acak)
End If
Else
If jum_antrian <> 0 Then
rata_antrian = rata_antrian + jum_antrian * (waktu - tL)
tL = waktu
jum_antrian = jum_antrian - 1
waktutunggu = waktu - Ttiba(1)
tot_tunggu = tot_tunggu + waktutunggu
jum_pelanggan_skrg = jum_pelanggan_skrg + 1
TN(2) = waktu + Exp(-pelayanan * acak)
If jum_antrian <> 0 Then
For i = 1 To jum_antrian - 1
Ttiba(i) = Ttiba(i + 1)
Next
End If
Else
status = 0
TN(2) = 1E+30
End If
End If
msproses.Rows = msproses.Rows + 1
msproses.TextMatrix(A, 0) = jum_pelanggan_skrg
msproses.TextMatrix(A, 1) = Format(waktu, "0.00")
A = A + 1
Wend
Dim rata_tunggu, rata_jum_antrian As Double
rata_tunggu = tot_tunggu / jum_pelanggan_skrg
rata_jum_antrian = rata_antrian / waktu
txtratawaktu = Format(rata_tunggu, "0.00")
txtratapelanggan = Format(rata_jum_antrian, "0.00")
txttotal = Format(waktu, "0.00")
End If
Exit Sub
salah:
MsgBox Err.Number & vbNewLine & Err.Description & vbNewLine & Err.Source
End Sub
Private Sub Form_Activate()
With msproses
.Cols = 2
.ColWidth(0) = 1500
.ColWidth(1) = 1800
End With
End Sub
Private Sub Form_Load()
With Me
.Left = (Screen.Width - .Width) / 2
.Top = (Screen.Height - .Height) / 2
End With
With msproses
.Rows = 1
.TextMatrix(0, 0) = "Pelanggan Ke-"
.TextMatrix(0, 1) = "Waktu Pelayanan"
End With
End Sub
Private Sub txtpelanggan_GotFocus()
txtpelanggan = ""
End Sub
Private Sub txtpelanggan_KeyPress(KeyAscii As Integer)
Call OnlyNUMERIC(KeyAscii)
End Sub
Private Sub txtpelayanan_GotFocus()
txtpelayanan = ""
End Sub
Private Sub txtpelayanan_KeyPress(KeyAscii As Integer)
Call OnlyNUMERIC(KeyAscii)
End Sub
Private Sub txttiba_GotFocus()
txttiba = ""
End Sub
Private Sub txttiba_KeyPress(KeyAscii As Integer)
Call OnlyNUMERIC(KeyAscii)
End Sub
Boleh minta source codenta
ReplyDelete