Hallo an alle :)
Ich habe folgenden Python Code von jemanden aus dem Internet gefunden der die Mitarbeiteranzahl mit der Erlang C formel in Excel berechnet:
#!/usr/bin/python # coding: utf-8 import math def CalcNeededAgents(BaseTimePeriod, MeanServiceTime, MeanRequests, ServiceLevel, MaxWaitTimeClient): WorkVolume = (MeanRequests * MeanServiceTime) / BaseTimePeriod Sum = 0.0 Summand = 1.0 Agents = 0 while True: if Agents > WorkVolume: Tmp = Summand * Agents/(Agents-WorkVolume) Probability = 1-Tmp/(Sum+Tmp)*math.exp(-MaxWaitTimeClient*(Agents-WorkVolume)/MeanServiceTime) if (Probability >= ServiceLevel): break Sum += Summand Agents += 1 Summand *= WorkVolume/Agents return (Agents, Probability) if __name__ == '__main__': Result = CalcNeededAgents(3600, 120, 200, 0.8, 20) print("{} Agenten benötigt; damit erreichtes Service-Level: {}".format(Result[0],Result[1])
Leider weiß ich nicht so wirklich wie ich das in Excel als VBA nutzen kann.
Ich habe mit Chat GBT den Code in folgende VBA umschreiben lassen:
Option Explicit
Public Function CalcNeededAgents(BaseTimePeriod As Double, MeanServiceTime As Double, MeanRequests As Double, ServiceLevel As Double, MaxWaitTimeClient As Double) As Variant
Dim WorkVolume As Double
Dim Sum As Double
Dim Summand As Double
Dim Agents As Double
Dim Probability As Double
Dim Tmp As Double
WorkVolume = (MeanRequests * MeanServiceTime) / BaseTimePeriod
Sum = 0#
Summand = 1#
Agents = 0#
While True
If Agents > WorkVolume Then
Tmp = (Summand * Agents) / (Agents - WorkVolume)
Probability = 1# - Tmp / (Sum + Tmp) * Application.Exp(-MaxWaitTimeClient * (Agents - WorkVolume) / MeanServiceTime)
If Probability >= ServiceLevel Then
Exit While
End If
End If
Sum = Sum + Summand
Agents = Agents + 1
Summand = Summand * WorkVolume / Agents
Wend
CalcNeededAgents = Array(Agents, Probability)
End Function
Public Sub test()
Dim Result As Variant
Result = CalcNeededAgents(3600, 120, 200, 0.8, 20)
Debug.Print Result(0) & " Agenten benötigt, damit erreichtes Service-Level: " & Result(1)
End Sub
Sobald ich den Code anwende, kommt aber der Fehler: Syntaxfehler bei "Exit While"..
Schonmal danke für eure Hilfe! :)
|