Open yanqiyqh opened 1 year ago
Potential issues might include:
serviceTime
before you actually start servicing the customer.Hello! I had the same issue and it was due to calling get() to get the service time before serve event occurs
@wilsonwid do you mind sharing how you implement it such that serviceTime is only retrieved when serveEvent is executed? As for my implementation, the serviceTime is called in wait event to update the expecetedServeTime and busyUntil. If i getServiceTime only when serveEvent is executed, i will get the error shown above
Served served = new Served(customer, manager.getServer(freeQueueIndex), nextFreeTime);
customer = customer.setServedTime(served.getOccurrence());
Done done = new Done(customer, manager.getServer(freeQueueIndex), customer.getServedTime() + customer.getServiceTime());
manager = manager.addServerQueue(freeQueueIndex, served.getOccurrence(), done.getOccurrence());
double waitTime = served.getOccurrence() - customer.getArrival();
Wait wait = new Wait(customer, manager.getServer(freeQueueIndex));
code snippet of calling get when a customer has to wait to be served. i'm not sure whether i'm calling service time before the serve event as i only call it in my Done event
@wilsonwid do you mind sharing how you implement it such that serviceTime is only retrieved when serveEvent is executed? As for my implementation, the serviceTime is called in wait event to update the expecetedServeTime and busyUntil. If i getServiceTime only when serveEvent is executed, i will get the error shown above
my implementation includes just having serviceTime in serve event. other times, i just use super of the previous event time. if you would like this implementation of serviceTime being only retrieved when serveEvent is executed, then you simply supply the customer with a supplier attribute now rather than a double serviceTime attribute, and use a .get() to obtain the serviceTime from the supplier within the customer.
I got exactly same error. There are possible reasons:
Hi, I came across this error as well. U have to retrieve the service time only when customer is served. u cant retrieve it in wait either
Got the same issue as well, solved it once i removed retrieving the service time from the wait event
If u only use the supplier.get() once in ServeEvent and still face this issue, maybe u wanna check whether it is called within the constructor? If it is used in constructor, the supplier is also called in the classes that make a new Serve even though it is only called in ServeEvent
hi all thanks for your help! ive resolved this by modifying the way i process the queue (i was calling service time before the customer was served) however ive encountered a new issue... do let me know if anyone has gotten this error before and how to resolve it.
all subsequent service times seem to be correct, so i don't think calling service time is an issue anymore, but im not sure why customer 18 and 14 is having problems with their done time being slightly off causing everything else to spiral out of control
Hi, given that the done time for 18 is late by 1sec while the done time for 14 is earlier by 1sec, could be possible that their service times were assigned wrongly i.e. service time for 18 is assigned to 14 and vice versa. You might want to check through ur logic for assigning service times and see if there's anything you missed out
Summary
I'm having trouble with test case 8 and not sure how to debug or find where my code logic is not appropriate.
Description:
From the screenshot I attached, the inputTimes seem to be getting jumbled up as expected output service time is different from my output. Am I calling for serviceTime too many times?
For context, I am currently running Simulator with a helper class ServerManager to manage the queues at each server and update the servers with customer done time when necessary. Simulator takes care of the events and flow (whether customer is immediately served, has to wait to be served, or has to leave) and calls for an available server from ServerManager to create the events.
Code Snippets
Attach code snippets (if any)
Screenshots