Parallel Computation#

slotted_aloha_simulator.parallel.compute(parameters, computations=None)[source]#

Simple wrapper for launching a single simulation

Parameters:
  • parameters (dict) – Parameters for the aloha simulation

  • computations (list of str, optional) – Name of computing methods to call.

Returns:

The input parameters (for traceability) plus a ‘results’ key that contain the simulation measurements.

Return type:

dict

slotted_aloha_simulator.parallel.parallel_compute(parameters_list, computations=None, n_jobs=-1)[source]#
Parameters:
  • parameters_list (list of dict) – Simulation parameters.

  • computations (list of str, optional) – Name of computing methods to call.

  • n_jobs (int, default=-1) – Number of workers to spawn, joblib style (-1 means all CPUs).

Returns:

For each setting, input parameters with an extra ‘results’ key.

Return type:

list of dict

Examples

>>> p_values = [1/8, 1/4, 1/2, 2/3]
>>> p_list = [{'p0': p, 'n': 4, 't_sim': 10, 'seed': 42} for p in p_values]
>>> data = parallel_compute(p_list, n_jobs=len(p_values))
>>> for dat in data:
...     print(round(dat['p0'], 4))
...     mf = dat['results']['mf']
...     print([mf[k][3].round(4) for k in ['occupancy', 'goodput', 'efficiency']])
...     sim = dat['results']['simulation']
...     print([sim[k][3].round(4) for k in ['occupancy', 'goodput', 'efficiency']])
0.125
[0.3642, 0.3049, 0.712]
[0.3632, 0.3039, 0.7118]
0.25
[0.5215, 0.3873, 0.5753]
[0.5176, 0.3804, 0.5627]
0.5
[0.6501, 0.4202, 0.4549]
[0.6466, 0.423, 0.4637]
0.6667
[0.6929, 0.4217, 0.4125]
[0.702, 0.4377, 0.4302]