|
Dynamical System Framework
|
A deterministic flow gate. More...
#include <FlowAccumulator.hpp>
Public Member Functions | |
| void | refill (double const capacity, std::time_t const timeStep) noexcept |
| Bring the accumulator up to date with a time step. | |
| void | consume () noexcept |
| Consume one unit, as an agent passes through. | |
| bool | canPass () const noexcept |
| Check whether an agent can pass through. | |
| double | value () const noexcept |
| Get the accumulated value. | |
A deterministic flow gate.
Each time step adds the capacity (agents per time step) without exceeding it, and each agent passing through consume()s one unit, so that the value can become negative. Agents may pass while canPass(). Hence an idle gate lets a lone agent pass at once, while a platoon is released at exactly capacity agents per time step, at most ceil(capacity) in a single step. The gate is refilled lazily: refill() catches up on all the time steps since the previous call, so it only needs calling when an agent tries to pass.
|
inlinenoexcept |
Check whether an agent can pass through.
|
inlinenoexcept |
Bring the accumulator up to date with a time step.
Adds the capacity once per time step since the previous refill, without exceeding it: refilling once after k idle time steps is the same as refilling at each of them. The first refill fills the gate, a second one in the same time step has no effect.
| capacity | The number of agents per time step allowed through, positive. If it changed since the previous refill, it applies to the whole interval. |
| timeStep | The current time step |
|
inlinenoexcept |
Get the accumulated value.