Docs/Build/Integration patterns
CLIENT 0.4.3PYTHON 3.8+

Integration patterns

One measurement contract for regulation and compatible optimization.

Always use regulation mode with an explicit vector target. For regulation, the target is the operating setpoint. For compatible optimization, the target is the desired response and the objective is the squared response error.

A current complete response produces the next complete configuration. Keep one session open across consecutive updates.

The contract is substrate-independent but not structure-blind. Timing, bounds, readout quality, target feasibility, drift, and coupling determine whether the application fits.

PYTHON
opt = SWCOptimizer(key, n=len(x0), mode="regulation", target=target)
x = opt.start(x0)
for _ in range(rounds):
    x = opt.step(measure(x), target=target)
opt.end()

Optimization uses the same contract

When J(x) is the mean squared difference between the measured response and a desired response, driving that vector difference to zero minimizes J(x). No scalar-score mode is required.

Keep a session open across consecutive rounds. Recreating it every round starts a new control job.

Production checklist

Validate that every configuration, measurement, and target has length n; reject NaN and infinity before the network call; apply actuator bounds after every returned update; and log acquisition count separately from raw shots.

Verify same-cycle acquisition before go-live: every reading must reflect the configuration applied in that cycle. Survey dominant disturbance periods and raise the loop rate if a chiller, fan, or beat note falls near the loop response time.

Pair the runtime with a coarse stage when the operating point can leave the available control span. Wrap periodic controls such as phase.

Use a try/finally block or the context manager so end() always runs. If one HTTPS hop dominates the loop, move the same API contract to an on-premises deployment.

Need the answer on your plant?

Run the envelope, then race the runtime and your incumbent under the same measured budget.

Start evaluation