Lesson 5: Time-varying attributes
Engine attributes can be modified between steps. For instance, suppose there will be no arrivals after time 2. Here is additional code to obtain the pmf of the number of entities in the system at time 3:
engine.number_of_arrivals_pmf = {0: 1.0}
engine.step()
print(engine.get_number_of_entities_in_system_pmf())
And here is the output:
{0: 0.011663999999999999, 1: 0.089478, 2: 0.2598529541284403, 3: 0.3531530917431193, 4: 0.22280295412844045, 5: 0.05814900000000001, 6: 0.004900000000000005}
Similarly, suppose the service duration pmf changes at time 3 to
{1: 0.6, 2: 0.4}
Here is additional code to obtain the pmf of the number of entities in the system at time 4:
engine.service_duration_pmf = {1: 0.6, 2: 0.4}
engine.step()
print(engine.get_number_of_entities_in_system_pmf())
And here is the output:
{0: 0.17171275473984657, 1: 0.3103743950783459, 2: 0.30928273374065673, 3: 0.1693307367508906, 4: 0.03774537126363208, 5: 0.0015540084266281453}
As a final illustration, suppose that arrivals resume after time 4, and the number of servers increases from two to three. Here is the additional code to obtain the pmf of the number of entities in the system at time 5:
engine.number_of_arrivals_pmf = {2: 0.3, 3: 0.7}
engine.number_of_servers = 3
engine.step()
print(engine.get_number_of_entities_in_system_pmf())
And here is the output:
{2: 0.17549869068573712, 3: 0.5064339229667894, 4: 0.2505284902351039, 5: 0.05981766990727956, 6: 0.0072459780827977575, 7: 0.00047122549325886493, 8: 4.022629033519126e-06}
Note
This tutorial glosses over a lot of details. For example, you might be wondering: If the number of servers is decreased, what happens to entities already in service whose server has disappeared? These missing details can be found in the StandardMultiserver engine reference.
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())
engine.number_of_arrivals_pmf = {0: 1.0}
engine.step()
print(engine.get_number_of_entities_in_system_pmf())
engine.service_duration_pmf = {1: 0.6, 2: 0.4}
engine.step()
print(engine.get_number_of_entities_in_system_pmf())
engine.number_of_arrivals_pmf = {2: 0.3, 3: 0.7}
engine.number_of_servers = 3
engine.step()
print(engine.get_number_of_entities_in_system_pmf())