Code to reconstruct the network topology in dynamical systems with following the functional form
assuming
See R.Schmidt et al., Inferring topology of networks with hidden dynamic variables, IEEE Access (2022) for the publication.
Let
from reconstruction import Reconstructor
R = Reconstructor(y, t, f, g, fkwargs, gkwargs)
R.reconstruct()
Here, f=f(t, y, **fkwargs)
and g=g(t, y, **gkwargs)
are callables.
Results can be accessed via
K, delta_x = R.get_results()
where K
denotes the reconstructed matrix, and delta_x
is a list of tuples. Each tuple contains (j, i)
and the reconstructed delta_x_ij
, i.e. the reconstructed difference of
The code requires the following packages:
numpy, scipy, numba, sklearn
The code has been tested using
python 3.8.5
numpy 1.19.3
scipy 1.6.0
numba 0.50.1
sklearn 0.23.2
Reconstruction is implented using either least squares (np.linalg.lstsq
) or pseudo inverse (np.linalg.pinv
), which can be specified via R.reconstruct(method='lstsq')
. When using method='pinv'
, rarely, numerical outliers might occur when inferring the network topology, see Fig. 1(a).
Fig.1 Outliers in inferred coupling matrix caused by single-value computation.
This is due to the calculation of the pseudo inverse via singular value decomposition. In the calculation, 1 is divided by the individual singular values unequal to zero. If a singular value is very small however, single very large matrix elements may occur in the Moore-Penrose-Pseudoinverse
Typically, we separate numerical noise from the reconstructed edges by calculating a threshold value. However, if there is a single, very large matrix element, the threshold value also becomes very large, which in turn is responsible for omitting all inferred edges except for the outlier, see Fig. 1(b). As only a single, very large matrix element remains, the computed MAE also is very large. Since detecting this computational error is very easy, e.g. by comparing the number of edges the reconstructed matrix with the (known) number of nodes, we discarded the corresponding simulation in Fig. 3 in the publication.