Simulation#
- class SimulatedDrop(timestamp, device_transmissions, channel_realizations, device_receptions)#
Bases:
Drop
Drop containing all information generated during a simulated wireless scenario transmission, channel propagation and reception.
- Parameters:
timestamp (float) – Time at which the drop was generated.
device_transmissions (Sequence[DeviceTransmission]) – Transmitted device information.
channel_realizations (Sequence[Sequence[ChannelRealization]]) – Realizations of the wireless channels over which the simualation propagated device transmissions.
device_receptions (Sequence[ProcessedSimulatedDeviceReception]) – Received device information.
- property channel_realizations: Sequence[Sequence[ChannelRealization]]#
Channel realizations over which signals were propagated.
Returns: Two-dimensional numpy matrix with each entry corresponding to the respective device link’s channel.
- to_HDF(group)#
Serialize the object state to HDF5.
Dumps the object’s state and additional information to a HDF5 group.
- Parameters:
group (Group) – The HDF5 group to which the object is serialized.
- Return type:
None
- classmethod from_HDF(group)#
De-Serialized the object state from HDF5.
Recalls the object’s state from a HDF5 group.
- Parameters:
group (Group) – The HDF5 group from which the object state is recalled.
- Return type:
Returns: The object initialized from the HDF5 group state.
- class SimulationScenario(snr=inf, snr_type=SNRType.PN0, *args, **kwargs)#
Bases:
Scenario
[SimulatedDevice
]- Parameters:
snr (float, optional) – The assumed linear signal to noise ratio. Infinite by default, i.e. no added noise during reception.
snr_type (Union[str, SNRType], optional) – The signal to noise ratio metric to be used. By default, signal power to noise power is assumed.
- yaml_tag = 'SimulationScenario'#
- new_device(*args, **kwargs)#
Add a new device to the simulation scenario.
- Returns:
Newly added simulated device.
- Return type:
- add_device(device)#
Add a new device to the scenario.
- Parameters:
device (Device) – New device to be added to the scenario.
- Raises:
ValueError – If the device already exists.
RuntimeError – If the scenario is not in default mode.
- Return type:
None
- property channels: 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:
transmitter (SimulatedDevice) – The device transmitting into the channel.
receiver (SimulatedDevice) – the device receiving from the channel
- Returns:
Channel between transmitter and receiver.
- Return type:
- 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.
- 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: float | None#
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.
- transmit_devices(cache=True)#
Generate simulated device transmissions of all registered devices.
Devices sharing trigger models will be triggered simultaneously.
- Parameters:
cache (bool, optional) – Cache the generated transmissions at the respective devices. Enabled by default.
- Return type:
Sequence
[SimulatedDeviceTransmission
]- Returns:
Sequence of simulated simulated device transmissions.
- propagate(transmissions)#
Propagate device transmissions over the scenario’s channel instances.
- Parameters:
transmissions (Sequence[DeviceOutput]) – Sequence of device transmissisons.
- Return type:
List
[List
[Tuple
[Signal
,ChannelRealization
]]]
Returns: Propagation matrix.
- Raises:
ValueError – If the length of transmissions does not match the number of registered devices.
- process_inputs(impinging_signals, cache=True, trigger_realizations=None)#
Process input signals impinging onto the scenario’s devices.
- Parameters:
impinging_signals (Sequence[DeviceInput | Signal | Sequence[Signal]]) – List of signals impinging onto the devices.
cache (bool, optional) – Cache the operator inputs at the registered receive operators for further processing. Enabled by default.
trigger_realizations (Sequence[TriggerRealization], optional) – Sequence of trigger realizations. If not specified, ideal triggerings are assumed for all devices.
- Return type:
Returns: List of the processed device input information.
- Raises:
ValueError – If the number of impinging_signals does not match the number of registered devices.
- receive_devices(impinging_signals, cache=True, trigger_realizations=None)#
Receive over all simulated scenario devices.
Internally calls
SimulationScenario.process_inputs()
andScenario.receive_operators()
.- Parameters:
impinging_signals (List[Union[DeviceInput, Signal, Iterable[Signal]]]) – List of signals impinging onto the devices.
cache (bool, optional) – Cache the operator inputs at the registered receive operators for further processing. Enabled by default.
trigger_realizations (Sequence[TriggerRealization], optional) – Sequence of trigger realizations. If not specified, ideal triggerings are assumed for all devices.
- Return type:
Sequence
[SimulatedDeviceReception
]
Returns: List of the processed device input information.
- Raises:
ValueError – If the number of impinging_signals does not match the number of registered devices.
- class SimulationRunner(scenario)#
Bases:
object
Runner remote thread deployed by Monte Carlo routines
- Parameters:
scenario (SimulationScenario) – Scenario to be run.
- transmit_operators(*, _ray_trace_ctx=None)#
Generate base-band signal models emitted by all registered transmitting operators.
Internaly resolves to the scenario’s transmit operators routine
SimulationScenario.transmit_operators()
.- Return type:
None
- generate_outputs(*, _ray_trace_ctx=None)#
Generate radio-frequency band signal models emitted by devices.
Internally resolves to the scenario’s generate outputs routine
SimulationScenario.generate_outputs()
.- Return type:
None
- propagate(*, _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.
- Raises:
RuntimeError – If the propagation stage is called without prior device transmission.
RuntimeError – If the number of transmit signals does not match the number of registered devices.
- Return type:
None
- process_inputs(*, _ray_trace_ctx=None)#
Process device inputs after channel propgation.
- Raises:
RuntimeError – If the propagation stage is called without prior channel propagation.
RuntimeError – If the number of arriving signals does not match the number of registered devices.
- Return type:
None
- receive_operators(*, _ray_trace_ctx=None)#
Demodulate base-band signal models received by all registered receiving operators.
Internally resolves to the scenario’s receive operators routine
SimulationScenario.receive_operators()
.- Return type:
None
- class Simulation(scenario=None, num_samples=100, drop_duration=0.0, plot_results=False, dump_results=True, console_mode=ConsoleMode.INTERACTIVE, ray_address=None, results_dir=None, verbosity=Verbosity.INFO, seed=None, num_actors=None)#
Bases:
Serializable
,Pipeline
[SimulationScenario
,SimulatedDevice
],MonteCarlo
[SimulationScenario
]HermesPy simulation configuration.
Args:
- scenario (SimulationScenario, optional):
The simulated scenario. If none is provided, an empty one will be initialized.
- num_samples (int, optional):
Number of drops generated per sweeping grid section. 100 by default.
- 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.
- ray_address (str, optional):
The address of the ray head node. If None is provided, the head node will be launched in this machine.
- 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.
- property_blacklist: Set[str] = {'console', 'console_mode', 'scenario'}#
Set of properties to be ignored during serialization.
- plot_results: bool#
Plot results after simulation runs
- dump_results: bool#
Dump results to files after simulation runs.
- property num_samples: int#
Number of samples per simulation grid element.
- Returns:
Number of samples
- Return type:
int
- Raises:
ValueError – If number of samples is smaller than one.
- property console_mode: ConsoleMode#
Console mode during runtime.
Returms: The current console mode.
- property console: Console#
Console the Simulation writes to.
- Returns:
Handle to the console.
- Return type:
Console
- run()#
Execute the configuration.
Returns: The result of the run.
- Return type:
- 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: