Systems Thinking with AI

Chapter 18

Events, Queues, Agents, and Hybrid Models

When an aggregate model and a queue are joined, the seam between them is part of the model.

Four demonstrations of the chapter's staffing model and patient queue. Change how often they exchange numbers, test the queue alone, test the staffing rule alone, and check whether the frequency finding survives a different random seed.

Every example in these readers is a constructed teaching example built from the chapter's own numbers. Chapters 36 to 39 start from published public records; their fitted values are inferred from those records, and nothing here is a forecast.

1Demonstration 1 of 4

Feedback sampling is a modeling decision

If only the exchange interval changes, how different is the staffing the coupled model produces?

A stale reading is an information delay inside a feedback loop. The rule keeps acting on an old residence time, so staffing overshoots and swings on the interval's own period.

Equation: the coupled model run for 60 periods exchanging every period with seed 5

Equation: the coupled model run for 60 periods exchanging every eighth period with seed 5

Staff is the number of clinicians in the aggregate model. The backlog side receives nine patients per hourly period and clears them in batches at each hourly boundary. Exchanging every k periods means the staffing rule sees a mean residence time refreshed only every k periods; server counts still cross every period. Volatility is the standard deviation of staff over the 60 periods; residence is in hours.

Predict first. Does exchanging every 8 periods give a larger staffing range than exchanging every period?

Choose an example

Figure: Feedback sampling is a modeling decision. Staffing over 60 periods with seed 5, exchanging every 8 period(s) in dark blue over a pale line for exchanging every period; the dark path ranges from 6.6 to 27.7.
Exchange every (periods): 8
Constructed example: the chapter's own two runs with seed 5, plus intervals 2 and 4 defined for this reader.

Calculated values

Exchange every (periods)
8
Staffing volatility
4.75
Staff range
6.6 to 27.7
Mean residence (hours)
0.61
Volatility against exchanging every period
5.42

Volatility ratio = 4.7458/0.8761 = 5.42 (unrounded volatilities). Staff range 27.7 - 6.6 = 21.1 against 12.2 - 7.9 = 4.3 when exchanging every period. Mean residence 0.61 against 0.52, a difference of 0.09 hours. The rule corrects against a residence time measured up to 7 periods ago, an information delay inside a feedback loop.

Use the idea

Choose the exchange interval from the system's timescales and write it beside the equations.

Where the conclusion applies

One seed, 60 periods and the chapter's rule. Neither run settles; an interval picked for speed can report a behaviour that belongs to the interval.

Check your understanding: If the interval is 8 periods, how old can the residence time the rule acts on be, at most?
8 - 1 = 7 periods old, just before the next exchange.

Chapter 18 source: section "Feedback sampling is a modeling decision".

2Demonstration 2 of 4

Nine patients per period become nine arrival events

With the staffing side held fixed, how does the queue behave as capacity moves relative to arrivals?

Going down the seam, an aggregate rate becomes individual events. Each period that capacity falls short of arrivals adds the shortfall to the queue.

Equation: the coupled model run for 60 periods exchanging every period with seed 5

Arrivals are patients per period, each given a random time inside the period. Each server clears one patient per period at the period's end. Waiting is patients still in the backlog at the end of a period; residence is in hours, from arrival to the end of the period in which a patient is cleared.

Predict first. With 9 arrivals and 8 servers, how many patients are waiting after 12 periods?

Choose an example

Figure: Nine patients per period become nine arrival events. Two panels over 12 periods with 9 arrivals and 9 servers: patients waiting end at 0 and the mean residence ends at 0.50 hours.
Servers: 9, Arrivals per period: 9
Constructed example: the chapter's patient queue with arrival and server counts defined for this reader.

Calculated values

Arrivals per period
9
Servers
9
Patients waiting after 12 periods
0
Mean residence in the last period (hours)
0.50
Mean residence in the first period (hours)
0.31

Backlog change per period is 9 - 9 = 0, so it stays at 0 patients. Mean residence of those cleared went from 0.31 to 0.50 hours. Capacity equals arrivals exactly, a tie: nothing queues, and the residence time is only the spread of arrival times within a period.

Use the idea

Test the queue with a constant server count before closing the loop, so a defect is not hidden inside the coupling.

Where the conclusion applies

Seed 5, one hour per service, 12 periods, and arrivals spread evenly at random within a period. Spreading them differently would change the residence times, which the chapter notes is a modelling choice.

Check your understanding: With 10 arrivals and 8 servers, how many patients wait after 12 periods?
(10 - 8) x 12 = 24 patients.

Chapter 18 source: section "What each side may assume".

3Demonstration 3 of 4

The staffing rule alone has an equilibrium

With the residence time held constant, where does the staffing rule settle and how fast?

The target is anchored to the baseline, not the current staff, so a constant residence time gives a constant target and the staff moves smoothly toward it.

Equation: the coupled model run for 60 periods exchanging every period with seed 5

Staff starts at the baseline of 10. The target is 10 times the mean residence time over the target residence of 0.5 hours, capped at three times the baseline. Each period staff closes 1/(adjustment time) of the gap.

Predict first. If the residence time is held at 0.75 hours, what staffing level does the rule head toward?

Choose an example

Figure: The staffing rule alone has an equilibrium. Staffing from a baseline of 10 under a constant residence time of 0.75 hours and an adjustment time of 4, approaching a dashed target of 15.0.
Constant residence time (hours): 0.75, Adjustment time (periods): 4
Constructed example: the chapter's staffing rule with the three constant residence times of the chapter's test and others defined for this reader.

Calculated values

Staff the rule aims at
15.0
Staff after 1 period
11.25
Staff after 40 periods
15.00
Gap still open after 40 periods
0.00

Target = 10 x (0.75/0.5) = 15.0. First period: 10 + (15.0 - 10)/4 = 11.25. After 40 periods staff is 15.00, leaving a gap of 15.0 - 15.00 = 0.00. A slower adjustment time closes the gap more slowly.

Use the idea

A constant input should give a stable output; if the aggregate side alone cannot settle, no coupling can fix it.

Where the conclusion applies

The residence time is an input held fixed, which the coupled model never does. The cap and the floor of one clinician are the chapter's rules, not facts about clinics.

Check your understanding: If the residence time is held at 0.25 hours, what staffing does the rule head toward?
10 x (0.25/0.5) = 5 clinicians.

Chapter 18 source: section "Testing across the seam".

4Demonstration 4 of 4

Does the frequency finding survive another seed?

If the random seed changes, does exchanging less often still multiply the staffing swing?

The chapter reports one seed. Another seed gives different arrival times and, with them, a different size of effect, so a single pair of runs does not settle the matter.

Equation: the coupled model run for 60 periods exchanging every period with seed 5

Equation: the coupled model run for 60 periods exchanging every eighth period with seed 5

A seed fixes the random arrival times. Volatility is the standard deviation of staff. The ratio is the volatility with an exchange every 8 periods divided by the volatility with an exchange every period.

Predict first. With seed 7 over 60 periods, is the volatility ratio near the chapter's 5.4?

Choose an example

Figure: Does the frequency finding survive another seed?. Staffing paths for seed 5 over 60 periods, exchanging every period in teal and every eighth period in red; the volatility ratio is 5.42.
Random seed: 5, Periods simulated: 60
Constructed example: the chapter's two coupled runs repeated with other seeds and run lengths defined for this reader.

Calculated values

Volatility, every period
0.88
Volatility, every 8 periods
4.75
Ratio
5.42
Chapter's seed 5 over 60 periods
0.88 and 4.75

Ratio = 4.7458/0.8761 = 5.42 for seed 5 over 60 periods. The chapter's seed 5 over 60 periods gives volatilities 0.88 and 4.75, about 5.4 times. The slower exchange swings clearly wider, as the chapter's run does.

Use the idea

Where a finding depends on the exchange interval, report it across several seeds, as the chapter suggests for the frequency.

Where the conclusion applies

Four seeds and two run lengths; this is a robustness check on a constructed model, not an estimate of how real clinics behave.

Check your understanding: With volatilities of 0.80 and 1.39, what is the ratio?
1.39 / 0.80 = 1.74 from the rounded figures (1.73 from the unrounded volatilities 1.3896 / 0.8010), far smaller than the chapter's 5.4 times.

Chapter 18 source: section "The seam is part of the model".