Closed-loop Bayesian optimization of flow reaction conditions using inline HPLC/UV feedback — autonomous experimentation without a chemist in the loop
Self-driving flow chemistry platforms reframe reaction optimization as a black-box function maximization problem: given a set of continuously adjustable process variables, find the combination that maximizes (or multi-objectively balances) yield, purity, and throughput — without requiring the algorithm to understand the underlying reaction mechanism.
Self-optimization requires an experimental platform that can (1) rapidly execute a proposed condition, (2) reach a representative steady-state measurement, and (3) reset to a new condition — all without manual intervention. Batch chemistry fails all three requirements: each condition requires charging, heating, holding, sampling, and cleaning a vessel, a process typically taking hours and requiring operator involvement.
Flow chemistry satisfies all three natively. Because a flow reactor is already a continuously operating system, changing "temperature" or "residence time" is simply a matter of writing a new setpoint to a temperature controller or syringe/HPLC pump — the physical reactor volume and geometry never change. A new steady state is reached after 3–5 residence times (often under 5 minutes for coil reactors in the 1–10 mL range), at which point the reactor is, in effect, "a new batch experiment" ready for measurement.
The optimization campaign in this simulation targets the same SNAr amination system characterized in the standalone residence-time-optimization study (aryl fluoride + piperazine, k1 Ea=58 kJ/mol, competing dealkylation k2 Ea=91 kJ/mol) but now allows the algorithm to search all three variables jointly, including combinations a human chemist might never think to try (e.g., very short τ at very high T, which a manual DoE grid frequently skips because it seems intuitively unproductive).
The declared design space spans T=40–140 °C, τ=0.5–10 min (achieved via pump flow rate 1–20 mL/min through the fixed 10 mL coil), and stoichiometric ratio of piperazine to aryl fluoride from 1.0 to 3.0 equivalents — a continuous 3D volume containing effectively infinite candidate conditions, of which only a few dozen can be physically sampled within a practical campaign timeline.
The entire self-optimization loop depends on a fast, automated, and quantitative readout of reaction outcome at every tested condition. This is provided by two complementary inline analytical technologies sampling the reactor effluent directly, without any manual workup or sample preparation.
A segmented-flow autosampler interface (based on designs pioneered at MIT by the Jensen group, and commercialized in platforms like the Vapourtec/Chemspeed autonomous flow systems) periodically diverts a small slug of reactor effluent, separated by air or immiscible-solvent segments to prevent cross-contamination between successive samples, into an inline UPLC injection loop.
Each injection is run on a fast gradient method (Acquity BEH C18, 1.7 µm, 50×2.1 mm, 5→95% MeCN/H2O over 60 s, total cycle including re-equilibration 90 s) quantifying starting material, product, and the dealkylated impurity by peak area against a pre-calibrated response factor — giving conversion, yield, and impurity level for every sampled condition without any manual intervention.
A second, faster instrument — an inline UV/Vis flow cell (2 mm pathlength, response time ~2 s) monitoring absorbance at 265 nm — provides a continuous, lower-information proxy signal used to detect when the reactor has reached steady state after a new condition is set (absorbance stabilizes to <2% RSD over a 60 s window), triggering the UPLC injection at the earliest valid moment rather than on a fixed timer. This adaptive timing means low-τ (fast-equilibrating) conditions are sampled and moved past quickly, while high-τ conditions are given the necessary longer settling time — maximizing experiments-per-hour throughput of the whole campaign.
Total analytical duty cycle per tested condition (reach steady state + UPLC injection + data reduction) averages approximately 6 minutes, meaning a self-optimization campaign can execute roughly 8–10 fully quantified experiments per hour of unattended operation, versus perhaps 2–4 manually-run batch experiments per working day for a comparable human-executed DoE.
At the heart of the self-optimization loop is a Gaussian process (GP) regression model that treats the unknown relationship between process conditions and yield as a random function, updating its belief — both a predicted mean and a calibrated uncertainty — after every new experimental data point.
A Gaussian process defines a distribution over functions: given a set of observed (x, y) pairs — here x = (temperature, residence time, stoichiometry) and y = measured yield — the GP posterior provides, for any untested x, both a predicted mean ŷ(x) and a variance σ²(x) quantifying confidence in that prediction.
The covariance between any two points is defined by a kernel function; this campaign uses a Matérn 5/2 kernel with automatic relevance determination (ARD), meaning a separate lengthscale is learned for each of the three input dimensions — allowing the model to discover, for instance, that yield is highly sensitive to small changes in residence time near the optimum but comparatively insensitive to stoichiometry above 1.8 equivalents, without this being hard-coded in advance.
The campaign begins with 8 space-filling experiments chosen by Latin hypercube sampling (LHS) across the full 3D design box — a strategy that guarantees reasonable coverage of the space before any adaptive, model-guided experiments begin, avoiding the common failure mode where a purely greedy algorithm gets stuck exploring only the region around its first lucky result.
After each new experimental result, GP hyperparameters (kernel lengthscales, output variance, and observation noise) are re-fit by maximizing the marginal likelihood — a computation taking well under a second even for datasets of several hundred points, meaning model updating never becomes the bottleneck relative to the ~6 minute physical experiment cycle time. By 20 total experiments, the GP surrogate achieves an out-of-sample predictive R² of 0.91 against held-out validation points, indicating the model has captured the dominant structure of the true (unknown) yield surface — including the yield-maximizing ridge along which τ shortens as T increases, consistent with the Ea1<Ea2 kinetic behavior established in the manual residence-time study.
Because the GP model requires no assumed reaction mechanism, it discovers the same qualitative trend (shorter optimal τ at higher T) that was derived from first-principles Arrhenius analysis in the manual residence-time-optimization study — but does so directly from data, without any chemist needing to propose the underlying kinetic scheme in advance.
Knowing the GP's current mean and uncertainty surface is not enough — the platform needs a rule for converting that belief into the next physical experiment. This is the role of the acquisition function, which explicitly trades off exploiting regions predicted to be good against exploring regions where the model is still uncertain.
The Upper Confidence Bound (UCB) acquisition function scores every candidate condition x as:
UCB(x) = µ(x) + β·σ(x)
where µ(x) is the GP posterior mean (predicted yield) and σ(x) is the posterior standard deviation (uncertainty) at that point, and β is a tunable weight controlling how much the algorithm values exploring uncertain regions versus exploiting the current best-known region.
At the start of the campaign, β is kept relatively high (β≈3–4), favoring exploration of the design space to build a globally accurate model and avoid premature convergence to a local optimum. As the campaign progresses and the GP's uncertainty shrinks across most of the space, β is annealed down (β≈0.5–1) to focus remaining experimental budget on precisely refining the region around the current best point.
Because the flow platform can physically run more than one condition "simultaneously" in a coarse sense (by rapidly cycling through several setpoints within an hour), a batch acquisition strategy — here, the Kriging Believer heuristic, which greedily selects q points by iteratively pretending each selected point's outcome equals the GP's current mean prediction before choosing the next — proposes 3–4 conditions per round rather than one, better using the platform's unattended overnight operating capacity.
The autonomous loop — propose condition(s) via acquisition function → execute in flow reactor → measure by inline UPLC/UV → update GP posterior → re-optimize acquisition function → propose next condition(s) — runs with zero human intervention for the bulk of the campaign. Across 19 sequential rounds (57 total experiments, including the 8 initial LHS points), best observed yield rose from 41% (best of the initial space-filling set) to 89%, with the steepest gains occurring in rounds 9–14 as the GP model converged on the high-yield ridge near τ≈1 min, T≈115–122 °C, stoichiometry≈1.6 eq.
An autonomous optimization loop needs a well-defined stopping rule and, critically, a final confirmatory step — the algorithm's single best-observed point must be independently reproduced before it is trusted as a validated process condition, since any single measurement carries analytical and process noise.
The optimization loop is terminated automatically when the improvement in best-observed yield across 5 consecutive rounds falls below a pre-set threshold (0.5% absolute yield) — a simple but effective convergence criterion that avoids both premature stopping (missing a nearby further improvement) and wasted experimental budget chasing diminishing returns once the true optimum has effectively been located.
In this campaign, convergence was reached after 23 total rounds (69 experiments, including the 8-point LHS seed), consuming 11.5 hours of largely unattended instrument time — compared to the 9-day, ~30-run manual τ/T sweep campaign described in the companion residence-time-optimization study that arrived at a closely comparable operating point (τ=68 s, 118 °C vs. the autonomously discovered τ=71 s, 119 °C, 1.7 eq piperazine) via first-principles kinetic reasoning rather than black-box search.
Because any single flow experiment carries measurement noise (UPLC peak integration variability, minor pump flow-rate fluctuation, ±0.5 °C thermostat variation) on the order of 1–2% absolute yield, the single best-observed data point from the autonomous search cannot be taken directly as the validated process condition. A confirmatory step re-runs the identified optimal condition in triplicate (n=3, independent steady-state approaches, independent UPLC injections) — here yielding 94.1 ± 0.6% isolated yield, consistent with (and marginally exceeding) the point estimate found during active optimization, and with acceptably low run-to-run variability for CMC process characterization purposes.
The validated optimum, plus the full GP posterior surface (which doubles as an implicit design-space robustness map — regions of the 3D box where predicted yield remains >90% even under modest parameter drift), is exported as the design space characterization deliverable and handed to the scale-up team as the operating center-point for the numbering-up campaign.
A key advantage of the Bayesian approach beyond simply finding the optimum: the GP posterior variance map is itself a design-space robustness assessment. Regions where predicted yield stays above 90% across a ±5 °C, ±10 s τ perturbation window can be identified directly from the fitted model — informing which process parameters need the tightest control in production without any additional dedicated robustness experiments.