
Program runs
one or more optimizers and collects the final results.
This guide describes the optimizer interface, the built-in optimizers and what each is suited
to, how to run one, and how to chain several into a multi-stage program. Custom optimizers are
out of scope; the built-in set covers the common search strategies.
Open as a runnable notebook
View as a Python script
The loop
Every optimizer is constructed the same way: it is given theconstructs it designs, the
generators that propose sequences, the constraints that score them, and a config that sets
the search parameters. The optimizer then repeats a propose-score-select loop.
The generators and constraints are the same objects described in
Using Generators and
Using Constraints; the optimizer coordinates them. What
differs between optimizers is the strategy by which proposals are generated and selected, and
the parameters that govern it.
The built-in optimizers
MCMC
Metropolis-Hastings sampling: each proposal is accepted or rejected against a temperature
schedule. A general-purpose local search.
Rejection Sampling
Draw a batch of candidates and keep those below an energy threshold. Useful for filtering
and for a first enrichment stage.
Beam Search
Maintain a beam of partial sequences, extending and pruning them. Suited to autoregressive
generation.
Cycling
Alternate between two providers, such as structure prediction and inverse folding. The
Protein Hunter pattern.
Gradient
Differentiable optimization of position weights by gradient descent, following a
soft-to-hard schedule.
Running an optimizer
The example below balances the composition of a 100 bp DNA insert with theMCMCOptimizer. The
optimizer’s config sets the search budget: num_steps is the number of propose-score-select
iterations, proposals_per_result is how many candidates are evaluated per step, and the
temperature controls how readily worse proposals are accepted (higher is more exploratory).
python
Chaining optimizers into stages
AProgram may run several optimizers in sequence. When the stages share the same Segment
and Construct objects, the result sequences of one stage become the starting point of the
next, so the design is refined incrementally rather than rebuilt. This is how a coarse, broad
search is followed by a fine, narrow one.
The two stages below operate on a single 20 bp insert: rejection sampling first enriches it
toward a wide 70-100% GC window, then MCMC refines it into a tight 80-90% window.
python
The model-backed optimizers
Two optimizers coordinate machine-learning tools rather than composition constraints, and so require a GPU. TheCyclingOptimizer alternates between two providers; in the Protein Hunter
program it cycles between structure prediction and inverse folding, each round refining the
sequence toward a target fold. The GradientOptimizer pairs with PositionWeightGenerator to
optimize a differentiable sequence by gradient descent, following a soft-to-hard schedule that
sharpens a continuous sequence into a discrete one. Complete, runnable versions of both appear
in the Example Programs.
Practical considerations
Multi-stage programs share state through object identity: the later optimizers must be given the
same
Segment and Construct instances as the earlier ones for the design to carry over.
Constructing fresh segments for a later stage starts it from scratch instead.Next Steps
Using Constraints
Define the objective the optimizer minimizes.
Using Generators
Choose the moves the optimizer proposes.
Optimizers concept
How optimizers relate to the rest of the model.
Optimizer reference
The full catalog of built-in optimizers.