# pypdevsbbl.generic.generators module

A set of building blocks that can be used for generating data.

When using the classes in this file, you can start creating simple (and complex) flow systems or, generally, anything that requires input.

class `pypdevsbbl.generic.generators.``ConstantGenerator`(name: str, value=0, dt=1)

  Bases: `pypdevs.DEVS.AtomicDEVS`

  AtomicDEVS that generates a constant value every dt time.

  Parameters:

  - name (str) – The name of the generator.
  - value (any) – The item to be generated. Defaults to 0.
  - dt (numeric) – Time delay between the generation of new events. Defaults to 1.

  State:

  - value (any) – The item to generate.
  - dt (numeric) – Time delay between the generation of new events. Cannot be negative or zero.
  - elapsed (numeric) – The elapsed time since last internal transition.

  Input Ports:

  - value (any) – A new value to output.
  - dt (numeric) – A new time delay. Cannot be negative or zero.

  Output Ports: | output (any) – Outputs the generated value.

  `intTransition`()
  `extTransition`(inputs)
  `timeAdvance`()
  `outputFnc`()

class `pypdevsbbl.generic.generators.``FunctionGenerator`(name: str, function=<function FunctionGenerator.<lambda>>, ic=0, dt=1)

  Bases: `pypdevs.DEVS.AtomicDEVS`

  AtomicDEVS that generates a new value based on the previous one and the elapsed time.

  Note

  By default, he first output `ic` (initial condition) will be outputted at time 0.

  Parameters:

  - name (str) – The name of the generator.
  - function (def) – A function that takes the previous value and the elapsed time as arguments and returns a new item from those. Defaults to an incrementor of the ic.
  - ic (any) – The initial condition of the generator. Defaults to 0.
  - dt (numeric) – Time delay between the generation of new events. Defaults to 1.

  State:

  - next (any) – The next item that will be generated.
  - time (numeric) – The amount of time that has elapsed.
  - dt (numeric) – Time delay between the generation of new events. Cannot be negative or zero. Defaults to 1.
  - elapsed (numeric) – The elapsed time since last internal transition.

  Input Ports: | dt (numeric) – A new time delay. Cannot be negative or zero.
  Output Ports: | output (any) – Outputs the generated value.

  `timeAdvance`()
  `extTransition`(inputs)
  `intTransition`()
  `outputFnc`()

class `pypdevsbbl.generic.generators.``TableGenerator`(name: str, table, repeat: bool = False)

  Bases: `pypdevs.DEVS.AtomicDEVS`

  AtomicDEVS that generates a new value based on the table.

  Parameters:

  - name (str) – The name of the generator.
  - table (iter) – An iterable containing (time, value) tuples/pairs. Defaults to empty list.
  - repeat (bool) – When `True`, the table will be repeated when it is finished. Defaults to `False`

  State:

  - time (numeric) – The amount of time until the next transition.
  - index (int) – The index in the table at this point.

  Output Ports: | output (any) – Outputs the generated value.

  `timeAdvance`()
  `intTransition`()
  `outputFnc`()

class `pypdevsbbl.generic.generators.``SingleFire`(name: str, item, t=0.0)

  Bases: `pypdevs.DEVS.AtomicDEVS`

  Output an item once.

  Useful to prevent the overhead of a `TableGenerator` with a single record.

  Parameters:

  - name (str) – The name of the block.
  - item (any) – The item that needs to be outputted. Cannot be `None`.
  - t (numeric) – Absolute simulation time when to fire the event.

  State:

  - item (any) – The item to fire.
  - t (numeric) – The absolute time until the event or `INFINITY` if the event has already passed.

  Output Ports: | output (any) – The item.

  `timeAdvance`()
  `intTransition`()
  `outputFnc`()

class `pypdevsbbl.generic.generators.``BulkGenerator`(name: str, dt=0.0)

  Bases: `pypdevs.DEVS.AtomicDEVS`

  Creates \(n\) messages every time it receives \(n\).

  Parameters:

  - name (str) – The name of the block.
  - dt (numeric) – The time delay between the messages. Cannot be negative. Defaults to 0.

  State:

  - index (int) – The index of the last item that was outputted.
  - items (list) – The items to generate.
  - dt (numeric) – Time delay between the generation of new events. Cannot be negative or zero.
  - elapsed (numeric) – The elapsed time since last internal transition.

  Input Ports:

  - input (int) – A amount of items to output in bulk. When there are still items remaining, the provided values are appended to the list.
  - dt (numeric) – A new time delay. Cannot be negative.

  Output Ports: | output (numeric) – Outputs the generated values.

  `intTransition`()
  `extTransition`(inputs)
  `timeAdvance`()
  `outputFnc`()

class `pypdevsbbl.generic.generators.``RandomNumberGenerator`(name: str, seed=None, dist=<function RandomNumberGenerator.<lambda>>, args=(), dt=1)

  Bases: `pypdevs.DEVS.AtomicDEVS`

  `AtomicDEVS` that generates a random number every dt time.

  It makes use of the RngStreams random number generator i.i.d. (0, 1). Using the `dist` argument, one can simply change the distribution over which numbers need to be generated. The `pypdevsbbl.extra.rngstreams.distributions` module provides an extensive implementation of a lot of distributions.

  See also

  - `pypdevsbbl.generic.math.Random`
  - `RandomDelayGenerator`
  - `pypdevsbbl.extra.rngstreams`
  - `pypdevsbbl.extra.rngstreams.distributions`

  Parameters:

  - name (str) – The name of the generator (both the block and the engine).
  - seed (numeric) – The seed for the generator. When `None`, it will not set a seed. Defaults to `None`.
  - dist (def) – A stateless function that implements an inversive cumulative distribution function. It takes at least a single argument, which falls in (0, 1). Defaults to a uniform distribution over (0, 1).
  - args (tuple) – Optional additional arguments to add to the distribution.
  - dt (numeric) – Time delay between the generation of new events. Defaults to 1. Cannot be negative or zero.

  State:

  - dt (numeric) – Time delay between the generation of new events.
  - num (numeric) – The random number that’s being/needs to be outputted.
  - elapsed (numeric) – The elapsed time since last internal transition.

  Input Ports: | dt (numeric) – A new time delay. Cannot be negative or zero.
  Output Ports: | output (numeric) – Outputs the generated value.

  `timeAdvance`()
  `extTransition`(inputs)
  `intTransition`()
  `outputFnc`()
  `next`()

    Obtains a random variable w.r.t. this generator’s config.

    Do note that this updates the gen object, meaning it must only be called in functions that may update the state.

class `pypdevsbbl.generic.generators.``RandomDelayGenerator`(name: str, seed=None, dist=<function RandomDelayGenerator.<lambda>>, args=(), func=<function RandomDelayGenerator.<lambda>>, dt=0.0, max=inf, base=0)

  Bases: `pypdevs.DEVS.AtomicDEVS`

  `AtomicDEVS` that generates a new item every random time.

  The items that are generated get a sequential numbering (which can be altered using the `func` argument), but their inter-arrival times follow the provided distribution.

  It makes use of the RngStreams random number generator i.i.d. (0, 1). Using the `dist` argument, one can simply change the distribution over which numbers need to be generated. The `pypdevsbbl.extra.rngstreams.distributions` module provides an extensive implementation of a lot of distributions.

  See also

  - `RandomNumberGenerator`
  - `pypdevsbbl.generic.math.Random`
  - `pypdevsbbl.extra.rngstreams`
  - `pypdevsbbl.extra.rngstreams.distributions`

  Parameters:

  - name (str) – The name of the generator (both the block and the engine).
  - seed (numeric) – The seed for the generator. When `None`, it will not set a seed. Defaults to `None`.
  - dist (def) – A stateless function that implements an inversive cumulative distribution function. It takes at least a single argument, which falls in (0, 1). Defaults to a uniform distribution over (0, 1).
  - args (tuple) – Optional additional arguments to add to the distribution.
  - func (def) – Transformation function for the newly generated item.
  - dt (numeric) – Time of first item to generate. When `None`, no output will be created at time 0. Defaults to 0.
  - max (numeric) – Maximal amount of items to generate.
  - base (numeric) – The base number to start from when assigning the sequential numbering. When `None`, the block’s hash is used. Defaults to 0.

  State:

  - dt (numeric) – Time delay between the generation of new events.
  - num (numeric) – The random number that’s being/needs to be outputted.
  - elapsed (numeric) – The elapsed time since last internal transition.

  Input Ports: | halt (bool) – Halts the generator until further notice.
  Output Ports: | output (any) – Outputs the value.

  `timeAdvance`()
  `extTransition`(inputs)
  `intTransition`()
  `outputFnc`()
  `next`()

    Obtains a random variable w.r.t. this generator’s config.

    Do note that this updates the gen object, meaning it must only be called in functions that may update the state.