Getting the Most Detection Power per Dollar
Zero-day attacks hit before a patch or signature exists, so defenders depend on early signals from many sources: commercial feeds, OSINT, information-sharing communities (ISACs), dark web monitoring, vendor advisories, honeypots, EDR telemetry, and bug bounty intelligence. Every source costs money, and every source has diminishing returns. The real question is how to split a limited budget across sources to maximize expected detection and defensive value.
In this article we build a concrete model, solve it with Python, and visualize the result, including a 3D objective surface.
1. The Problem Setting
We have $N = 8$ intelligence sources and $M = 6$ zero-day threat categories (Browser RCE, VPN Appliance, Email Gateway, Supply Chain, Cloud IAM, Mobile OS). The total budget is $B = 100$ (in arbitrary cost units).
Decision variable: the investment $x_i \ge 0$ in source $i$.
Diminishing returns. The quality of source $i$ grows with investment but saturates:
$$
p_i(x_i) = 1 - e^{-a_i x_i}
$$
where $a_i$ is the source’s investment efficiency.
Timeliness. A source with an average delay of $\tau_i$ days loses value for zero-days, where speed matters most:
$$
e_{ij} = r_{ij}, e^{-\lambda \tau_i}
$$
Here $r_{ij}$ is the relevance of source $i$ to threat $j$, and $\lambda = 0.06$ is the decay rate.
Detection probability for threat $j$ is the probability that at least one source catches it. Treating sources as independent:
$$
D_j(\mathbf{x}) = 1 - \prod_{i=1}^{N}\left(1 - e_{ij},p_i(x_i)\right)
$$
Objective. With $w_j$ as the potential damage (business impact) of threat $j$, we maximize the expected loss avoided:
$$
\max_{\mathbf{x}} ; F(\mathbf{x}) = \sum_{j=1}^{M} w_j, D_j(\mathbf{x})
\qquad \text{s.t.} \quad \sum_{i=1}^{N} x_i \le B,;; x_i \ge 0
$$
Because the product term makes $F$ non-concave in general, a single local optimization can get stuck. We therefore combine SLSQP with multiple random restarts, and cross-check against a greedy marginal-gain algorithm and a naive equal split.
At an interior optimum, the KKT conditions say that every funded source has the same marginal value per unit of budget:
$$
\frac{\partial F}{\partial x_i} = \mu \quad \text{for all } i \text{ with } x_i > 0
$$
This is the “equalize the marginal return” principle that governs the allocation.
2. The Complete Source Code
1 | import numpy as np |
3. Code Walkthrough
Data definition (Section 1)
aholds the efficiency coefficients $a_i$. A larger value means the source reaches its saturation point with less money. Vendor advisories (0.070) saturate quickly, while bug bounty intelligence (0.030) needs far more investment to deliver comparable value.tauandlamproduce the timeliness factor $e^{-\lambda\tau_i}$. Honeypots and EDR telemetry (1 day) keep about 94% of their value, while vendor advisories (8 days) keep only about 62%. This is why speed is built into the model: for zero-days, stale intelligence is nearly worthless.Ris the relevance matrix $r_{ij}$. EDR telemetry is broadly relevant, whereas honeypots are strong for VPN appliances but weak for mobile OS threats.E = R * timeliness[:, None]multiplies each row by its source’s timeliness factor using broadcasting, giving the effective relevance $e_{ij}$ in one line.wencodes business impact. Supply chain compromise is weighted highest (100), and mobile OS threats lowest (45).
Model functions (Section 2)
detection(x) is fully vectorized. It computes $p_i$ for all sources at once, builds the $N \times M$ matrix of miss probabilities $1 - e_{ij}p_i$, and multiplies down the source axis with np.prod(..., axis=0). No Python loops are needed, which matters because the optimizer calls this function thousands of times. objective(x) is the weighted sum $F(\mathbf{x})$.
Solvers (Section 3)
solve()uses SLSQP (sequential least squares programming), which handles bound and inequality constraints natively. We minimize $-F$ with the constraint $B - \sum x_i \ge 0$. A defensive clip and rescale guards against tiny numerical constraint violations.- Multi-start: because $F$ is not guaranteed concave, we restart SLSQP from eight random Dirichlet-distributed starting points (each sums to $B$) and keep the best result. A fixed seed (
default_rng(0)) makes the output reproducible. greedy()allocates the budget one unit at a time to whichever source offers the largest marginal gain. It is a useful independent check: if greedy and SLSQP agree, we can be more confident that we found the global optimum.x_eqis the naive baseline of spending the same amount everywhere.
Budget sweep (Section 5)
We re-solve the problem for 20 budgets from 10 to 200. Each solve is warm-started from the previous solution, scaled to the new budget, which is the speed-up here. We also compare against the equal split at every point and keep whichever is better, so the plotted curve is never worse than the baseline even if a local solver stalls.
Surface computation (Section 6)
We pick the two most-funded sources, vary only those two investments over a $31 \times 31$ grid while holding the others at their optimal values, and evaluate $F$. This slice shows the shape of the objective around the optimum. It takes only 961 cheap vectorized evaluations, so no further acceleration is required.
Plotting (Section 7)
fig.add_subplot(2, 3, k) creates the 2-row, 3-column layout, with the sixth panel declared as a 3D axis.
4. Execution Results
=== Budget = 100 === Optimal (SLSQP) : expected loss avoided = 329.05 / 450 ( 73.1%) Greedy : expected loss avoided = 329.04 / 450 ( 73.1%) Equal split : expected loss avoided = 311.39 / 450 ( 69.2%) Optimal allocation: Commercial Feed : 18.14 OSINT : 9.06 ISAC Sharing : 19.31 Dark Web Monitoring : 6.02 Vendor Advisories : 13.14 Honeypot Network : 3.79 EDR Telemetry : 30.54 Bug Bounty Intel : 0.00 Detection probability per threat (optimal vs equal): Browser RCE : 0.787 vs 0.743 VPN Appliance : 0.753 vs 0.731 Email Gateway : 0.759 vs 0.710 Supply Chain : 0.689 vs 0.647 Cloud IAM : 0.683 vs 0.647 Mobile OS : 0.692 vs 0.647
–

5. Interpreting the Results
Strategy comparison
With a budget of 100, the optimized allocation avoids about 329.05 of the total potential loss of 450, a 73.1% reduction. The greedy method reaches almost exactly the same value (329.04), which supports the conclusion that the optimizer found the global optimum. The equal split reaches only 311.39 (69.2%). In other words, simply spending smarter, with no extra money, yields roughly 18 more units of avoided loss.
The optimal allocation
The optimizer concentrates the budget as follows:
- EDR Telemetry: about 30.5. This is the clear winner. It combines high relevance across all threat categories with a 1-day delay, so its effective relevance values are the largest in the heatmap.
- ISAC Sharing: about 19.3 and Commercial Feed: about 18.1. Both offer strong, broad coverage at moderate delay.
- Vendor Advisories: about 13.1. The high efficiency coefficient makes the first dollars very productive, but the 8-day delay caps its usefulness.
- OSINT (9.1), Dark Web Monitoring (6.0), Honeypots (3.8) receive smaller allocations.
- Bug Bounty Intel: 0. Low efficiency, a long delay, and limited relevance make it the first source to drop out of the portfolio.
The equal split ignores all of this and wastes money on saturating or weak sources.
Panel-by-panel reading
- Allocation by Strategy. The optimal bars are strongly uneven, while the equal-split bars are flat. The greedy bars nearly overlap the optimal ones.
- Coverage per Zero-Day Threat. The optimized portfolio improves every threat’s detection probability. For example, Browser RCE rises from 0.743 to 0.787 and Supply Chain from 0.647 to 0.689. The largest absolute gains appear for high-impact threats, which is exactly what the weights $w_j$ ask for.
- Effective Relevance Heatmap. Rows for EDR telemetry, ISAC, and commercial feeds are the warmest. This heatmap explains most of the allocation before any optimization is run.
- Diminishing Returns vs Budget. The optimal curve rises steeply at first and then flattens, reflecting the saturation $1 - e^{-a_i x_i}$. The gap between the optimal and equal-split curves is widest at small and moderate budgets, where choosing well matters most. It narrows as the budget grows, because eventually everything gets funded.
- Optimal Allocation Shift. The stacked area chart shows how the portfolio evolves. At small budgets, a few high-value sources dominate. As the budget grows, additional sources enter the mix once earlier ones approach saturation. This is the practical “funding order” a security team can follow when the budget changes.
- 3D Objective Surface. The surface over the two top-funded sources rises and then flattens in both directions, and the red dot marks the optimum on the plateau. The gentle slopes around the dot show that the solution is robust: a modest error in the budget split costs little, while the steep walls near zero show how costly it is to starve a key source.
6. Key Takeaways
- Zero-day defense is a portfolio problem: sources overlap, saturate, and decay in value with delay.
- Modeling timeliness explicitly, through $e^{-\lambda\tau_i}$, shifts money toward fast sources such as EDR telemetry and honeypots.
- Because the objective is non-concave, multi-start local optimization plus an independent greedy check is a cheap and reliable way to build trust in the answer.
- The same framework extends naturally to per-source minimum commitments (contracts), integer licensing tiers, or correlated sources, by changing the detection model and the constraints.
Replace the toy numbers with your own relevance estimates, delay measurements, and business-impact weights, and the same code becomes a practical decision aid for your next intelligence budget review.















