batch
batch
#
Protocol and utilities for batch (vectorized) distance computation.
Provides a protocol and utilities for batch (vectorized) distance computation. This enables O(n²) pairwise distance matrices to be computed efficiently using NumPy broadcasting instead of Python loops.
Each distance function can optionally provide batch capabilities via the BatchDistanceFunction protocol.
BatchedDistanceFunction
#
Bases: ABC
Protocol for distance functions that support batch computation.
Source code in capturegraph-lib/capturegraph/scheduling/distance/batch.py
__call__(a, b)
abstractmethod
#
extract(sessions)
abstractmethod
#
matrix(vals_a, vals_b=None)
#
Compute pairwise distance matrix.
Source code in capturegraph-lib/capturegraph/scheduling/distance/batch.py
pairwise(features_a, features_b)
abstractmethod
#
Compute pairwise distances from pre-extracted features.
prepared(candidates)
#
Extract candidates features once for repeated column queries.
PreparedDistance
#
Bases: ABC
A distance function bound to a fixed candidate set, extracted once.
Void & Cluster reads candidate-to-candidate distances one column at a time,
always against the same candidate set. Extracting that set's features
once turns each column into a single vectorized pairwise call instead
of re-walking every session object — the per-column cost that dominates the
sampler on large grids. Obtain one with [prepare][].
Source code in capturegraph-lib/capturegraph/scheduling/distance/batch.py
SupportsMatrix
#
Bases: Protocol
A distance function that can compute a full pairwise matrix in one call.
Structural, not nominal: both [BatchedDistanceFunction][] and the
composite CombinedBatchDistance provide matrix without sharing a base.
Source code in capturegraph-lib/capturegraph/scheduling/distance/batch.py
matrix(vals_a, vals_b=None)
#
Compute the full pairwise distance matrix between two value sets.
batch_matrix(fn, vals_a, vals_b=None)
#
Call a batchable distance function.
Source code in capturegraph-lib/capturegraph/scheduling/distance/batch.py
prepare(fn, candidates)
#
Bind fn to candidates for repeated column queries.
Distances that can extract features (a [BatchedDistanceFunction][], or
a combined metric) pre-extract the candidate set once; anything else
falls back to a per-column batch_matrix.