AS PPE code Flashcards

1
Q

What is the purpose of the ResetDataStructures function?

A

To initialize and reset the simulation data structures, including the stats, tills, and buyer queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does the ChangeSettings function modify the simulation settings?

A

It sets the simulation time and the number of tills. It also allows the user to adjust these settings within specified limits by input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the ReadInSimulationData function do?

A

It reads simulation data from a file (“SimulationData.txt”), where each line specifies the arrival time and the number of items for a buyer, storing the information into a 2D list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe the role of the BuyerJoinsQ function in the simulation.

A

It adds a buyer to the queue with their ID and the number of items they have, and updates the queue length accordingly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does the FindFreeTill function determine if a till is available?

A

It checks each till to see if it’s idle (i.e., not serving any buyer). If a free till is found, it returns its number; otherwise, it returns -1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of the ServeBuyer function?

A

It processes the first buyer in the queue, serving them and removing them from the queue, and returns details about that buyer (ID, waiting time, and number of items).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the UpdateStats function track?

A

It tracks statistics related to the buyers’ waiting times, such as total waiting time, maximum waiting time, and the number of buyers who didn’t have to wait.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain the function of CalculateServingTime.

A

It calculates the time required to serve a buyer based on the number of items they have, and updates the corresponding till’s serving time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does the IncrementTimeWaiting function impact the buyer queue?

A

It increments the waiting time of every buyer in the queue by one time unit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the role of the UpdateTills function?

A

It updates the state of each till by incrementing the idle time if the till is not in use or the busy time if it is serving a buyer. It also decreases the serving time for tills that are actively serving a buyer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the OutputTillAndQueueStates function display?

A

It prints the current states of the tills (idle, busy, serving times) and the buyer queue (buyer IDs, waiting times, and items in the basket).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Describe the operation of the Serving function.

A

It finds the first available till, serves the next buyer in the queue, updates the stats, calculates the serving time, and manages the queue and till states. It continues until all buyers are served.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does the TillsBusy function determine if any tills are busy?

A

It checks if any tills are currently serving a buyer (i.e., their serving time is greater than 0). If at least one till is busy, it returns True; otherwise, it returns False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the output of the OutputStats function?

A

It prints the simulation statistics, including the maximum queue length, the maximum waiting time, the number of buyers, the average waiting time, and the average queue length.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What happens in the QueueSimulator function?

A

It runs the entire simulation, initializing data structures, handling buyer arrivals, processing the queue, updating stats, and printing outputs until all buyers are served and tills are free.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the purpose of the OutputHeading function?

A

It prints the column headings for the simulation output, including details like time, buyer ID, till states, queue states, and buyer statistics.

17
Q

In the Serving function, when does the simulation stop processing buyers?

A

It stops processing buyers when all buyers have been served, and no more buyers are in the queue or when all tills are busy serving.

18
Q

How does the simulation handle extra time after all the buyers are processed?

A

The simulation enters a loop where it continues to process buyers in the queue until they are all served, even if this extends beyond the initial simulation time.

19
Q

What happens if there are no free tills available when a buyer arrives?

A

If there are no free tills, the buyer joins the queue and waits until a till becomes available.

20
Q

What is the effect of the SimulationTime variable in the simulation?

A

It defines the maximum number of time units the simulation runs, during which buyers arrive and are processed. The simulation continues to process until all buyers are served or until the simulation time ends.