Question
This the python code produced in regards with the question: { import random # Interarrival distribution of calls interarrival_distribution = { 1: 0.1, 2: 0.5,
This the python code produced in regards with the question:
{
import random
# Interarrival distribution of calls
interarrival_distribution = {
1: 0.1,
2: 0.5,
3: 0.3,
4: 0.1
}
cumulative_interarrival_distribution = {
1: 0.1,
2: 0.6,
3: 0.9,
4: 1
}
# Service time distribution of Ahmed
ahmed_service_distribution = {
2: 0.4,
3: 0.3,
4: 0.2,
5: 0.1
}
cumulative_ahmed_service_distribution = {
2: 0.4,
3: 0.7,
4: 0.9,
5: 1
}
# Service time distribution of Zain
zain_service_distribution = {
3: 0.2,
4: 0.4,
5: 0.2,
6: 0.2
}
cumulative_zain_service_distribution = {
3: 0.2,
4: 0.6,
5: 0.8,
6: 1
}
# Rule A:
# If both are idle, a call is assigned to Zain.
# If Ahmed is busy, a call is assigned to Ahmed.
# If both are busy, a call waits in the queue.
# Rule B:
# If both are idle, a call is assigned to Ahmed.
# If Ahmed is busy, a call is assigned to Zain.
# If both are busy, a call waits in the queue.
# Rule C:
# If both are idle, a call is assigned randomly to Ahmed or Zain.
# If Ahmed is busy, a call is assigned to Zain.
# If Zain is busy, a call is assigned to Ahmed.
# If both are busy, a call waits in the queue.
# Call center simulation
num_calls = 1000
ahmed_busy = False
zain_busy = False
call_queue = []
ahmed_service_time = 0
zain_service_time = 0
total_call_wait_time = 0
total_service_time = 0
total_interarrival_time = 0
rule = 'A'
for i in range(num_calls):
# Generate interarrival time
rand = random.random()
for time, prob in cumulative_interarrival_distribution.items():
if rand
interarrival_time = time
break
total_interarrival_time += interarrival_time
if rule == 'A':
if not ahmed_busy and not zain_busy:
zain_busy = True
rand = random.random()
for time, prob in cumulative_zain_service_distribution.items():
if rand
zain_service_time = time
break
elif ahmed_busy and not zain_busy:
zain_busy = True
rand = random.random()
for time, prob in cumulative_zain_service_distribution.items():
if rand
zain_service_time = time
break
elif zain_busy and not ahmed_busy:
ahmed_busy = True
rand = random.random()
for time, prob in cumulative_ahmed_service_distribution.items():
if rand
ahmed_service_time = time
break
else:
call_queue.append(interarrival_time)
elif rule == 'B':
if not ahmed_busy and not zain_busy:
ahmed_busy = True
rand = random.random()
for time, prob in cumulative_ahmed_service_distribution.items():
if rand
ahmed_service_time = time
break
elif ahmed_busy and not zain_busy:
zain_busy = True
rand = random.random()
for time, prob in cumulative_zain_service_distribution.items():
if rand
zain_service_time = time
break
elif zain_busy and not ahmed_busy:
ahmed_busy = True
rand = random.random()
for time, prob in cumulative_ahmed_service_distribution.items():
if rand
ahmed_service_time = time
break
else:
call_queue.append(interarrival_time)
elif rule == 'C':
if not ahmed_busy and not zain_busy:
rand = random.random()
if rand
ahmed_busy = True
rand = random.random()
for time, prob in cumulative_ahmed_service_distribution.items():
if rand
ahmed_service_time = time
break
else:
zain_busy = True
rand = random.random()
for time, prob in cumulative_zain_service_distribution.items():
if rand
zain_service_time = time
break
elif ahmed_busy and not zain_busy:
zain_busy = True
rand = random.random()
for time, prob in cumulative_zain_service_distribution.items():
if rand
zain_service_time = time
break
elif zain_busy and not ahmed_busy:
ahmed_busy = True
rand = random.random()
for time, prob in cumulative_ahmed_service_distribution.items():
if rand
ahmed_service_time = time
break
else:
call_queue.append(interarrival_time)
# Decrement service times
if ahmed_busy:
ahmed_service_time -= 1
if ahmed_service_time == 0:
ahmed_busy = False
if len(call_queue) > 0:
call = call_queue.pop(0)
total_call_wait_time += call
rand = random.random()
for time, prob in cumulative_ahmed_service_distribution.items():
if rand
ahmed_service_time = time
break
ahmed_busy = True
if zain_busy:
zain_service_time -= 1
if zain_service_time == 0:
zain_busy = False
if len(call_queue) > 0:
call = call_queue.pop(0)
total_call_wait_time += call
rand = random.random()
for time, prob in cumulative_zain_service_distribution.items():
if rand
zain_service_time = time
break
zain_busy = True
total_service_time += ahmed_service_time + zain_service_time
# Calculate average service time and average call wait time
average_service_time = total_service_time / num_calls
average_interarrival_time = total_interarrival_time / num_calls
average_call_wait_time = total_call_wait_time / num_calls
print("Average service time:", average_service_time)
print("Average interarrival time:", average_interarrival_time)
print("Average call wait time:", average_call_wait_time)
}
So The Question I need the asnwer for is
The next question needs me to change this code which runs the simulation a 1000 times to Run the simulation for 400 time for 100 calls and draw a histogram for call average caller delay (for the three rules).
Assume a call center where two staff members, named Zain and Ahmed, take care of customers to qive service. And we have the following possible roles: Rule A: - If both are idle, a call is assigned to Zain. - If Ahmed is busy, a call is assigned to Ahmed. - If both are busy, a call waits in the queue. Rule B: - If both are idle, a call is assigned to Ahmed. - If Ahmed is busy, a call is assigned to Zain. - If both are busy, a call waits in the queue. Rule C: - If both are idle, a call is assigned randomly to Ahmed or Zain. - If Ahmed is busy, a call is assiqned to Zain. - If Zain is busy, a call is assigned to Ahmed. - If both are busy, a call waits in the queue. Interarrival distribution of calls for technical support Servire time dictrihution of hmpd Service time distribution of ZainStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started