I am new in Simpy. I have a vehicle which stops at 3 different Resources to be serviced. The vehicle moves in the domain continuously, the Resources are active between the hours of 7 and 19 and do other processes concurrently (I addressed this with PriorityResource). The simple way I tackled this seems to work most of the time, but I suspect there is a precision problem with the line [wait_time = 12.0 - clock_hours + 19.0] since occasionally clock_hours+wait_time may result in a floating point value infinitesimally larger than 7.0. As a result the process with resource priority=1 does not always start first. I looked at manipulating time with datetime but it seems chaotic to me.
def start_shift(self, env):
time_now = env.now
wait_hours = 0
clock_days, clock_hours = divmod(time_now, 24)
if clock_hours <= 7.0 or clock_hours >= 19.0:
wait_time = 12.0 - clock_hours + 19.0
wait_days, wait_hours = divmod(wait_time, 24)
yield env.timeout(wait_hours)
Any ideas on how I can manipulate time in a more humanised way?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…