netneurotools.networks.strength_preserving_rand_sa_mse_opt
- netneurotools.networks.strength_preserving_rand_sa_mse_opt(A, rewiring_iter=10, nstage=100, niter=10000, temp=1000, frac=0.5, R=None, connected=None, verbose=False, seed=None)[source]
Strength-preserving network randomization using simulated annealing.
Randomize an undirected weighted network, while preserving the degree and strength sequences using simulated annealing.
This function has been optimized for speed but only allows the mean squared error energy function.
- Parameters:
A ((N, N) array-like) – Undirected weighted connectivity matrix
rewiring_iter (int, optional) – Rewiring parameter. Default = 10. Each edge is rewired approximately rewiring_iter times.
nstage (int, optional) – Number of annealing stages. Default = 100.
niter (int, optional) – Number of iterations per stage. Default = 10000.
temp (float, optional) – Initial temperature. Default = 1000.
frac (float, optional) – Fractional decrease in temperature per stage. Default = 0.5.
R ((N, N) array-like, optional) – Pre-randomized connectivity matrix. If None, a rewired connectivity matrix is generated using the Maslov & Sneppen algorithm. Default = None.
connected (bool, optional) – Whether to ensure connectedness of the randomized network. By default, this is inferred from data.
verbose (bool, optional) – Whether to print status to screen at the end of every stage. Default = False.
seed (float, optional) – Random seed. Default = None.
- Returns:
B ((N, N) array-like) – Randomized connectivity matrix
min_energy (float) – Minimum energy obtained by annealing
Notes
Uses Maslov & Sneppen rewiring model to produce a surrogate connectivity matrix, B, with the same size, density, and degree sequence as A. The weights are then permuted to optimize the match between the strength sequences of A and B using simulated annealing.
This function is adapted from a function written in MATLAB by Richard Betzel and was optimized by Vincent Bazinet.
References
Misic, B. et al. (2015) Cooperative and Competitive Spreading Dynamics on the Human Connectome. Neuron. Milisav, F. et al. (2024) A simulated annealing algorithm for randomizing weighted networks.