Docs

Tips & tricks

Small choices that move results. Most are about feeding the loop well and staying inside the envelope.

Start from a good x0

A sensible initial configuration shortens warm-up. If you have a known-decent setting, start there.

Exploit related-task streams

If you solve a sequence of similar problems, keep one session open and feed each solution forward instead of cold-starting. Retained-state warm-starting on related instances is the runtime’s strongest regime:

copyfrom swc import SWCOptimizer

opt = SWCOptimizer(license_key="EVAL-...", n=N)
phi = opt.start(initial_config)
for problem in related_stream():        # similar problems over time
    for _ in range(rounds_each):
        phi = opt.step(measure(phi), score=-cost(phi, problem))
    record(phi)                         # no reset: state carries forward
opt.end()

Tune measurements-per-round

More shots per round gives a cleaner statistic but fewer rounds at a fixed budget; fewer shots gives noisier reads but more steps. Sweep this once on a small instance to find your sweet spot:

copyfor shots in (1, 2, 4, 8, 16):
    with SWCOptimizer(license_key="EVAL-...", n=N) as opt:
        phi = opt.start([1.5708] * N)
        for _ in range(budget // shots):     # equal total reads
            stat = average_reads(phi, shots)  # mean of `shots` measurements
            phi  = opt.step(stat, score=objective(phi))
    print(shots, evaluate(phi))

Give it a meaningful score

In optimization mode the score is the steering signal — make it your real objective, not a proxy that plateaus. In tracking problems, switch to regulation mode and pass a target instead.

Keep the loop running under drift

Don’t restart when the target moves — retained state is the mechanism for tracking. One session, many steps, beats repeated cold re-optimization.

Sign and polarity are handled for you

You never need to configure or calibrate the drive direction. In regulation mode the runtime measures each channel’s sensitivity at the start of the session, so reversed-polarity, negative-gain, and sign-varying plants all work unchanged. The only requirement is local monotonicity — see compatibility.

Coupled plants stay in the envelope longer than you might expect

The per-channel residual drive absorbs mild channel coupling; validated plants include neighbour crosstalk. Tracking holds well through moderate normalized cross-channel coupling and then degrades smoothly; a strongly coupled, non-separable plant will eventually DECLINE, just as a separable controller would need the model.

Minimize round-trips

Open one session with start() and reuse it across all step() calls; don’t recreate the optimizer each round. Where your loop allows, batch measurements before stepping.

Check the envelope before a pilot

Run check_envelope() first so you don’t spend a budget proving a tie. A DECLINE up front saves you a wasted run.

Handle the network gracefully

Transient failures are auto-retried; still, wrap long runs and catch SWCNetworkError so a blip doesn’t lose a long session.

Validate small, then scale

Get the integration green on a small n and few rounds first; then scale up — and remember the advantage grows with scale (see bigger problems).

Reproducibility

Fix your own measurement seed so your runs are comparable; your inputs, scores, and results are yours.