[SciPy-user] Optimization & Parallelization of, integrate.odeint
Lars Friedrich
lfriedri at imtek.de
Tue May 8 12:26:59 EDT 2007
Hello Anne, hello all,
thank you very much for your post. I am also interested in solving ODEs and your post encourages me to use python for this.
Anne Archibald wrote:
> If you write it efficiently, with minimal loops, you will not lose a
> great deal of performance by using python.
Ok. I have the problem, that my ODEs are usually very simple like
x'(t) = input(t) - k(x) * x(t)
where k(x) is a nonlinear function of x and x is a scalar(!). So I don't
have the chance to avoid loops, because there are none.
>
> Solving ODEs, at least the way odeint and friends do it, is a mostly
> sequential process - you calculate the derivative at a few samples,
> find an approximate solution that covers the range of values you just
> sampled; if it's a good approximation, you accept its value at the
> endpoint and repeat the process, otherwise you cut it down and start
> working on a smaller step. But until you've taken a step, you don't
> know what values to use to evaulate your function at the next step. So
> there's not a lot of scope for parallelization, even if odeint had
> been written to do it.
I understand. This means, that the solver will to the unavoidable
"looping" over the system function for me. But if the system function is
a basic python function, this will cause some overhead, that makes the
simulation slow, or did I get something wrong here?
> You might also look into
> one of the other tools - numexpr, weave, etc. - for accelerating code
> before you jump to FORTRAN.
Ok. What do you recommend? (Fortran is no option for me ;-) Numexpr is
in the sandbox, so I started to look at weave. But it seems to me that I
need some work to start using weave. (setting up the compiler?,
understanding how weave works...) This is no problem, if I know, that I
am on the right way. So can you recommend the combination weave/odeint
or is there a better way? Do you think this will speed up simulations
with *scalar* or *low-dimensional* states?
Thanks
Lars
More information about the SciPy-User
mailing list