Dynamical System Framework
Loading...
Searching...
No Matches
dsf::FlowAccumulator Class Reference

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.

Detailed Description

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.

Member Function Documentation

◆ canPass()

bool dsf::FlowAccumulator::canPass ( ) const
inlinenoexcept

Check whether an agent can pass through.

Returns
bool True if the accumulated value is positive

◆ refill()

void dsf::FlowAccumulator::refill ( double const capacity,
std::time_t const timeStep )
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.

Parameters
capacityThe number of agents per time step allowed through, positive. If it changed since the previous refill, it applies to the whole interval.
timeStepThe current time step

◆ value()

double dsf::FlowAccumulator::value ( ) const
inlinenoexcept

Get the accumulated value.

Returns
double The accumulated value, at most the last refilled capacity

The documentation for this class was generated from the following file: