Keeping multiple instances of the same simulation

Description of problem

I am trying to randomly perturb my network with an input at a given time point - I want to figure out how far my network has diverged from its initial trajectory (i.e. without the random input). In order to do this I need to keep track of the network dynamics following input and the network dynamics had I never perturbed the system.

However my network is stochastic due to poisson input so I can’t just re-run the network. What im wondering is if there is any feature in Brian to keep multiple instances of the exact same network (with the same stochastic input) dynamics, one where I add input and one where I dont?

Thanks in advance!

Hi. If I understand correctly what you want to do, you have two options:

  1. run the network twice and set the same random number seed each time. You have to be a bit careful that the simulation is generating the exact random numbers in both cases which means that you should not completely remove the random input, but rather multiply it with 0.
  2. snapshot the simulation with store() and go back to the earlier state with restore (see Running a simulation — Brian 2 2.4.2 documentation). You can ask restore to “rewind” the random number generator as well with the option restore_random_state (see restore function — Brian 2 2.4.2 documentation). The same comment as above holds – be careful that you ask for the same amount of random numbers in both cases.

The second option has the advantage that you only need to run the simulation once up to the point where you want to have the perturbation. On the downside, the store/restore mechanism does not work with the C++ standalone mode.

Hope that helps!

This works, thanks so much!

1 Like