Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
230 views
in Technique[技术] by (71.8m points)

simpy - Wait time for start of shift

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...