9,476 reputation
1642
bio website
location
age
visits member for 2 years, 6 months
seen Jul 17 at 21:28

Jan
22
revised How to minmize the memory problem in a compile function for a given code?
added 302 characters in body
Jan
22
comment ParametricNDSolve: Parameter inside UnitStep leads to longer integration times
One more comment: in my opinion there actually is a problem with ParametricNDSolve: there is only very vague documentation about what it does internally ("Derivatives of ParametricFunction are computed using a combination of symbolic and numerical sensitivity methods when possible."). One can make some guesses from the method options and examples but it's really difficult to make a reasonable guess about what kind of optimizations we can expect to be done and what the premises are for them. Maybe one day there will be another section in the advanced ndsolve docs...
Jan
22
comment ParametricNDSolve: Parameter inside UnitStep leads to longer integration times
Of course my comparison is somewhat oversimplified -- but there is certainly also some overhead in what ParametricNDSolve does/tries to do. While it might be well justified to claim that there is still potential for further optimization of ParametricNDSolve, I find the claim "there is a large issue" with it a little overdrawn -- after all you give no indication that it does something wrong and it isn't (much) slower than a naive approach. And I find it makes perfect sense that the case with a parameter in UnitStep is much more difficult/expensive than the almost trival one...
Jan
21
comment ParametricNDSolve: Parameter inside UnitStep leads to longer integration times
I'm not so sure whether this is not the contrary of a problem but a good example of why ParametericNDSolve is useful: the time to run just NDSolve for every value of RATE is about the same as that for the two-parameter case. The one-parameter case is much faster and that might well be because ParametericNDSolve can do an optimization for that case that it can't do for the (highly nonlinear) case where the parameter is in the UnitStep. Of course, I'm just guessing...
Jan
21
comment How to minmize the memory problem in a compile function for a given code?
@santosh: if I understand correctly that's easy enough, see my edit in the answer...
Jan
21
revised How to minmize the memory problem in a compile function for a given code?
added note about storing only diagonal elements
Jan
20
revised How to minmize the memory problem in a compile function for a given code?
added 19 characters in body
Jan
20
revised How to minmize the memory problem in a compile function for a given code?
added 419 characters in body
Jan
20
answered How to minmize the memory problem in a compile function for a given code?
Jan
19
awarded  Yearling
Jan
18
comment How to exit a package gracefully in the middle?
What's wrong with If[$FrontEnd=!=Null,DoSomethingIfFrontEndDefined] ? And you are missing some trailing backquotes in your context names...
Jan
18
comment How to minmize the memory problem in a compile function for a given code?
Which version/OS/compiler are you using? For me the Compile did work alright for n=4 with version 9.0.1 on Windows (both without any options and with your options). To make NDSolve finish without errors I only needed to increase MaxSteps, the rest of the options seems not to be necessary. Of course the quality of the solution might not be good enough without setting MaxStepSize, but using a small value for it will make the memory usage increase a lot (a factor of 3 for n=3). For n=4 I stopped NDSolve when the Kernel used more than 3 GB of memory...
Jan
18
comment How to minmize the memory problem in a compile function for a given code?
Why do you say "the compile function is not working"? For me it's the NDSolve that needs a lot of memory, so I stopped it to keep my computer operable. My impression is that you did try some optimizations in a quite arbitrary way, none of them seems to give any speedup, let alone safes you memory (which seems the main problem). Replacing all the Parallel functions with their sequential versions and using Compile with no options at all leaves the runtime exactly the same. You also might want to explain why you are using those options for NDSolve, can you explain why you chose them?
Dec
27
comment How to integrate functions of linearly interpolated data?
@halirutan: no problem, I didn't remember it was an open question until Alexey answered :-).
Dec
27
comment How to integrate functions of linearly interpolated data?
@AlexeyPopkov: thanks, that's useful. Actually it is where one could expect to find it, I obviously just didn't try hard enough...
Dec
27
answered Scheduled tasks not preserving order with Dynamic?
Dec
27
awarded  Nice Answer
Dec
23
answered Refering to global variables inside modules
Dec
17
comment Plotting heat equation in a Manipulate expression
@Ajasja: ... here are two examples with a more appropriate usage of Module which show what I am trying to say: Manipulate[Module[{z}, z = a^2; z], {a, 0, 2}] vs. Module[{y}, Manipulate[y = a^2; y, {a, 0, 2}]]. Interestingly by checking with Names["Global*"]` I found that Manipulate itself does leave behind a mess of new symbols for its own local variables, which I honestly do consider a "dirty" job, especially considering that DynamicModule doesn't show the problem...
Dec
17
comment Plotting heat equation in a Manipulate expression
@Ajasja: while it ist true that Module does create a lot of symbols for the local variables if used inside a Manipulate these usually are temporary and removed after the Module finishes (with the usual exceptions as in your examples). A Manipulate inside a Module will, on the other hand, only generate symbols for the local variables once, but these will always leak if used in the Manipulate and remain existing -- which I think is potentially a larger problem...