Ln1Exp and other numerical optimizations #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, I remember that one time we had a conversation about how to handle numerical optimizations e.g. for
ln(1 + exp(x))stuff. So, I tested it. Implementation is rather simplistic, and I've just added some code to theCompileExpressionvisitor, but it should be probably done in some more organized way (e.g. separate visitor per optimization). I was wondering if it's possible to useSubstituteTransformfor that? But this is more like a run-time optimization, and it fits better for the compilation step. I've also tried addingLn1Expfunction to the global namespace directly, so it can be used in models, but it causes many problems (e.g. with differentiation). BTW, that's why I had to add a linear extension to theexpfunction, because withoutCall.Ifin triode models, Computer Algebra produces different results, containing exp function calls in derivatives, which wasn't the case in old version because of how derivatives are handled for function containingifexpression 😉Anyway, I hope that you can point me in the right direction with this 😄