Lesson 4: Stepping forward
It is now time to move the engine forward by one period by calling step
.
During this period entities may arrive and others may depart.
Here is the code:
engine.step()
print(engine.get_number_of_entities_in_system_pmf())
Here is the output:
{2: 0.3000000000000001, 3: 0.7}
Note
No surprise here. Since there were no entities in the system initially, the number of entities in the system at time 1 is simply the number of arrivals in the first period, whose pmf was specified as an attribute.
Now take another step. Here is the code:
engine.step()
print(engine.get_number_of_entities_in_system_pmf())
And here is the output:
{2: 0.03239999999999999, 3: 0.19439999999999996, 4: 0.39239999999999997, 5: 0.30239999999999995, 6: 0.0784}
Note
This pmf is no longer obvious. But it can be reproduced by an alternative calculation, as shown here.
Here is the complete code so far:
from qplex import StandardMultiserver
engine = StandardMultiserver()
engine.number_of_arrivals_pmf = {2: 0.3, 3: 0.7}
engine.service_duration_pmf = {1: 0.6, 2: 0.3, 3: 0.1}
engine.number_of_servers = 2
print(engine.get_number_of_entities_in_system_pmf())
engine.step()
print(engine.get_number_of_entities_in_system_pmf())
engine.step()
print(engine.get_number_of_entities_in_system_pmf())