Simulation

class SimulationScenario(seed=None)

Bases: hermespy.core.scenario.Scenario[hermespy.simulation.simulated_device.SimulatedDevice]

Parameters

seed (int, optional) – Random seed used to initialize the pseudo-random number generator.

new_device()

Add a new device to the simulation scenario.

Returns

Newly added simulated device.

Return type

SimulatedDevice

add_device(device)

Add new device to scenario.

Parameters

device (DeviceType) – New device to be added to the scenario.

Raises ValueError if the device already exists.

Return type

None

property channels: numpy.ndarray

Channel matrix between devices.

Returns

An MxM matrix of channels between devices.

Return type

np.ndarray

channel(transmitter, receiver)

Access a specific channel between two devices.

Parameters
Returns

Channel between transmitter and receiver.

Return type

Channel

Raises

ValueError – Should transmitter or receiver not be registered with this scenario.

departing_channels(transmitter, active_only=False)

Collect all channels departing from a transmitting device.

Parameters
  • transmitter (SimulatedDevice) – The transmitting device.

  • active_only (bool, optional) – Consider only active channels.

Returns

A list of departing channels.

Return type

List[Channel]

Raises

ValueError – Should transmitter not be registered with this scenario.

arriving_channels(receiver, active_only=False)

Collect all channels arriving at a device.

Parameters
  • receiver (Receiver) – The receiving modem.

  • active_only (bool, optional) – Consider only active channels.

Returns

A list of arriving channels.

Return type

List[Channel]

Raises

ValueError – Should receiver not be registered with this scenario.

set_channel(receiver, transmitter, channel)

Specify a channel within the channel matrix.

Parameters
  • receiver (int) – Index of the receiver within the channel matrix.

  • transmitter (int) – Index of the transmitter within the channel matrix.

  • channel (Optional[Channel]) – The channel instance to be set at position (transmitter_index, receiver_index).

Raises

ValueError – If transmitter_index or receiver_index are greater than the channel matrix dimensions.

Return type

None

property snr: Optional[float]

Ratio of signal energy to noise power at the receiver-side.

Returns

Linear signal energy to noise power ratio. None if not specified.

Return type

Optional[float]

Raises

ValueError – On ratios smaller or equal to zero.

SimulationResult: Type[hermespy.core.monte_carlo.MonteCarloResult[hermespy.simulation.simulation.SimulationScenario]]

Result Container of a Full Simulation Campaign.

class SimulationRunner(scenario)

Bases: object

Parameters

scenario (SimulationScenario) – Scenario to be run.

transmit_operators(drop_duration=None, *, _ray_trace_ctx=None)

Generate base-band signal models emitted by all registered transmitting operators.

Parameters

drop_duration (float, optional) – Length of simulated transmission in seconds.

Raises
  • ValueError – On invalid `drop_duration`s.

  • ValueError – If data_bits does not contain data for each transmitting modem.

Return type

None

transmit_devices(*, _ray_trace_ctx=None)

Generate radio-frequency band signal models emitted by devices.

Returns

List of signal models emitted by transmitting devices.

Return type

List[List[Signal]]

propagate(transmitted_signals, *, _ray_trace_ctx=None)

Propagate the signals generated by registered transmitters over the channel model.

Signals receiving at each receive modem are a superposition of all transmit signals impinging onto the receive modem over activated channels.

The signal stream matrices contain the number of antennas on the first dimension and the number of signal samples on the second dimension

Parameters

transmitted_signals (List[List[Optional[np.ndarray]]]) – Signal models transmitted by each registered device.

Returns

A square matrix of dimension num_devices containing tuples of propagated signals as well as the respective channel state information.

Return type

np.ndarray

Raises

ValueError – If the number of transmitted_signals does not equal the number of devices.

receive_devices(propagation_matrix, *, _ray_trace_ctx=None)

Generate base-band signal models received by devices.

Parameters

propagation_matrix (np.ndarray) – Matrix of signals and channel states impinging onto devices.

Returns

Signals received by the devices.

Return type

received_signals(List[Signal])

Raises

ValueError – If the length of propagation_matrix does not equal the number of devices within this scenario.

class Simulation(num_samples=100, drop_duration=0.0, plot_results=False, dump_results=True, snr_type=SNRType.EBN0, results_dir=None, verbosity=Verbosity.INFO, seed=None)

Bases: hermespy.core.executable.Executable, hermespy.core.factory.Serializable, hermespy.core.monte_carlo.MonteCarlo[hermespy.simulation.simulation.SimulationScenario]

HermesPy simulation configuration.

Args:

drop_duration(float, optional):

Duration of simulation drops in seconds.

plot_results (bool, optional):

Plot results after simulation runs. Disabled by default.

dump_results (bool, optional):

Dump results to files after simulation runs. Enabled by default.

snr_type (Union[str, SNRType]):

The signal to noise ratio metric to be used.

results_dir (str, optional):

Directory in which all simulation artifacts will be dropped.

verbosity (Union[str, Verbosity], optional):

Information output behaviour during execution.

seed (int, optional):

Random seed used to initialize the pseudo-random number generator.

yaml_tag: Optional[str] = 'Simulation'

YAML serialization tag.

plot_results: bool

Plot results after simulation runs

dump_results: bool

Dump results to files after simulation runs.

property scenario: hermespy.simulation.simulation.SimulationScenario

Scenario description of the simulation.

Returns

Scenario description.

Return type

SimulationScenario

run()

Execute the configuration.

Return type

SimulationResult

property snr_type: hermespy.core.statistics.SNRType

Global type of signal to noise ratio.

Return type

SNRType

property snr: Optional[float]

Ratio of signal energy to noise power at the receiver-side.

Returns

Linear signal energy to noise power ratio. None if not specified.

Return type

Optional[float]

Raises

ValueError – On ratios smaller or equal to zero.

classmethod to_yaml(representer, node)

Serialize an Simulation object to YAML.

Parameters
  • representer (SafeRepresenter) – A handle to a representer used to generate valid YAML code. The representer gets passed down the serialization tree to each node.

  • node (Simulation) – The Simulation instance to be serialized.

Returns

The serialized YAML node

Return type

Node

classmethod from_yaml(constructor, node)

Recall a new Simulation instance from YAML.

Parameters
  • constructor (SafeConstructor) – A handle to the constructor extracting the YAML information.

  • node (Node) – YAML node representing the Simulation serialization.

Returns

Newly created Simulation instance.

Return type

Simulation