brian2 icon indicating copy to clipboard operation
brian2 copied to clipboard

Multiple standalone runs with change in parameters

Open mstimberg opened this issue 4 years ago • 1 comments

Running multiple standalone simulations of the same model with different parameters is quite cumbersome at the moment. We can support this much more efficiently by using the trick I show in my gist. It would be nice to expose this to the user, but I wonder about the best syntax. I think for cases like this it could be useful to more clearly separate the compilation and run stages. Here's an idea for a syntax:

group = NeuronGroup(...)
group.E_L = device.Parameter(default=-75*mV)
device.compile()
for E_L in [-70, -60, -50]*mV:
    device.run(parameters={group.E_L: E_L})

The encapsulation mode (https://github.com/brian-team/brian2/issues/251) would of course take care of that as well, but I think we need a more feasible short- to mid-term solution.

mstimberg avatar Oct 02 '20 09:10 mstimberg

I mostly like this syntax but is it a bit cumbersome? How about something like this?

define_parameter('E_L', group.E_L, default=-75*mV)
...
run(E_L=E_L)

I didn't consider carefully so there might be some bad things about this approach.

thesamovar avatar Oct 02 '20 10:10 thesamovar

Maybe not quite as fancy as the solution discussed here, but the basic mechanism has been implemented in #1429

mstimberg avatar Apr 18 '24 07:04 mstimberg