CBD.lib.endpoints module

class CBD.lib.endpoints.CollectorBlock(block_name, input_ports, data=None)[source]

Bases: CBD.Core.BaseBlock

Abstract class, representing a basic collection unit. In the data attribute, a set of values is stored for external access (possibly during the simulation). This should allow for live plots w.r.t. an independent plotting framework.

Parameters
  • block_name (str) – The name of the block.

  • input_ports (list) – The inputs for the collector.

  • data (Any) – The data that is being tracked.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

clear()[source]

Clears the contents of the block. Must be called in-between simulations if the obtainable statistics do not need to interfere/retain information about previous simulations.

property data

Property to obtain the internal data.

class CBD.lib.endpoints.SignalCollectorBlock(block_name, buffer_size=- 1)[source]

Bases: CBD.lib.endpoints.CollectorBlock

Collects a single signal to store w.r.t. the arrival time.

Parameters
  • block_name (str) – The name of the block.

  • buffer_size (int) – The maximal amount of values to keep track of. When negative, no buffering will happen. Defaults to -1.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

clear()[source]

Clears the contents of the block. Must be called in-between simulations if the obtainable statistics do not need to interfere/retain information about previous simulations.

property data_xy

The collected data, as a pair of lists; i.e. the unzipped form of xs, ys.

class CBD.lib.endpoints.PositionCollectorBlock(block_name, buffer_size=- 1)[source]

Bases: CBD.lib.endpoints.CollectorBlock

Collects a X/Y position, to be used for a parametric plot.

Parameters
  • block_name (str) – The name of the block.

  • buffer_size (int) – The maximal amount of values to keep track of. When negative, no buffering will happen. Defaults to -1.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

clear()[source]

Clears the contents of the block. Must be called in-between simulations if the obtainable statistics do not need to interfere/retain information about previous simulations.

distance_from_last(x1, y1)[source]

Computes the distance between the last point and the given point.

Parameters
  • x1 (numeric) – The x position of the given point.

  • y1 (numeric) – The y position of the given point.

distance_from_start()[source]

Obtains the distance from the starting position (in the buffer).

property data_xy

The collected data, as a pair of lists; i.e. the unzipped form of xs, ys.

class CBD.lib.endpoints.StatisticsCollectorBlock(name)[source]

Bases: CBD.lib.endpoints.CollectorBlock

Collects all inputs and allows for statistical data summaries.

While this can be done on the SignalCollectorBlock, this class uses a less memory-intensive algorithm to do so. When only statistical info is required and a lot of data needs to be analyzed, this algorithm should be used!

Note

This block only works for NUMERICAL data.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

clear()[source]

Resets the values of the statistics. Should be called when the model is used in multiple simulations back-to-back to make sure the statistics remain valid.

count()[source]

Returns the amount of items that have been captured.

min()[source]

Returns the smallest value that was seen.

max()[source]

Returns the largest value that was seen.

sum()[source]

Returns the sum of all items that have been captured.

sumOfSquares()[source]

Returns the sum of the squares for all items that have been captured.

mean()[source]

Returns the average/mean value of the data.

variance()[source]

Returns the variance of the data.

std()[source]

Returns the standard deviation value of the data.