engine.solvers.embodied
engine.solvers.embodied
Embodied solvers: how far a machine travels before it stops, and what the floor allows.
Domain implementations behind mlsysim.solvers (the public import path, derived from engine.solvers.__init__). The equations live in physics.robotics.stopping and physics.drivetrain; these models compose them for one stated situation (added 2026-10-20).
Classes
| Name | Description |
|---|---|
| OnsetTrialModel | One stopping trace scored against a precommitted oracle (added 2026-10-20). |
| RailHoldUpModel | A capacitor-backed rail that must carry the protective response from the |
| ShieldCoverageBillModel | The evidence a shielded hazard-rate claim needs (added 2026-10-20). |
| StoppingBudgetModel | The elementary stopping budget: travel during the pre-brake delay plus braking travel. |
| TakeoverBudgetModel | A request for a person to take over, priced against the finished stopping budget. |
| TractionLossModel | A drop in floor friction against the deceleration a machine’s budget assumes. |
OnsetTrialModel
engine.solvers.embodied.OnsetTrialModel()One stopping trace scored against a precommitted oracle (added 2026-10-20).
The oracle bounds powered-deceleration onset at onset_bound after the reference event and travel to rest at travel_bound (onset-bound travel, the resident stop, and the tracking inset). A trace that begins braking at onset travels speed * onset plus the same resident stop. Each predicate keeps its own signed margin; a combined score needs scales fixed in advance, here the bounds themselves. The trace passes only when both margins are non-negative.
Methods
| Name | Description |
|---|---|
| solve | Score one observed onset against precommitted bounds. |
solve
engine.solvers.embodied.OnsetTrialModel.solve(
onset_bound,
onset,
speed,
resident_stop,
travel_bound,
stop_time,
)Score one observed onset against precommitted bounds.
Parameters
onset_bound : Quantity
Positive permitted onset delay in seconds, fixed before scoring.
onset : Quantity
Observed powered-braking onset in seconds after the reference event.
speed : Quantity
Entry speed in m/s; positive for inverse budgets.
resident_stop : Quantity
Braking travel after onset in meters; nonnegative.
travel_bound : Quantity
Positive allowed total travel in meters, fixed before scoring.
stop_time : Quantity
Braking duration after onset in seconds; nonnegative.
Returns
OnsetTrialResult
Onset/time margins in milliseconds, travel margins in millimeters,
normalized margins, and the conjunction of the two bound checks.
Notes
Equation: travel = speed onset + resident_stop; passes = (onset <= onset_bound) and (travel <= travel_bound).
Assumptions: The observed and reference cases share the resident braking profile; the two bounds are fixed externally.
Excludes: Statistical confidence across trials and any inference of certified safety.
References
Derivation: Each signed margin subtracts the observed quantity from its precommitted bound; normalized margins divide by that same bound.
Examples
>>> from mlsysim.engine.solvers.embodied import OnsetTrialModel
>>> from mlsysim.core.units import ureg
>>> r = OnsetTrialModel().solve(ureg('0.2 s'), ureg('0.1 s'), ureg('1 m/s'), ureg('0.5 m'), ureg('1 m'), ureg('1 s'))
r.passes True
RailHoldUpModel
engine.solvers.embodied.RailHoldUpModel()A capacitor-backed rail that must carry the protective response from the loss-of-feed flag until the holding brakes are set (added 2026-10-20).
t_set = flag_path + (v/a + a/j) + t_engage: the path from the flag to powered-deceleration onset, the S-curve stop from the entry speed v (calc_scurve_stop_time), and the holding brake’s engagement. The margin is the hold-up time less t_set.
Methods
| Name | Description |
|---|---|
| solve | Compare rail hold-up time with the protective stop duration. |
solve
engine.solvers.embodied.RailHoldUpModel.solve(
flag_path,
speed,
deceleration,
jerk,
engage,
holdup,
)Compare rail hold-up time with the protective stop duration.
Parameters
flag_path : Quantity
Loss-of-feed flag to brake-onset latency in seconds.
speed : Quantity
Entry speed in m/s; positive for inverse budgets.
deceleration : Quantity
Available braking magnitude in m/s**2; positive.
jerk : Quantity
Positive acceleration slew limit in m/s**3; None uses constant deceleration.
engage : Quantity
Holding-brake engagement duration in seconds.
holdup : Quantity
Available rail hold-up duration in seconds.
Returns
RailHoldUpResult
Phase durations and remaining hold-up margin in milliseconds;
a negative margin means the stated supply duration is insufficient.
Notes
Equation: t_set = flag_path + t_scurve + engage; margin = holdup - t_set.
Assumptions: Serial flag, stopping, and engagement phases; the supplied jerk and deceleration remain available during hold-up.
Excludes: Rail voltage trajectories, capacitor sizing, and safety certification.
References
Derivation: Serial response durations add; the S-curve stopping helper supplies the powered-stop duration.
Examples
>>> from mlsysim.engine.solvers.embodied import RailHoldUpModel
>>> from mlsysim.core.units import ureg
>>> r = RailHoldUpModel().solve(ureg('0.1 s'), ureg('1 m/s'), ureg('1 m/s**2'), ureg('2 m/s**3'), ureg('0.1 s'), ureg('3 s'))
r.margin.m_as(‘s’) > 0 True
ShieldCoverageBillModel
engine.solvers.embodied.ShieldCoverageBillModel()The evidence a shielded hazard-rate claim needs (added 2026-10-20).
A fleet of fleet_units logs hours_per_day for one release cycle of cycle_days with zero hazardous proposals; the one-sided Poisson bound is -ln(1 - C) / T. The shield passes 1 - coverage of hazardous proposals (calc_shielded_system_hazard_rate), plus the common-cause rate. Against target_rate the model reports the coverage the bound would need, the proposal bound the stated coverage would need, the failure-free exposure and fleet days that bound it (calc_empirical_testing_exposure), and the seeded-hazard campaign that bounds the coverage itself (calc_zero_failure_sample_size), alone and with both bounds held jointly at 1 - alpha/2 each.
Methods
| Name | Description |
|---|---|
| solve | Compute exposure and coverage requirements for a hazard-rate bound. |
solve
engine.solvers.embodied.ShieldCoverageBillModel.solve(
fleet_units,
cycle_days,
hours_per_day,
coverage,
common_cause_rate,
target_rate,
confidence,
)Compute exposure and coverage requirements for a hazard-rate bound.
Parameters
fleet_units : int
Positive number of machines contributing exposure.
cycle_days : Quantity
Release-cycle duration in days; positive.
hours_per_day : Quantity
Logging rate in hours/day; positive.
coverage : float
Hazard rejection fraction in the open interval (0, 1).
common_cause_rate : Quantity
Nonnegative common-cause hazard rate in 1/hour.
target_rate : Quantity
Target hazard rate in 1/hour, above the common-cause rate.
confidence : float
One-sided confidence in (0, 1).
Returns
ShieldCoverageBillResult
Exposure in hours, rate bounds in inverse hours, campaign duration
in days, trial counts, and the comparison with the stated rate target.
Notes
Equation: T = fleet_units cycle_days hours_per_day; lambda_upper = -log(1-confidence)/T; lambda_residual = (1-coverage) lambda_upper + common_cause_rate.
Assumptions: Zero observed hazardous proposals under a stationary Poisson process and representative seeded coverage trials. Joint bounds split the error budget equally.
Excludes: Nonstationary hazards, unmodeled dependence, experimental evidence collection, and safety certification.
References
Derivation: For zero Poisson events, exp(-lambda T) equals the tail probability. Residual proposals multiply by the uncovered fraction; the joint bounds use a union-bound allocation.
Examples
>>> from mlsysim.engine.solvers.embodied import ShieldCoverageBillModel
>>> from mlsysim.core.units import ureg
>>> r = ShieldCoverageBillModel().solve(10, ureg('30 day'), ureg('8 hour/day'), 0.9, ureg('0 / hour'), ureg('0.001 / hour'), 0.95)
r.exposure.m_as(‘hour’) 2400.0
StoppingBudgetModel
engine.solvers.embodied.StoppingBudgetModel()The elementary stopping budget: travel during the pre-brake delay plus braking travel.
d_stop = travel(delay) + v^2 / (2 a) <= D_clear. The delay travel is v * tau at constant speed, or the trapezoid between speed and speed_at_delay_end when two speeds were recorded. Braking travel and braking time are from speed, the speed when the hazard appears, as the elementary budget assumes. The crossover speed 2 a tau is where the two terms are equal; the speed ceiling is the fastest speed whose stop fits clear_distance. A localization bound and a protective margin, when stated, add to the required distance and lower the ceiling (calc_safe_stopping_distance). added_delay prices one more delay step as travel at speed. The delay ceiling is the longest constant-speed pre-brake delay whose stop, with the overhead, still fits (calc_watchdog_lease_bound): (D_clear - overhead - v^2/2a) / v.
The finished budget (added 2026-10-20) takes three optional terms. A jerk bound replaces constant-deceleration braking with the resident S-curve stop (calc_scurve_stop_distance); its extra travel over v^2/2a is the jerk-ramp travel, and above a^2/j it equals v a / (2 j), a delay of a / (2 j). A tracking_bound (the tracking inset) joins the required distance after the two allowances. An approach_speed charges a person who keeps closing the gap for the whole delay and stop (v_h (tau + T_stop)). With a jerk bound the speed ceiling is the S-curve root (calc_scurve_max_permitted_velocity) and the delay ceiling is (D_clear - overhead - inset - d_S(v)) / v. The same case reports the weakest deceleration whose S-curve stop still fits the braking room, jerk fixed, and its shortfall from the stated one (added 2026-10-20).
Methods
| Name | Description |
|---|---|
| solve | Compose delay, braking, and clearance budgets. |
solve
engine.solvers.embodied.StoppingBudgetModel.solve(
speed,
delay,
deceleration,
clear_distance=None,
speed_at_delay_end=None,
loc_margin=None,
physical_margin=None,
added_delay=None,
jerk=None,
tracking_bound=None,
approach_speed=None,
)Compose delay, braking, and clearance budgets.
Parameters
speed : Quantity
Entry speed in m/s; positive for inverse budgets.
delay : Quantity
Pre-braking latency in seconds; nonnegative.
deceleration : Quantity
Available braking magnitude in m/s**2; positive.
clear_distance : Optional[Quantity]
Available clearance in meters; None omits clearance checks.
speed_at_delay_end : Optional[Quantity]
Recorded terminal delay speed in m/s; None uses entry speed.
loc_margin : Optional[Quantity]
Localization allowance in meters; None contributes zero.
physical_margin : Optional[Quantity]
Protective allowance in meters; None contributes zero.
added_delay : Optional[Quantity]
Extra delay to price as travel, in seconds; None omits that output.
jerk : Optional[Quantity]
Positive acceleration slew limit in m/s**3; None uses constant deceleration.
tracking_bound : Optional[Quantity]
Tracking inset in meters; None contributes zero.
approach_speed : Optional[Quantity]
Closing speed of the other body in m/s; None contributes zero.
Returns
StoppingBudgetResult
Distances in meters, times in milliseconds, speed ceilings in m/s,
and signed clearance margins; optional fits compares required clearance.
Notes
Equation: d_required = (v + v_end) tau / 2 + d_brake + margins + v_approach (tau + t_stop).
Assumptions: The constant-deceleration branch brakes from entry speed, even when the delay endpoint differs. Optional jerk selects the S-curve branch.
Excludes: Terrain changes, controller transients outside the stated delay, and safety certification.
References
Derivation: Distances are integrated over the stated delay and braking profile; inverse budgets solve the same distance inequality.
Examples
>>> from mlsysim.engine.solvers.embodied import StoppingBudgetModel
>>> from mlsysim.core.units import ureg
>>> r = StoppingBudgetModel().solve(ureg('1 m/s'), ureg('0.1 s'), ureg('1 m/s**2'))
round(r.stop_distance.m_as(‘m’), 2) 0.6
TakeoverBudgetModel
engine.solvers.embodied.TakeoverBudgetModel()A request for a person to take over, priced against the finished stopping budget.
The takeover T_Sigma (the human response plus the console transport) adds to the machine’s pre-brake delay tau: until the person commits, the machine keeps moving at the request speed. Four finished budgets (StoppingBudgetModel with the S-curve jerk bound and the tracking inset) are solved at that speed: the machine alone, the machine with the dispatch-to-admission allocation Delta_da charged, and each with the takeover waited out before braking. The fallback deadline T_latest is the machine-alone delay spare: the longest wait after the request before the machine’s own stop must begin,
T_latest = (D_clear - delta - d_S(v)) / v - tau.
Configured timeouts are clipped to it, T = max(0, min(T_cfg, T_latest)), and dispatched on the last whole permission tick. Once the operator holds the channel, a manual lease longer than the chunk lease adds its excess to the delay as travel at the request speed (added 2026-10-20).
Methods
| Name | Description |
|---|---|
| solve | Charge takeover latency against the machine stopping reserve. |
solve
engine.solvers.embodied.TakeoverBudgetModel.solve(
speed,
delay,
deceleration,
clear_distance,
takeover,
loc_margin=None,
physical_margin=None,
jerk=None,
tracking_bound=None,
dispatch_to_admission=None,
configured_timeout=None,
tick=None,
manual_lease=None,
chunk_lease=None,
)Charge takeover latency against the machine stopping reserve.
Parameters
speed : Quantity
Entry speed in m/s; positive for inverse budgets.
delay : Quantity
Pre-braking latency in seconds; nonnegative.
deceleration : Quantity
Available braking magnitude in m/s**2; positive.
clear_distance : Quantity
Available clearance in meters; None omits clearance checks.
takeover : Quantity
Human response and transport duration in seconds; nonnegative.
loc_margin : Optional[Quantity]
Localization allowance in meters; None contributes zero.
physical_margin : Optional[Quantity]
Protective allowance in meters; None contributes zero.
jerk : Optional[Quantity]
Positive acceleration slew limit in m/s**3; None uses constant deceleration.
tracking_bound : Optional[Quantity]
Tracking inset in meters; None contributes zero.
dispatch_to_admission : Optional[Quantity]
Additional admission delay in seconds; None contributes zero.
configured_timeout : Optional[Quantity]
Requested timeout in seconds; requires positive tick when supplied.
tick : Optional[Quantity]
Permission tick period in seconds; positive when timeout is supplied.
manual_lease : Optional[Quantity]
Manual command lease in seconds; requires chunk_lease when supplied.
chunk_lease : Optional[Quantity]
Reference command lease in seconds.
Returns
TakeoverBudgetResult
Stopping budgets, travel in millimeters, and deadlines, timeouts, and
time reserves in milliseconds; permission counts are dimensionless.
Notes
Equation: T_latest = (D_clear - overhead - d_brake) / v - tau; timeout = max(0, min(T_configured, T_latest)).
Assumptions: The same speed, braking profile, and margins apply to all four compared budgets. Inputs must leave an available delay_spare on the underlying stopping result.
Excludes: Human-response distributions, changing approach speed, and safety certification.
References
Derivation: Subtract the common stopping budget from clearance and convert remaining travel into waiting time at entry speed.
Examples
>>> from mlsysim.engine.solvers.embodied import TakeoverBudgetModel
>>> from mlsysim.core.units import ureg
>>> r = TakeoverBudgetModel().solve(ureg('1 m/s'), ureg('0.1 s'), ureg('1 m/s**2'), ureg('2 m'), ureg('0.2 s'))
round(r.takeover_travel.m_as(‘m’), 2) 0.2
TractionLossModel
engine.solvers.embodied.TractionLossModel()A drop in floor friction against the deceleration a machine’s budget assumes.
At the traction limit the deceleration is mu g phi, so braking distance v^2 / (2 mu g phi) scales as 1 / mu and the ratio of the two braking distances is mu_before / mu_after. The stated deceleration holds only while the lower friction still supplies it (calc_required_friction).
Methods
| Name | Description |
|---|---|
| solve | Compare a friction change with required deceleration. |
solve
engine.solvers.embodied.TractionLossModel.solve(
mu_before,
mu_after,
deceleration,
drive_load_share=1.0,
)Compare a friction change with required deceleration.
Parameters
mu_before : float
Positive dimensionless friction coefficient before the change.
mu_after : float
Positive dimensionless friction coefficient after the change.
deceleration : Quantity
Available braking magnitude in m/s**2; positive.
drive_load_share : float
Fraction of normal load on driven wheels, in (0, 1].
Returns
TractionLossResult
Dimensionless braking-distance ratio and required friction, acceleration
ceiling in m/s**2, and a friction-premise comparison.
Notes
Equation: d_after / d_before = mu_before / mu_after; a_max = mu_after g drive_load_share.
Assumptions: Coulomb friction and unchanged speed and load distribution.
Excludes: Slip dynamics, slope, tire deformation, and safety certification.
References
Derivation: The constant-deceleration distance ``v**2/(2`` a) is inversely proportional to friction-limited acceleration.
Examples
>>> from mlsysim.engine.solvers.embodied import TractionLossModel
>>> from mlsysim.core.units import ureg
>>> r = TractionLossModel().solve(0.8, 0.4, ureg('1 m/s**2'))
r.braking_distance_ratio 2.0