A Swimming Bacterium and a Simulated-Annealing Algorithm Both Search Blind — But They Don’t Cheat the Same Way

Escherichia coli has no eyes, no compass, and no ability to sense which direction a food source actually lies in. It finds sugar anyway, using a strategy elegant enough that computer scientists building optimization algorithms have, over the decades, arrived at something that sounds remarkably similar: a search method that mixes random exploration with a bias toward improvement, letting an algorithm find good solutions in a landscape it has no map of. It’s tempting to treat bacterial chemotaxis and simulated annealing as the same trick wearing different costumes. They belong to the same broad family, but the specific mechanism each one uses to balance exploring versus committing turns out to differ in a precise, informative way.

Scientific Foundation

E. coli moves through its environment using a run-and-tumble strategy: the bacterium swims in a relatively straight line, called a run, propelled by its flagella rotating counterclockwise, and periodically stops to tumble, a brief chaotic reorientation caused by the flagella switching to clockwise rotation, before setting off on a new run in a new, largely random direction. What makes this chemotaxis rather than aimless wandering is a specific temporal comparison the bacterium performs continuously: it can’t sense a chemical gradient spatially, comparing concentration at its front versus its back, because it’s too small for that comparison to be reliable given ordinary measurement noise. Instead, it compares the concentration it’s experiencing now to what it experienced a few seconds ago, as it moves. When conditions are improving over that recent time window, the bacterium suppresses its tumbling and extends the current run; when conditions are worsening or staying flat, it tumbles sooner. The result, confirmed in classic work by Howard Berg and others, is a biased random walk: runs pointed in a favorable direction last longer on average than runs pointed the wrong way, and over many cycles this bias reliably carries the bacterium up a chemical gradient, with a further refinement showing the reorientation after a tumble isn’t perfectly random either, but somewhat biased toward continuing in roughly the forward direction.

Simulated annealing, developed by Kirkpatrick and colleagues building on the earlier Metropolis algorithm, searches an unknown solution landscape through a different, more explicitly structured cycle. At each step, the algorithm proposes a candidate move to a new state, then decides whether to accept it using a specific rule: a move that improves the objective is always accepted, but a move that makes things worse is still accepted some of the time, with a probability governed by exactly how much worse it is and by a temperature parameter that starts high and is deliberately, systematically lowered over the course of the run. Early on, at high temperature, the algorithm accepts a lot of bad moves, allowing it to explore broadly and escape shallow local traps; as the temperature cools, it becomes progressively stricter, converging toward something closer to pure hill-climbing, always taking the best available option. That deliberate willingness to accept a worse state, calibrated by a temperature schedule that shrinks predictably over time, is the defining engineering trick that gives simulated annealing its name and its power.

Cross-Domain Connection

Both processes solve the same abstract problem — searching an unknown landscape for good regions without ever computing a gradient or seeing a map — using the same broad ingredients: randomness for exploration, and a bias favoring improvement for exploitation. That’s a genuine, useful family resemblance, not a coincidence of vocabulary.

What Remains Undemonstrated

The mechanisms diverge in a precise and informative way once you look at how each system actually implements that combination. Simulated annealing has an explicit propose-then-evaluate-then-accept-or-reject cycle: a specific candidate state is generated, compared against the current one, and a calculated decision is made about whether to commit to it, with the crucial feature that the algorithm sometimes deliberately, knowingly accepts a worse state specifically to avoid getting stuck, at a rate controlled by a temperature parameter engineered to decrease steadily over the run. E. coli’s chemotaxis has no equivalent of that structure at all. There’s no proposal step and no explicit accept-or-reject decision on a specific alternative state — the bacterium is already committed to whatever direction its current run happens to be pointed, and all it modulates is how long that commitment lasts, based on a simple, monotonic rule: better trending conditions extend the run, worse or flat conditions shorten it. Critically, nothing in the chemotaxis pathway resembles simulated annealing’s signature move: a calculated, temperature-governed decision to deliberately continue toward something that’s currently getting worse, specifically to escape a trap. E. coli’s “exploration” step, the tumble, is simply always available at some baseline rate and always essentially random in direction; there’s no systematically shrinking exploration schedule analogous to simulated annealing’s cooling temperature, because the balance between exploring and committing in a bacterium is fixed by the dynamics of its underlying signal transduction network rather than something deliberately programmed to change over the course of any single foraging trajectory.

Why It Matters

That distinction matters for what each process is actually good at and why. Simulated annealing’s explicit, temperature-controlled willingness to accept worse moves is specifically what lets it escape deep local optima that a purely greedy or purely gradient-following search would get permanently stuck in — a deliberate, engineered feature with no real analog in the bacterium’s simpler rule. E. coli’s strategy, by contrast, doesn’t need to solve that same problem in the same way, because it’s operating continuously in a changing physical environment rather than searching a fixed, static landscape for a single global optimum — it just needs to reliably drift toward better regions over time, not guarantee it will eventually find the single best point anywhere in the space. Recognizing that difference is more useful than blurring the two together, because it clarifies which parts of an “intelligent random search” strategy actually require the harder engineering, deliberately courting worse outcomes on a schedule, and which parts can get by on something much simpler: just swim a little longer when things are looking up.

Human Dimension

There’s something worth appreciating in the fact that a bacterium with no brain at all solved a version of “search intelligently without a map” using a strategy simpler than the one computer scientists eventually built to solve their own version of the same problem — and that the extra complexity computer scientists added, a calculated, cooling willingness to embrace worse outcomes on purpose, turns out to be solving a slightly harder problem than the one E. coli actually faces. Sometimes the more sophisticated-looking algorithm earns its extra machinery. It’s worth checking, each time, whether it actually needs to.

Sources:

1. ScienceDirect — “Responding to chemical gradients: bacterial chemotaxis” — https://www.sciencedirect.com/science/article/abs/pii/S0955067411001542

2. PubMed — “Responding to chemical gradients: bacterial chemotaxis” — https://pubmed.ncbi.nlm.nih.gov/22169400/

3. PMC (National Institutes of Health) — “Optimal Noise Filtering in the Chemotactic Response of Escherichia coli” — https://pmc.ncbi.nlm.nih.gov/articles/PMC1636674/

4. PMC (National Institutes of Health) — “Escherichia coli Remodels the Chemotaxis Pathway for Swarming” — https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6426603/

5. bioRxiv — “Biased re-orientation in the chemotaxis of peritrichous bacteria” — https://www.biorxiv.org/content/10.1101/2020.11.11.379230.full.pdf

6. arXiv — “Persistence of direction increases the drift velocity of run and tumble chemotaxis” — https://arxiv.org/pdf/0706.3589

7. arXiv — “Assessing Quantum and Classical Approaches to Combinatorial Optimization: Testing Quadratic Speed-ups for Heuristic Algorithms” — https://arxiv.org/pdf/2412.13035

8. arXiv — “The Impact of Move Schemes on Simulated Annealing Performance” — https://arxiv.org/pdf/2504.17949

9. arXiv — “Simulated Annealing: Rigorous finite-time guarantees for optimization on continuous domains” — https://arxiv.org/pdf/0709.2989

Idea originated at artificialideas.org. Article researched and written by Claude Sonnet 5. Published at artificialideas.org.