Skip to main content

engine.solvers.mapping

engine.solvers.mapping

Volumetric-map solvers: clearance-query reads, map storage, update traffic, and encoder rate (added 2026-10-20).

Domain implementations behind mlsysim.solvers. The equations live in physics/robotics/perception.py; these models compose them for one stated permission controller, workcell, depth stream, or encoder.

Classes

Name Description
ClearanceQueryModel Reads a sphere-hull clearance query needs per map representation, against the permission tick’s read budget.
EncoderRateModel A per-frame encoder of flop_per_frame run at frame_rate, against a peak rate.
HostMapSizingModel A dense voxel grid of a workcell against a hashed narrow band around its surfaces.
RaymarchTrafficModel Naive ray-marching map-update traffic f N_rays (d / r) S against a memory bandwidth.

ClearanceQueryModel

engine.solvers.mapping.ClearanceQueryModel()

Reads a sphere-hull clearance query needs per map representation, against the permission tick’s read budget.

The collision allocation divided among the hulls gives the time per query; SRAM bandwidth over that time, in cells, is the read budget. An occupancy scan reads calc_sphere_scan_cells cells; an octree pays calc_octree_depth dependent reads for each; an ESDF reads the corners of one trilinear interpolation. A snapshot of slab_volume stores V / r^3 cells, and a cell’s center misplaces a point by up to calc_voxel_quantization_error.

Methods

Name Description
solve Compare map-query reads and storage at each voxel pitch.
solve
engine.solvers.mapping.ClearanceQueryModel.solve(
    tick_rate,
    collision_allocation,
    hulls,
    hull_radius,
    protective_clearance,
    sram_bandwidth,
    esdf_cell_bytes,
    occupancy_cell_bytes,
    map_edge,
    slab_volume,
    pitches,
    trilinear_reads,
    wcet=None,
)

Compare map-query reads and storage at each voxel pitch.

Parameters
Name Type Description Default
tick_rate Quantity Positive permission-controller frequency, in Hz. required
collision_allocation Quantity Time assigned to all collision queries per tick, in seconds. required
hulls int Positive number of spherical hull queries sharing the allocation. required
hull_radius Quantity Nonnegative radius of each collision hull, in meters. required
protective_clearance Quantity Nonnegative extra clearance around each hull, in meters. required
sram_bandwidth Quantity Positive sustained SRAM read bandwidth, in bytes per second. required
esdf_cell_bytes Quantity Positive storage per signed-distance cell, in bytes. required
occupancy_cell_bytes Quantity Positive storage per occupancy cell, in bytes. required
map_edge Quantity Positive map side length used to estimate octree depth, in meters. required
slab_volume Quantity Positive snapshot volume whose storage is counted, in cubic meters. required
pitches sequence of Quantity Positive voxel widths in meters. Result rows are keyed by rounded centimeters, so pitches must have distinct keys to retain every row. required
trilinear_reads int Nonnegative number of corner-cell reads for one ESDF interpolation. required
wcet Quantity Positive reference worst-case execution time, in seconds. If supplied, report allocation divided by this value; no WCET is inferred. None
Returns
Name Type Description
ClearanceQueryResult Tick and per-query times in microseconds, read budgets as counts, and pitch-indexed storage in kilobytes and spatial error in meters. Budget ratios describe this accounting model, not collision safety.
See Also

mlsysim.physics.robotics.perception.calc_sphere_scan_cells : Sphere-grid scan count. mlsysim.physics.robotics.perception.calc_octree_depth : Dependent octree levels. mlsysim.physics.robotics.perception.calc_voxel_quantization_error : Cell-center spatial error.

Notes

Equation: t_query = collision_allocation / hulls; reads_budget = t_query * sram_bandwidth / esdf_cell_bytes. The read budget counts esdf_cell_bytes-wide SRAM transactions (e.g., 800 8-byte bus transactions / 6.4 kB raw ceiling on a 400 MHz controller), so smaller occupancy_cell_bytes records still consume one transaction cycle per independent lookup. Dense storage counts slab_volume / pitch**3 cells; octree reads multiply sphere-scan cells by tree depth, while the ESDF reads trilinear_reads corners. Assumptions: one equal time allocation per hull, uniform cubic voxels, fully sustained SRAM bandwidth, and a fixed interpolation read count. Excludes: cache reuse, dependency stalls, tree traversal instructions, scene reconstruction error, and certification of a collision checker.

References

Derivation: divide time and byte budgets by per-query and per-cell costs; the spatial counts and quantization bound are supplied by the linked sphere-scan, octree-depth, and voxel-quantization functions.

Examples

A constructed controller gives each of two hulls half its collision budget.

>>> from mlsysim import Q_
>>> result = ClearanceQueryModel().solve(
...     Q_(100, 'Hz'), Q_(2, 'ms'), 2, Q_(0.1, 'm'), Q_(0.05, 'm'),
...     Q_(1, 'GB/s'), Q_(4, 'byte'), Q_(1, 'byte'), Q_(1, 'm'),
...     Q_(1, 'm^3'), [Q_(0.1, 'm')], 8)
>>> result.query_time == Q_(1, 'ms')
True

EncoderRateModel

engine.solvers.mapping.EncoderRateModel()

A per-frame encoder of flop_per_frame run at frame_rate, against a peak rate.

Methods

Name Description
solve Compare frame-encoder work demand with an available compute rate.
solve
engine.solvers.mapping.EncoderRateModel.solve(flop_per_frame, frame_rate, peak)

Compare frame-encoder work demand with an available compute rate.

Parameters
Name Type Description Default
flop_per_frame Quantity Nonnegative arithmetic work for one frame, in FLOPs. required
frame_rate Quantity Nonnegative frame arrival rate, in Hz. required
peak Quantity Positive compute capacity, in FLOPs per second. Supply an effective rate instead if utilization losses should already be included. required
Returns
Name Type Description
EncoderRateResult Required and supplied rates in the units of peak, and their ratio. The field shortfall is demand/capacity, not a percentage or latency.
Notes

Equation: required = flop_per_frame * frame_rate; shortfall = required / peak. Assumptions: every frame executes the same work, and throughput can be compared with the supplied compute rate. Excludes: memory traffic, queueing, launch overhead, and deadline guarantees.

References

Derivation: work per frame multiplied by frames per second is work per second; division by supply gives dimensionless capacity demand.

Examples

A constructed stream whose demand equals supply has unit demand ratio.

>>> from mlsysim import Q_
>>> result = EncoderRateModel().solve(Q_(10, 'flop'), Q_(2, 'Hz'), Q_(20, 'flop/s'))
>>> result.shortfall == 1
True

HostMapSizingModel

engine.solvers.mapping.HostMapSizingModel()

A dense voxel grid of a workcell against a hashed narrow band around its surfaces.

Dense storage is V / r^3 voxels; the band of half-width delta around surface area A has volume 2 delta A and fills V_band / (B r)^3 blocks of B^3 voxels each.

Methods

Name Description
solve Count dense-grid storage and ideal narrow-band block storage.
solve
engine.solvers.mapping.HostMapSizingModel.solve(
    extent,
    pitch,
    voxel_bytes,
    surface_area,
    band_half_width,
    block_edge,
)

Count dense-grid storage and ideal narrow-band block storage.

Parameters
Name Type Description Default
extent sequence of Quantity Three positive workspace side lengths, in meters. required
pitch Quantity Positive cubic voxel width, in meters. required
voxel_bytes Quantity Positive bytes stored per voxel, excluding hash-table metadata. required
surface_area Quantity Positive mapped surface area, in square meters. required
band_half_width Quantity Positive distance stored on each side of the surface, in meters. required
block_edge int Positive voxels per side of each cubic block. required
Returns
Name Type Description
HostMapSizingResult Workspace and band volumes in cubic meters, ideal cell/block counts, dense storage in GB, band storage in MB, and dimensionless ratios. Fractional block counts are retained; memory admission is not checked.
Notes

Equation: V = extent[0] * extent[1] * extent[2]; N_dense = V / pitch**3; V_band = 2 * band_half_width * surface_area. N_blocks = V_band / (block_edge * pitch)**3 and each block stores block_edge**3 * voxel_bytes. Assumptions: flat locally independent surface bands, identical voxel payloads, and continuously divisible block occupancy. Excludes: band overlap, workspace clipping, partial-block rounding, hash keys, allocator overhead, and GPU residency constraints.

References

Derivation: volume divided by cubic-cell volume gives cell count; multiplying a surface area by its two-sided band thickness gives the narrow-band volume used in this geometric approximation.

Examples

A constructed cubic workspace exposes the volume accounting directly.

>>> from mlsysim import Q_
>>> result = HostMapSizingModel().solve(
...     [Q_(1, 'm')] * 3, Q_(0.1, 'm'), Q_(4, 'byte'),
...     Q_(1, 'm^2'), Q_(0.05, 'm'), 4)
>>> result.workspace_volume == Q_(1, 'm^3')
True

RaymarchTrafficModel

engine.solvers.mapping.RaymarchTrafficModel()

Naive ray-marching map-update traffic f N_rays (d / r) S against a memory bandwidth.

Methods

Name Description
solve Estimate uncached voxel-update traffic for a depth-image stream.
solve
engine.solvers.mapping.RaymarchTrafficModel.solve(
    width_px,
    height_px,
    frame_rate,
    ray_length,
    pitch,
    bytes_per_step,
    bandwidth,
)

Estimate uncached voxel-update traffic for a depth-image stream.

Parameters
Name Type Description Default
width_px int Positive image width, in pixels. required
height_px int Positive image height, in pixels. required
frame_rate Quantity Positive depth-frame rate, in Hz. required
ray_length Quantity Nonnegative traversed distance per ray, in meters. required
pitch Quantity Positive distance between ray samples, in meters. required
bytes_per_step Quantity Nonnegative bytes transferred per ray sample, in bytes. required
bandwidth Quantity Positive available memory bandwidth, in bytes per second. required
Returns
Name Type Description
RaymarchTrafficResult Ray count per frame, steps per ray, traffic in GB/s, and traffic divided by available bandwidth. A share above one identifies a bandwidth deficit under the stated access model.
Notes

Equation: rays = width_px * height_px; steps = ray_length / pitch; traffic = frame_rate * rays * steps * bytes_per_step. Assumptions: every pixel emits one equal-length ray and every step causes the supplied byte transfer. Fractional step counts are retained. Excludes: repeated-voxel reuse, culling, empty-space skipping, compression, contention with other clients, and integer step rounding.

References

Derivation: multiply frames per second, rays per frame, steps per ray, and bytes per step; the units reduce to bytes per second.

Examples

Doubling the constructed frame rate doubles the traffic.

>>> from mlsysim import Q_
>>> model = RaymarchTrafficModel()
>>> args = (2, 2, Q_(1, 'Hz'), Q_(1, 'm'), Q_(0.1, 'm'),
...         Q_(4, 'byte'), Q_(1, 'GB/s'))
>>> first = model.solve(*args)
>>> second = model.solve(*args[:2], args[2] * 2, *args[3:])
>>> second.traffic == first.traffic * 2
True
Back to top