Rounding strategy for slot duration at JSON export
The AKSlot
objects stores the duration of an AK in hours as a float. The solver instead requires an integer of the number of discrete slots the AK spans.
For this conversion, we multiply the duration in hours by the float factor slots_in_an_hour
.
The resulting float must then be converted to an integral amount of slots. The current implementation assumes that the Slot duration are a priori aligned with the grid so that all deviations from integers are the result of floating point erros. Hence, it simply uses round
for the conversion.
We want to also support the scheduling of AKs that do not align with the discrete grid. The strategy we agreed on in the meeting is to always "round up". However, if an AK were to align with the grid, simply using ceil
might lead to slot counts that are 1 to large.
I would instead propose to use ceil((duration * slots_in_an_hour) - eps)
with eps chosen such that
- it is larger than all floating point errs
- but also smaller than all reasonable deviations from the optimizer grid.
eps=1e-4
should work.