Search code examples
pythonschedulesimpy

how to use yield dynamically that doesnt effect the whole environment


I am new to python and I want to ask something in detail about simpy environment. so let's say it like this I have 2 cars and each car has to perform same function at different time but the problem is, when I used yield env.timeout(something) it change the whole environment time but in actual I want to do it separately. For example if car A is moving from point 1 at time t1 and doing some work at time t2 and after that the car 2 is moving and doing samework at time t3 and t4 but I want to do this like, let say the car A is moving from point 1 at time t1 and doing somework at time t2 in the same case the I want to move car 2 at time t1.5 even the car 1 is on its way at time t1.5. both of them should not be in depending mood. How to synchronize that? If someone has experience please help. thank you


Solution

  • you can define Car A and Car B as two difference environment process. Do not put CarA and CarB in the same function

    env.process(CarA(env))
    env.process(CarB(env))