pylabrobot.lib.liquid_handling.pipette_batch_scheduling#

Plan the fewest X/Y moves that position each channel at its target.

Multi-channel heads share one X carriage, enforce minimum pairwise Y spacing, strictly descending Y by channel index, and per-container geometry (including no-go zones). Given a list of (channel, target container) assignments, this module groups them into batches where each batch is a set of channels whose targets can all be reached in one X/Y move. A Z-axis operation (e.g. LLD probe, aspirate, dispense, …) is then supplied as a callback by the caller.

This is formally a Minimum Exact Cover problem (equivalently, Set Partitioning in OR terminology, or minimum hypergraph coloring in graph theory): pairwise constraints alone reduce to graph coloring; container fit with no-go zones is k-ary, making it hypergraph coloring. Hence the enumerate-then-partition pipeline rather than 2-ary graph coloring. Intended for n <= ~16 channels; planning is O(2^n * n^2) in the worst case, with the branch-and- bound partition solver typically fast on the structured instances this module sees.

Example:

batches = plan_batches(
  use_channels=[0, 1, 2, 5, 6, 7],
  containers=[w0, w1, w2, w5, w6, w7],
  channel_spacings=backend._channels_minimum_y_spacing,
  wrt_resource=backend.deck,
  x_tolerance=0.1,
)
await backend.execute_batched(func=my_z_callback, batches=batches)

Functions

enumerate_valid_batches(use_channels, ...[, ...])

Enumerate every valid batch by backtracking, returning ChannelBatch objects.

is_valid_batch(job_indices, use_channels, ...)

Validate a candidate batch against all physical constraints, cheapest first.

log_batches(batches[, use_channels, containers])

Log a tree view of the batch execution plan.

minimum_exact_cover(n_jobs, batches)

Pick the fewest batches that partition {0..n_jobs-1} (branch-and-bound).

plan_batches(use_channels, containers, ...)

Container-aware, optimal batch planning (respects no-go zones).

validate_channel_selections(containers, ...)

Validate and normalize channel selection.

Classes

ChannelBatch(x_position, indices, channels, ...)

A group of channels that can operate simultaneously.