nus-cs2030 / 2021-s2

2 stars 2 forks source link

Fail Test Case: 5_4 #409

Open TMTM98 opened 3 years ago

TMTM98 commented 3 years ago

Summary

Put a summary of the question

For some reason, the program could not allow Customer 254 to wait despite it being able to wait since the wait queue reduction happened at line 866 and since 868 takes place quite a while after 866, Customer 254 should have been able to wait.

Description

Describe the problem and code snippets if necessary

Can anyone provide any insight or the input for Case 5_4 so I can debug?

Screenshots (if any):

Insert Images here if necessary

image

garionKang62 commented 3 years ago

Hello, potentially this might be triggering some edge case for the "able to wait" logic (maybe for the greedy customer); perhaps you might want to relook at that portion of code?

linminsaw commented 3 years ago

hmm i think the problem here is the queue where customers wait in is not properly updated? maybe you didn't poll at the correct time thats why there's no space for the customer to queue

TMTM98 commented 3 years ago

@linminsaw Should not be the case since the Served event of line 866 reduces the queue by 1, since line 866 appeared, it means the queue was indeed reduced.

TMTM98 commented 3 years ago

If its any help, here is how the reduction happens in the Served event: image

As you can see, if served was called by a wait event, there will be a queue reduction.

and here is what happens in arrival to call the next event: image

and here is how the server is selected if the customer is greedy vs non-greedy: image

image