Closed chrisajohnson closed 2 years ago
As far as I can tell at a quick glance, most time is spent by SymEngine trying to simplify your equations – and not on integration. Thus calling compile_C
with simplify=False
was the right call (you don’t need to set the chunk_size
though as you only have four dynamical variables). However, you need to do this before calling integrate_blindly
, as it already needs the compiled code. In your current code, JiTCODE first compiles inefficiently, then calls integrate_blindly
, and then compiles efficiently. When I compile first, everything runs within seconds on my machine.
Some further remarks:
pi
instead of NumPy’s and don’t force numbers to be floats (e.g., using 1.
instead of 1
). This is not necessary and prevents potential optimisations.helpers
may help as you have a considerable number of recurring terms.adjust_diff
instead of integrate_blindly
.Awesome!!! Thank you so much for the super fast reply, it worked like a charm! Such a great package!
Hi,
First off, this is a really neat package that I think is exactly what I need to run DDE models for my research. Thanks!
I have a question about how to speed up the integration of my code (a minimal working example is below). Very briefly, I am using a variable-time delay model to predict the abundance of an insect species with juvenile (J) and adult (A) life stages. A third DDE equation describes juvenile survival (S) and the fourth equation describes the development time delay (tau). The maturation rate from juveniles to adults is dependent on the habitat temperature, which is modeled via a sine wave. For simplicity, I am using a constant past and I am integrating blindly (following advice in the documentation). To deal with initial discontinuities, I am simply running the model for long enough for transients to dissipate and the system to settle into equilibrium cycles.
The codes seems to be working (awesome!), but it takes 11-12 hours to run on my Mac laptop with Python 3.8.8 and JitCDDE 1.8. For reference, I ran a similar model years ago using the PyDDE package on the same laptop and the code would take ~15-20 minutes to run. I don't have access to a better computer, but I feel that I should be able to write a more efficient code that speeds up the integration. I am a Python newbie, so I am sure that any problems lie with my implementation of the code. I tried my best to follow the Common Mistakes and Questions suggestions, but must admit that some of the information about generators and Clang went over my head.
I hesitate to post this as an issue because it's very likely my own naive coding, but I am wondering if you have any suggests for speeding up the integration. Thanks so much in advance, it would be a life saver!
Best, Chris