-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathcallcenter.py
More file actions
155 lines (128 loc) · 5.69 KB
/
callcenter.py
File metadata and controls
155 lines (128 loc) · 5.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# DO NOT CHANGE THIS FUNCTION
# Create a basic queue
def create_queue(size: int) -> dict:
"""
Description: Creates and initializes a basic queue with a specified size.
Parameters: size - an integer representing the size of the queue.
Return: A dictionary representing the initialized queue.
"""
return {
'data': [None] * size, # list of elements
'front': -1, # index of the first element in the queue
'rear': -1, # index of the last element in the queue
'n': 0, # number of elements in the queue
'size': size # size of the queue
}
# DO NOT CHANGE THIS FUNCTION
# Create a priority queue
def create_priority_queue(size: int) -> dict:
"""
Description: Creates and initializes a priority queue with a specified size.
Each element in the queue is a tuple consisting of data and priority.
Parameters: size - an integer representing the size of the priority queue.
Return: A dictionary representing the initialized priority queue.
"""
return {
'data': [(None, float('inf'))] * size, # list of elements with default priority set to infinity
'front': -1, # index of the first element in the queue
'rear': -1, # index of the last element in the queue
'n': 0, # number of elements in the queue
'size': size # size of the queue
}
# Check if the queue is full
def is_full(queue: dict) -> bool:
"""
Description: Checks if the given queue is full (reached its maximum capacity).
Parameters: queue - a dictionary representing the queue.
Return: True if the queue is full, False otherwise.
"""
pass
# Check if the queue is empty
def is_empty(queue: dict) -> bool:
"""
Description: Checks if the given queue is empty (contains no elements).
Parameters: queue - a dictionary representing the queue.
Return: True if the queue is empty, False otherwise.
"""
pass
# Add an element to the rear of the queue
def enqueue(queue: dict, item):
"""
Description: Adds an element with the value 'val' to the rear of the queue.
Parameters: queue - a dictionary representing the queue, val - the value to be added to the queue.
"""
pass
# Remove and return the element from the front of the queue
def dequeue(queue: dict) :
"""
Description: Removes and returns the element from the front of the queue.
Parameters: queue - a dictionary representing the queue.
Return: The element from the front of the queue.
"""
pass
# Return the element at the front of the queue without removing it
def peek(queue: dict):
"""
Description: Returns the element at the front of the queue without removing it.
Parameters: queue - a dictionary representing the queue.
Return: The element at the front of the queue.
"""
pass
# Add an element with priority to the priority queue
def enqueue_priority(priority_queue: dict, item, priority: int):
"""
Description: Adds an element with the value 'val' and the specified priority to the priority queue.
Parameters: queue - a dictionary representing the priority queue, val - the value to be added to the queue,
priority - the priority of the element.
"""
pass
# Remove and return the element with the minimum priority from the priority queue
def dequeue_min_priority(priority_queue: dict):
"""
Description: Removes and returns the element with the minimum priority from the priority queue.
Parameters: queue - a dictionary representing the priority queue.
Return: The element with the minimum priority from the priority queue.
"""
pass
# Return the element with the minimum priority from the priority queue without removing it
def peek_min_priority(priority_queue: dict):
"""
Description: Returns the element with the minimum priority from the priority queue without removing it.
Parameters: queue - a dictionary representing the priority queue.
Return: The element with the minimum priority from the priority queue.
"""
pass
def CallSimulator(callQueue, agentQueue) -> dict:
"""
Description: Simulates a call center scenario where calls are processed by agents based on their availability.
Type: Function
Parameters: callQueue - a dictionary representing the call queue,
AgentQueue - a dictionary representing the agent queue.
Return: A queue containing information about each processed call (callerName, call_start, call_end, wait_time).
"""
# Simulation parameters
Simulation = True
currentTime = 0
# Create a queue to store the call log
callLog = create_queue(callQueue['size'])
while Simulation:
# provide your implementation here
# Increment the current time for the next iteration
currentTime += 1
# Returning the queue containing the call log
return callLog
def main(filename) -> list:
"""
Description: Main function to read input data from a file, initialize agent and call queues, simulate call processing using CallSimulator, and return the call log data.
Parameters: filename - the name of the file containing input data.
Return: A list representing the call log data.
"""
# Read input data from the file
# First line contains the list of agents separated by spaces
# Second line contains the number of calls to be processed
# Populate the call queue with call details from the remaining lines contain the call details (start time, caller name, call duration) separated by spaces
# provide your implementation here
# Simulate call processing using CallSimulator
call_log = CallSimulator(call_queue, agentQueue)
# Return the call log data as a list
return call_log['data']