I want to reinitialize a set of monitors that are explicitly added to a
Network object after a simulation time of length
T/N. The reason is I’m recording a number of variables and things get quickly enormous. So I want to chop the whole simulation into
N chunks, do light post-processing on them and save the important parameters, restart the monitors (clear all the recorded variables but keep the network state), and then continue the simulation for the next chunk.
I’ve realized from the previous conversations in the old google group that it often suffices to
del those objects and redefine them again. However, I shamefully don’t know how to do it.
I define my network as follows:
# imports and some configuration ... b2.start_scope() net = Network(collect()) # let's define 10 groups G =  for i in range(10): Gi= NeuronGroup(...) G.append(Gi) net.add(G) # let's connect them somehow adj_mat = [[...]] # adjacency matrix S =  for i in len(adj_mat): for j in len(adj_mat): .... # some condition based on adj_mat Sij = Synapse(...) S.append(Sij) net.add(S) # lets define monitors mons =  for k in range(K): mon_k = StateMonitor( ... , name=str(k)) # name for tracking monitors mons.append(mon_k) net.add(mon_k) net.run(T/N) # drink a coffee, come back and face your full RAM # some post-processing for k in range(K): fancy_output_from_mon_k = ... save_fancy() # let's clean the monitors >> HELP NEEDED HERE << # and add the originally define ones to the network again net.add(mons) # and finally redo the procedure N-1 other times ...
I tried going through items in
mons (that contains all the monitors) and
del them one by one. I also tried to remove the whole list
mons. Neither freed up the space. It’s expected since
mons or its contaminants are simply python objects. What I really have to delete are the objects that are added to
net. I can see all the monitors in the
net.objects. (Btw, I tried all this in Jupyter environment, although I don’t think it matters.)
So the question specifically would be how to modify network objects.
Any help or ideas that help me free up the space clogged by the monitors are appreciated.