Excellent questions, and they pertain to all kinds of models, not just network models.
This
Code: Select all
objref svstate
svstate = new SaveState()
svstate.save()
creates a SaveState object that contains the present values of "all" states, regardless
of the size and complexity of (and number of cells in) your model. The only exception
is that the event queue is not saved (see
Caveats below).
To use the state data that are contained in a SaveState object, it is necessary to make
a small change to the standard run system's proc init() (I assume that you are using the
standard run system, not your own simulation control code). To do this, insert the
following code into your program, anywhere after the point at which you put the stuff
that creates svstate--
Code: Select all
proc init() {
finitialize(v_init)
svstate.restore()
t = 0 // t is one of the "states"
if (cvode.active()) {
cvode.re_init()
} else {
fcurrent()
}
frecord_init()
}
Now every simulation will start from the state that you saved earlier.
State information can be saved for use in later sessions with
Code: Select all
objref f
f = new File("states.dat")
svstate.fwrite(f)
Here's how to read such a file into SaveState object:
Code: Select all
objref svstate, f
svstate = new SaveState()
f = new File("states.dat")
svstate.fread(f)
To use these state data, just include the new proc init() shown above.
Caveats:
1. The biggest one is that the "state" of the event queue is not saved. This means that
undelivered events are lost. This could have important consequences for models that
use the event delivery system, i.e. models that use NetCons or which use
cvode.event() or an FInitializeHandler to launch events that have not yet been
delivered by the time SaveState.save() is called. Bill Lytton does a lot of network
modeling and may have worked out a strategy for dealing with this problem; I'll
ask him to comment on this.
2. States are saved in a binary format using data structures that are likely to be
incompatible across different versions of NEURON. Consequently, if you update
NEURON, you will have to generate a new states.dat file.
How can you set the time point the network state is saved?
If this means what I think it does, the simplest answer is: use tstop.
Code: Select all
Can you use continuetil() to run simulations from the restore point on?
You could, but first you'd have to execute init(). Why not just execute run(), which
takes care of everything?