Alert Response Time, Shift Rules, and Skill Coverage in One Model
A Security Operations Center (SOC) never closes, but alert volume is far from flat. It rises on patch days, drops on weekends, and falls sharply at night. Meanwhile the analysts are a mixed group: seniors who run incident response, mid-level hunters, and juniors still learning triage. Everyone also needs rest, vacation, and a fair share of night shifts.
This article builds a small but realistic model of that problem in three steps:
- Use queueing theory to translate alert volume and a response-time target into a required number of analysts per shift.
- Use mixed-integer linear programming (MILP) to build the cheapest weekly roster that covers those requirements, respects skill rules, and obeys labor constraints.
- Run a sensitivity analysis to see how cost changes when alert volume or the response-time target changes.
The Example Scenario
- Planning horizon: one week, with 3 shifts per day (Day 06:00–14:00, Evening 14:00–22:00, Night 22:00–06:00), giving 21 shifts.
- Analysts: 20 people: 5 Senior, 7 Mid-level, 8 Junior. Two of them are part-time (at most 3 shifts per week).
- Alert handling: each analyst processes 6 alerts per hour (about 10 minutes per alert).
- Alert arrivals: 16 per hour on day shifts, 12 on evening shifts, and 6 on night shifts, scaled by a day-of-week factor. Wednesday has a 1.35× surge, and weekends drop to 0.70× and 0.65×.
- Service level: the mean waiting time of an alert in the queue must be at most 2 minutes.
- Skill rules: every shift needs at least one IR-certified analyst and at least one Senior. Every Day shift also needs at least one threat hunter.
- Labor rules: at most one shift in any 11-hour window, 4–5 shifts per week for full-timers, at most 3 night shifts per person, individual days off, and some analysts who cannot work nights.
- Cost: hourly wage × 8 hours × a premium (Evening ×1.05, Night ×1.25, weekend ×1.10).
Step 1: How Many Analysts Does Each Shift Need?
Treat each shift as an $M/M/c$ queue. With arrival rate $\lambda$ (alerts per hour), service rate $\mu$ per analyst, and $c$ analysts on duty, the offered load is
$$
a = \frac{\lambda}{\mu}
$$
The probability that an arriving alert has to wait (the Erlang C formula) is
$$
P_{\text{wait}} = \frac{\dfrac{a^{c}}{c!}\cdot\dfrac{c}{c-a}}{\displaystyle\sum_{k=0}^{c-1}\frac{a^{k}}{k!}+\frac{a^{c}}{c!}\cdot\dfrac{c}{c-a}}, \qquad c > a
$$
and the mean waiting time is
$$
W_q = \frac{P_{\text{wait}}}{c\mu-\lambda}
$$
For each shift $s$, the minimum staffing level is the smallest integer $c_s$ such that
$$
W_q(\lambda_s,\mu,c_s) \le W_{\text{target}} = \frac{2}{60}\ \text{hours}
$$
Analysts do not all work at the same speed, so each analyst $a$ gets an efficiency factor $e_a$ (Senior 1.2, Mid 1.0, Junior 0.8). A shift is covered when its effective headcount reaches $c_s$.
Step 2: The Optimization Model
Let $x_{a,s}\in{0,1}$ equal 1 if analyst $a$ works shift $s$. The cost of that assignment is $w_{a,s}$ (wage × 8 × premiums).
$$
\min \sum_{a}\sum_{s} w_{a,s},x_{a,s}
$$
subject to:
$$
\sum_{a} e_a,x_{a,s} \ge c_s \quad \forall s \qquad \text{(effective capacity)}
$$
$$
\sum_{a\in \text{IR}} x_{a,s} \ge 1,\qquad \sum_{a\in \text{Senior}} x_{a,s} \ge 1 \quad \forall s \qquad \text{(skill coverage)}
$$
$$
\sum_{a\in \text{Hunter}} x_{a,s} \ge 1 \quad \forall s\in \text{Day shifts}
$$
$$
L_a \le \sum_{s} x_{a,s} \le U_a \quad \forall a \qquad \text{(weekly workload)}
$$
$$
\sum_{s\in \text{Night}} x_{a,s} \le 3 \quad \forall a \qquad \text{(night cap)}
$$
$$
x_{a,s}+x_{a,t}\le 1 \quad \text{if } \text{start}_t-\text{end}_s < 11\text{h} \qquad \text{(minimum rest)}
$$
Vacation days and “no night” flags are enforced by fixing the corresponding variables to zero. This gives 420 binary variables and 890 constraints, small enough for an exact solution with SciPy’s built-in milp solver (HiGHS), with no extra installation.
Speed Considerations
The expensive parts of this workflow are building the sparse constraint matrix and solving the MILP many times for the sensitivity analysis. The code below therefore builds the matrix once and only replaces the right-hand side of the capacity constraints for each scenario. The base roster is solved to proven optimality (mip_rel_gap=0), while the 20 sensitivity scenarios use a 1% optimality gap and a 30-second limit each. This keeps the whole script within roughly a minute in a typical notebook session.
Full Source Code
1 | import math |
Code Walkthrough
Section 1: Queueing helpers. erlang_c_wait evaluates $W_q$ with an iterative update of the terms $a^k/k!$, so no large factorials are ever computed and the function stays numerically stable. min_servers starts at $\lfloor a \rfloor + 1$, the smallest count that keeps the queue stable, and increases $c$ until the waiting-time target is met.
Section 2: Problem data. Shifts are indexed from 0 to 20 in chronological order. Each shift has an absolute start and end hour counted from Monday 00:00, which makes the rest rule easy to check later. The arrival rate of each shift is the base rate of its shift type multiplied by the day factor. The analyst table holds everything the model needs per person: efficiency, wage, certifications, workload bounds, “no night” flags, and vacation days.
Section 3: Building the MILP. The function build_model assembles the constraint matrix row by row:
- Rows (a)–(d) are the coverage constraints: effective capacity, IR, Senior, and threat hunter.
- Rows (e)–(f) limit the weekly workload and the number of night shifts per analyst.
- Row group (g) enforces the rest rule. Any pair of shifts separated by less than 11 hours gets a constraint $x_{a,s}+x_{a,t}\le 1$. This single rule covers “no two shifts in a day”, “no Night followed by Day”, and “no Evening followed by next-morning Day”. Night→Night and Evening→Evening remain legal.
Vacation and “no night” restrictions are applied as variable upper bounds of zero, which lets the solver remove those variables during presolve.
Section 3b: Reusing the matrix. The capacity constraints are the first $S$ rows, so solve_roster only overwrites the first 21 entries of the lower-bound vector with the scenario’s requirement. The matrix is never rebuilt, which is where the speed-up comes from.
Section 4: Base scenario. The base case is solved to proven optimality. Afterwards the script derives the metrics that matter operationally: assigned effective capacity, utilization $\rho=\lambda/(\mu\cdot\text{capacity})$, and the expected wait computed from the floor of the assigned effective capacity, which is a conservative estimate.
Section 5: Sensitivity grid. The script solves 20 scenarios (5 alert-volume multipliers × 4 waiting-time targets). Both variables change only the vector $c_s$, so the model structure stays identical.
Sections 6 and 7: Reporting. The console output is a shift-level table, the weekly roster, the cost by seniority level, and the sensitivity table. The final figure contains eight panels in a single image.
Console Output
================================================================================
SOC STAFFING OPTIMIZATION - BASE SCENARIO
================================================================================
Analysts: 20 | Shifts per week: 21 | Binary variables: 420 | Constraints: 890
Optimal weekly labor cost : 29,233
Solve time (exact) : 82.67 s
Sensitivity grid : 20 MILPs in 45.18 s
--- Shift-level result ---
shift lambda/h offered load required c headcount eff. capacity IR senior hunter utilization wait [min]
Mon-D 17.6 2.93 5 5 5.0 2 1 3 58.7 1.06
Mon-E 13.2 2.20 4 4 4.0 3 1 0 55.0 1.26
Mon-N 6.6 1.10 3 3 3.0 1 1 1 36.7 0.60
Tue-D 17.6 2.93 5 6 5.2 1 1 1 56.4 1.06
Tue-E 13.2 2.20 4 4 4.0 3 1 0 55.0 1.26
Tue-N 6.6 1.10 3 3 3.0 1 1 1 36.7 0.60
Wed-D 21.6 3.60 6 6 6.0 2 1 3 60.0 0.82
Wed-E 16.2 2.70 5 6 5.2 1 1 0 51.9 0.73
Wed-N 8.1 1.35 3 3 3.0 1 1 1 45.0 1.13
Thu-D 17.6 2.93 5 5 5.0 3 1 2 58.7 1.06
Thu-E 13.2 2.20 4 4 4.0 2 1 0 55.0 1.26
Thu-N 6.6 1.10 3 3 3.0 1 1 1 36.7 0.60
Fri-D 16.0 2.67 5 5 5.0 2 1 2 53.3 0.69
Fri-E 12.0 2.00 4 4 4.0 2 1 1 50.0 0.87
Fri-N 6.0 1.00 3 3 3.0 2 1 0 33.3 0.45
Sat-D 11.2 1.87 4 4 4.0 1 1 1 46.7 0.67
Sat-E 8.4 1.40 3 3 3.0 1 1 1 46.7 1.26
Sat-N 4.2 0.70 2 2 2.0 1 1 0 35.0 1.40
Sun-D 10.4 1.73 4 4 4.0 2 1 1 43.3 0.51
Sun-E 7.8 1.30 3 3 3.0 1 1 1 43.3 1.00
Sun-N 3.9 0.65 2 2 2.0 1 1 0 32.5 1.18
--- Weekly roster (D = Day, E = Evening, N = Night) ---
analyst level Mon Tue Wed Thu Fri Sat Sun shifts cost
A01 Senior N - - - E E E 4 2028
A02 Senior - N N N - - D 4 2134
A03 Senior E E - - D D - 4 1881
A04 Senior D D D D - - - 4 1824
A05 Senior - - E E N N N 5 2635
A06 Mid E E - E N - D 5 1760
A07 Mid D - D - D D - 4 1344
A08 Mid E E - D E - - 4 1328
A09 Mid D - D D D - - 4 1344
A10 Mid N - - E - D D 4 1440
A11 Mid - N N N - E E 5 1890
A12 Mid D - D D D - - 4 1312
A13 Junior - D E N - D - 4 1056
A14 Junior - D E - E - D 4 1008
A15 Junior N N N - - E E 5 1405
A16 Junior D D D D - - - 4 992
A17 Junior - D E - D N - 4 1062
A18 Junior - D E E N - N 5 1374
A19 Mid - - D - E - - 2 656
A20 Junior E E E - - - - 3 756
--- Cost by level ---
shifts cost
level
Junior 29 7653
Mid 32 11074
Senior 21 10502
--- Optimal weekly cost: SLA target x alert-volume multiplier (nan = infeasible) ---
x0.8 x0.9 x1 x1.1 x1.2
SLA 2 min 26594.0 27921.0 29326.0 29326.0 33089.0
SLA 3 min 26308.0 26594.0 28321.0 29326.0 29326.0
SLA 5 min 26131.0 26308.0 26356.0 27640.0 29326.0
SLA 8 min 26115.0 26131.0 26259.0 26356.0 26704.0
Reading the Console Results
The shift-level table shows how the Erlang C requirement turns into real staffing. Compare the columns required c and eff. capacity. The optimizer never goes below the requirement, and it exceeds it only when the skill rules or the rest rules force an extra person, for example when a Senior or an IR-certified analyst is needed to cover a shift. The wait [min] column stays below the 2-minute target in every shift, and utilization shows that the SOC runs at a moderate load rather than at its limit, which leaves headroom for bursts.
The roster table shows each analyst’s week as a sequence of D, E, N, and -. You can verify the labor rules by eye: no Night is followed by a Day or Evening the next day, nobody works on their vacation days, and the “no night” analysts have no N. The cost-by-level table shows where the budget goes. Seniors cost more per shift, but the model needs them in every shift for the skill rules, so their shift count is largely dictated by coverage rather than by cost.
Result Figure
Paste the single combined figure here.

Reading the Graphs
(1) Required vs. assigned capacity. Each bar is the effective capacity assigned to a shift, and the black step line is the Erlang C requirement. The bars sit on or just above the line. A bar that overshoots reveals where discrete people (a Junior at 0.8 or a Senior at 1.2) cannot add up exactly to the requirement. The Wednesday surge is visible as a tall block of Day and Evening bars, while the weekend and every Night shift sit low.
(2) Roster heat map. Rows are analysts, columns are shifts, and colors mark the shift type. Gray cells are days off. This view makes the structure of the solution visible: Night shifts are concentrated on analysts who accept them, vertical gaps appear where vacation days are blocked, and no analyst has an adjacent pair of incompatible shifts.
(3) 3D headcount bars. The three axes are the day of the week, the shift type, and the number of analysts on duty. The Day row forms a clear plateau with a Wednesday peak, the Evening row follows it at a lower level, and the Night row is the shortest. It is the whole weekly demand pattern in one picture.
(4) 3D Erlang C staffing surface. This surface shows the required number of analysts for any combination of alert rate and waiting-time target. Two effects are visible. The surface rises roughly linearly with alert volume, and it climbs steeply as the target becomes stricter, because squeezing the mean wait from several minutes toward half a minute costs extra people. The red dots mark the 21 shifts of the example, all lying on the 2-minute slice of the surface.
(5) Service quality by shift. The bars show the expected waiting time and the red line shows utilization. The waiting time stays far below the dashed SLA line everywhere. Utilization is highest during busy Day and Evening shifts and lowest at night and on weekends. Quiet shifts have low utilization by design: the skill rules (an IR-certified analyst and a Senior in every shift) and the Erlang C minimum prevent shrinking them further.
(6) Workload and cost per analyst. The stacked bars show how many Day, Evening, and Night shifts each analyst works, and the dashed line shows the weekly labor cost. Full-timers sit at 4–5 shifts, part-timers at 2–3. Cost differences come from wages and from the Night and weekend premiums, so analysts who work more nights and weekends show higher costs for the same number of shifts.
(7) Cost sensitivity to alert volume. Each line is one waiting-time target, plotted against the alert volume multiplier. All curves are non-decreasing and grow in steps, because staffing requirements are integers and a small increase in alerts only matters when it pushes a shift over a threshold. The strictest target reacts most to growing volume, while the relaxed targets stay almost flat. This tells a SOC manager how much headroom the current team has before it needs to hire.
(8) 3D optimal cost surface. The same data as panel (7) is shown as a surface over the volume multiplier and the waiting-time target. The cost is lowest where volume is low and the target is relaxed, and it rises toward the corner of high volume and strict target. The surface is a staircase rather than a smooth slope for the same integrality reason, and the steepest part of the slope shows which direction (more alerts or a tighter SLA) is more expensive to follow.
Takeaways
- Queueing theory gives a defensible, quantitative answer to “how many analysts do we need per shift?” instead of a rule of thumb.
- MILP turns that answer, together with skill, rest, workload, and availability rules, into a concrete roster at minimum cost.
- Building the constraint matrix once and changing only the right-hand side makes scenario analysis cheap, so the same model can answer questions like “what happens if alert volume grows 20%?” or “what does a 5-minute SLA save us?”
From here, the model can be extended with preference scores, fairness terms such as balancing weekend shifts, multi-skill queues with separate Tier 1 and Tier 2 demands, or a rolling horizon that re-plans every week.








