Wednesday, October 17, 2007

Function Microsoft Excel For Erlang Calculator

Melanjutkan scripting Function di Microsoft Excel. Ini adalah function untuk Erlang Calculator yang bisa mengkonversi Trunk Device menjadi Erlang dan sebaliknya.

Function ERL2CH(Traffic, GOS)
TCH = -1000
GOS = GOS / 100

If GOS <= 0 Then
TCH = -1
ElseIf GOS > 1 Then
TCH = -10
ElseIf Traffic < 0 Then
TCH = -100
ElseIf Traffic = 0 Then
TCH = 0
ElseIf GOS = 1 Then
TCH = 0
Else
TCH = Int(Traffic * (1 - GOS))
b = 1
For i = 1 To TCH
b = b / (b + (i / Traffic))
Next
While (b - GOS) > 0
b = b / (b + (i / Traffic))
i = i + 1
Wend
TCH = i - 1
End If
ERL2CH = TCH

End Function

Function CH2ERL(Channel, GOS)
GOS = GOS / 100
Carried = -1000
offered = -1000

If GOS <= 0 Then
Carried = -1
offered = -1000
ElseIf GOS >= 1 Then
Carried = -10
offered = -10
ElseIf Channel <= 0 Then
Carried = -100
offered = -100
Else
offered = Channel / (1 - GOS)
b = 1
y = 0
While y = 0
b = 1
For i = 1 To Channel
b = b / (b + (i / offered))
Next
If ((Abs(b / (GOS - 1))) < 0.000001) Or ((Abs(b - GOS)) < 0.000001) Then
y = 1
End If
offered = offered * (Channel - offered * (1 - b)) / (Channel - offered * (1 - b) + 1 - GOS / b)
Wend
End If

CH2ERL = Round(offered, 2)

End Function

1 comment:

| A | d | i | N | k | said...

Hehehe... Erlang Calculator ini pernah jadi tugas di kampus :)