-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify exact integration #1327
base: master
Are you sure you want to change the base?
Conversation
Also handle better trivial equations (e.g. constant RHS term)
…ct" state updater After merging #1327, this shouldn't be necessary anymore.
These sorts of changes seem important to get right. In principle, this all sounds fine and the code looks good, but I'd like to go through the maths before we commit it if that's ok? Could you explain the reasoning? |
Also, what does the generated code look like for a couple of equations before and after? Just trying to get a feel for this change. |
So the maths for the new version is quite easy to explain: we use the fact that the solution to The currently implemented solution is slightly different (and basically the same as the one used in Brian 1) and solves a linear system to get the matrix I am off to my holidays unfortunately (maybe not the right word 😉 ), so more details on this have to wait until I'm back! |
It would be good to think carefully about this as there are some hiccups that do occasionally crop up. One of the most common being that if you have two time constants for membrane and synapse, and those time constants have different symbols but the same value, you get nans (because there is a divide by the difference of the two time constants in the solution). I guess this corresponds to a singular matrix. That can be dealt with, but it's not straightforward. What if the time constants are different for every neuron? What if they change each time step? etc. |
The "exact" integration algorithm currently has some limitations and is not able to integrate some linear equations with constant coefficients. For example, it fails to integrate this (Tsodyks, Pawelzik, Markram, Neural Computation, 1998):
This is because it hardcodes the approach for non-homogeneous equations, and homogenous ones like the one above need to be handled slightly differently. Even simpler, equations like
dv/dt = rate : 1
are not supported, which can be especially annoying if you add such an equation to an existing set of equations that can be integrated withexact
. I first tried to tackle this by making exceptions for certain types of equations, but I finally found it simpler to convert all non-homogeneous equations into homogenous equations by transforming an equation likeinto something along the lines of
(which happens to be the approach used in Rotter & Diesmann (1999) for piecewise-constant input).
This simplifies the code quite a bit and also reduces our dependency on sympy details (we only call the matrix exponential, but there's no need any more to call the
solve_linear_system
method), which sometimes break with updates.There's one disadvantage: the process of generating the update code takes ~30% longer, e.g. for the CUBA model 2.7s instead of 1.9s. There's no change in execution speed and the results are of course unchanged. I think the change is worth it despite the inconvenience of slightly longer code generation, and there are also ways to make this faster in the future. In particular, the equations are complicated by the
int(not_refractory)
term, and we might change this in the future to separate code generation for theTrue
/False
cases.