most read
Software Engineering
Why We Killed Our End-to-End Test Suite Sep 24
Product
Product Managers: what they do and why we need them Feb 15
Software Engineering
The value of canonicity Oct 30
Careers
We are building diverse teams with the most creative and innovative professionals for each position we open.



Author: Emanuel Fitta
Most practitioners learn experimental design through clean examples: control vs. treatment, version A vs. version B vs. version C, maybe a 2×2 factorial. In these cases, the statistics are tractable, the intuition is clear, and sample size calculations are straightforward.
However, many applied settings—from fintech and healthcare to operations and e-commerce personalization—have a much larger decision space. Multiple levers can each take several values, those choices can interact, and regulation, operations, or customer experience may rule out some combinations.
The number of possibilities grows quickly, making it statistically or operationally impractical to run every variant. This is where optimal design theory becomes useful and where textbook examples often stop being enough.
The Combinatorial Problem
Suppose we have an experiment with k factors, each with L levels. A full factorial design has L^k combinations. For example, with 4 factors and 5 levels each, there are 625 possible combinations. With 5 factors and 5 levels, that grows to 3,125. The design space grows exponentially, so full enumeration quickly becomes impractical.
One classical response is the fractional factorial design: choose a structured subset of the full factorial such that main effects and some interactions remain estimable. The underlying idea is to trade the ability to estimate some higher-order effects for a much smaller experiment while preserving the effects we care about most. In standard regular fractional factorial designs, this creates deliberate aliasing between effects and can produce balanced, orthogonal designs.
Standard fractional factorial designs work most cleanly in regular, unconstrained factor spaces with a pre-specified aliasing structure. In more irregular settings, such as mixed factor levels, forbidden combinations, or uncertainty about which interactions matter, classical constructions can become harder to apply directly. Optimal design, on the other hand, provides a more general framework for these messy cases.
Check our job opportunies
What Optimal Design Actually Optimizes
Choosing a design requires committing to a model. The question “Which runs should we allocate?” only makes sense relative to what we want to estimate. A design that is excellent for detecting main effects can be useless for detecting curvature or interactions. So before optimizing anything, we need to state how we expect the response to depend on the factors.
Linear models are a natural starting point for three reasons. First, over a limited experimental region, a smooth response surface can often be approximated locally with linear terms, adding interactions or quadratic terms when curvature matters. The linearity assumption is about the region we are studying, not about the system everywhere.
Second, the coefficients map directly to quantities practitioners care about: the effect of a factor, or the additional effect when two factors change together. Third, and crucially for experimental design, the precision of those coefficient estimates can be evaluated before we collect data. Up to the unknown error variance, their covariance depends on the design matrix rather than on the outcomes we have not yet observed. That is what turns design selection into an optimization problem instead of guesswork.
With that in mind, we can make the framework explicit. Each coefficient in the linear model represents a factor, interaction, or other model term. This separates two questions cleanly: what relationship do we want to estimate—the statistical model—and how should we allocate experimental runs to estimate it as precisely as possible—the experimental design?
In a linear model, the design matrix X represents the experiment: one row per experimental arm and one column per model term. From it we obtain the information matrix, M = X’X, which arises naturally in ordinary least squares. Up to the error variance, M determines how precisely the model coefficients can be estimated. When M is well-conditioned and nonsingular, the coefficients can be estimated with finite variance; when it is singular, at least some parameters are not separately identifiable from the available design.
Different optimality criteria summarize and optimize different aspects of M [3]:
D-optimality is the most widely used criteria in practice. It maximizes det(M), which, under the assumed model and a fixed design size, minimizes the volume of the joint confidence ellipsoid for β. It is also invariant to nonsingular linear reparameterizations, so the ranking of designs does not depend on an arbitrary choice among equivalent parameterizations.
The D-efficiency of a design is:
where p is the number of model parameters and n is the number of arms. This normalization summarizes the mean information per arm under the chosen model, factor coding, and candidate space. To measure the cost of restrictions, evaluate the same criterion for the constrained design and for an unconstrained benchmark, then compare the two on the same scale. Their ratio gives a relative D-efficiency for the constrained design under that benchmark.
Finding Good Designs Computationally
For small problems, we can enumerate all possible designs and pick the best. For anything realistic, the space is too large to search exhaustively. In such cases, Fedorov’s exchange algorithm [1] is a standard computational approach: a greedy local search that improves a candidate design one exchange at a time. It starts with a random set of n arms drawn from the feasible candidate set. For each arm in the current design and each candidate point outside it, the algorithm evaluates whether swapping the two would improve det(X’X). It accepts the best improving swap and repeats until no single swap increases the criterion.
Because the algorithm is greedy, it can converge to local optima; using multiple random restarts reduce that risk. Variants include the coordinate-exchange algorithm [2], which modifies one factor level at a time rather than swapping full arms. In R, `optFederov()` in the AlgDesign [4] package implements this directly: specify the candidate set, the model formula, and the number of arms, and the algorithm returns the D-optimal design within that space. In Python, PyOptEx provides D-optimal design generation through a coordinate-exchange algorithm rather than Fedorov’s exchange algorithm, supporting custom models, constraints, and optimization criteria. [5].
The Problem Textbooks Leave Out: Restrictions
In practice, the feasible candidate set is rarely “all combinations of factor levels.” It is narrowed by operational constraints, regulatory constraints, customer experience constraints, and engineering constraints. Some treatment combinations may be impossible to execute; some segments may be ineligible for certain treatments; some sequences may be unacceptable regardless of their statistical properties; and the number of treatments that can run in parallel may be bounded.
Restrictions affect the design in two ways. First, they shrink the feasible design space, so the information matrix is limited by what remains. Second—and more seriously—they can make the information matrix singular. This can happen when constraints create structural dependencies among model terms. For example, if level A at position 3 is only feasible when level B is absent from positions 1 and 2), then the design matrix X will have collinear columns for certain model specifications. The model we want to fit may be literally non-identifiable from the data we are allowed to collect.
When singularity happens, the model must be changed if we still want identifiable coefficients. That may mean dropping interaction terms, collapsing factor levels, or simplifying the experimental question until the remaining model is identifiable within the constrained space. This makes the cost of restrictions explicit: some effects may no longer be separately estimable. For example, let’s suppose we have two binary factors, A and B, and all four combinations are feasible. A D-optimal design for estimating both main effects and the AB interaction uses all four combinations, each once. Now a restriction makes (A=1, B=1) infeasible. Three candidate points remain. Main effects are still estimable, but the AB interaction is not: across the three remaining points, the interaction column carries no variation left to distinguish it from the model’s other terms, so its coefficient can’t be identified. The restriction costs us the ability to answer a question that was previously answerable.
The Information Loss Is Real and Irreversible
A common intuition is that restrictions are a nuisance that additional sample size can compensate for. If we cannot test every combination, perhaps we can simply assign more users to the combinations we can test. That works for precision, but not for identifiability.
Sample size buys precision within a design. More users per existing design point reduces the variance of our estimates. However,replication does not change the rank of the model matrix or create variation in a direction that the design never explores. If a restriction creates collinearity between two effects, no amount of additional data separates them. The information is structurally absent, not just statistically noisy.
The practical implication is that once we have imposed all necessary restrictions and computed the feasible candidate set, we should be reluctant to prune it further. Every additional reduction can lower precision and, in the worst case, make a target effect non-identifiable.
A Real Case: A Sequential Collections Experiment
To make this concrete, consider the design problem we faced building the Next Best Action Foundational Test at Nubank’s collections engagement team. The goal was to gather training data for a model that would recommend personalized action strategies for credit card customers. The available actions were Reminders, Bureau Warning, Credit Card Block Warning, Credit Card Block Action, and No action. Customers pass through up to four sequential time windows; at each one, the team selects one of five actions. The unconstrained space is 5^4 = 625 possible sequences.
After applying business constraints (rules about which action sequences are operationally forbidden or logically inconsistent) 175 feasible combinations remained, down from 625. The restrictions alone removed 72% of the candidate set. That sharply narrowed the variation available to identify effects in the model.
We modeled the main effects of each action at the first three positions as primary estimands. The fourth position could not be added as an independent model term without causing rank deficiency in the information matrix: in this setup, its assignment was deterministic given the decisions at earlier positions. Instead, we treated the fourth position as a secondary objective: maximize empirical coverage across its conditions within the feasible set.
Running `optFederov()` over all 175 feasible candidates against the main-effects model for the first three positions consistently returned a design that included all 175 combinations. This was not a pre-specified outcome; it emerged from the optimization. In our setup, the optimized design therefore did not recommend pruning the feasible candidate set any further. Under the chosen model, constraints, and design-size specification, reducing the set would lower the design criterion rather than improve it.
This may seem surprising, since optimal design is often associated with reducing the number of experimental runs. Here, however, the optimization did not reveal a smaller subset with better D-efficiency under the setup used.
The resulting design had a D-efficiency of 0.75 relative to the unconstrained benchmark used in the analysis. In that comparison, the constrained design retained 75% of the benchmark’s D-efficiency. The remaining gap quantifies the efficiency cost associated with the business rules under this model and benchmark.
The broader lesson is not that constrained D-optimal designs will always use every feasible point. Business restrictions can remove so much flexibility that further pruning becomes costly under the target model. The candidate set should therefore be reduced only after measuring what the reduction does to the design criterion and identifiability.
What This Means for Practitioners
Three rules are worth keeping in mind when designing constrained experiments:
Don’t prune the candidate set without analyzing the cost. Every combination removed can reduce precision and may, in some cases, eliminate identifiability for a target effect. Compute D-efficiency before and after proposed pruning, and be explicit about what effects are being sacrificed.
Restrictions are not free, and quantifying their cost matters. Before a stakeholder adds a constraint, evaluate how it changes D-efficiency and the rank or estimability of the target model. Sometimes the cost is negligible; sometimes it makes a key effect non-identifiable. Make the trade-off visible rather than absorbing it silently into the design.
Use the model as input to the design. D-optimal designs are model-dependent: what is optimal for a main-effects model differs from what is optimal for a model with two-way interactions. Be clear about which model the design targets, and remember that the design offers no guarantee of good estimation for terms the model did not prioritize.
Conclusion
Standard A/B testing is the right tool for a specific class of problems: small design spaces, few treatment arms, no structural constraints. For that class, it remains the right tool.
Many real problems do not belong to that class. Sequential decisions, multi-factor spaces, and business restrictions push experimenters beyond simple A/B tests and standard factorial setups. D-optimal design provides the theoretical and computational machinery to handle these cases, along with a language for understanding what our restrictions are costing us.
The core message is simple: when we cannot test everything, the choice of what to test is not administrative; it is statistical. Getting it wrong does not just mean lower power; it can make some questions structurally unanswerable from the resulting design.
When restrictions have already removed much of the candidate space, the best design may be less sparse than expected—and in some cases may use every feasible combination. The important point is to let the model and design criterion determine whether further pruning is justified. Restrictions already impose a statistical cost; do not add another one without measuring it.
Check our job opportunies