magni.cs.phase_transition._simulation module¶
Module providing the actual simulation functionality.
Routine listings¶
 run(algorithm, path, label)
 Simulate a reconstruction algorithm.
See also
magni.cs.phase_transition._config
 Configuration options.
Notes
The results of the simulation are backed up throughout the simulation. In case the simulation is interrupted during execution, the simulation will resume from the last backup point when run again.

magni.cs.phase_transition._simulation.
run
(algorithm, path, label, pre_simulation_hook=None)[source]¶ Simulate a reconstruction algorithm.
The simulation results are stored in a HDF5 database rather than returned by the function.
Parameters:  algorithm (function) – A function handle to the reconstruction algorithm.
 path (str) – The path of the HDF5 database where the results should be stored.
 label (str) – The label assigned to the simulation results
 pre_simumlation_hook (callable) – A handle to a callable which should be run just before the call to the reconstruction algorithm (the default is None, which implies that no pre hook is run).

magni.cs.phase_transition._simulation.
_simulate
(algorithm, ij_tuple, seed, path, pre_simulation_hook=None)[source]¶ Run a number of monte carlo simulations in a single deltarho point.
The result of a simulation is the simulation error distance, i.e., the ratio between the energy of the coefficient residual and the energy of the coefficient vector. The time of the simulation is the execution time of the reconstruction attempt.
Parameters:  algorithm (function) – A function handle to the reconstruction algorithm.
 ij_tuple (tuple) – A tuple (i, j) containing the parameters i, j as listed below.
 i (int) – The deltaindex of the point in the deltarho grid.
 j (int) – The rhoindex of the point in the deltarho grid.
 seed (int) – The seed to use in the random number generator when generating the problem suite instances.
 path (str) – The path of the HDF5 backup database.
 pre_simulation_hook (callable) – A handle to a callable which should be run just before the call to the reconstruction algorithm (the default is None, which implies that no pre hook is run).
See also
magni.cs.phase_transition._config()
 Configuration options.
magni.cs.phase_transition._data.generate_matrix()
 Matrix generation.
magni.cs.phase_transition._data.generate_vector()
 Coefficient vector generation.
Notes
The pre_simulation_hook may be used to setup the simulation to match the specfic simulation parameters, e.g. if an oracle estimator is used in the reconstruction algorithm. The pre_simulation_hook takes one argument which is the locals() dict.
The following reconstruction statistics are computed:
 time: Measured algorithm run time in seconds.
 dist: Normalised mean squared error (NMSE)  ( alpha_hat  alpha / alpha)^2
 mse: Mean squared error (MSE)  1/n * alpha_hat  alpha^2
 norm: True vector norm  alpha