#240: rewrite getPowerDeriv assignments in temporary terms --------------------------+------------------------------------------------- Reporter: houtanb | Owner: houtanb Type: bug | Status: new Priority: major | Milestone: 4.3 Component: Preprocessor | Version: Keywords: | --------------------------+------------------------------------------------- From Stephane:
In models with power functions of the form x**a (utility functions, production functions, agregation functions, quadratic costs, ...) the evaluation of the jacobian matrix (or higher order derivates) necessitate potentially a huge number of calls to the routine getPowerDeriv (the name of the routine is explicit enough). In my example (a real business cycle model with perfect foresight) most of the time is spent in this routine, while, if my understanding is correct, this is not necessary because x>0.
I wrote a mex file (see the new branch called mex-!GetPowerDeriv) as a replacement for the matlab routine, unfortunatly the overhead cost is so high that the use of the mex file increases the total time of execution!
In my case I resolved the issue by using option use_dll, but this is not a solution for the majority of our users (they would have to install cygwin/gcc and configure matlab/mex). So my question is: Do we really need to call this routine in all situations ? Would it not be possible to replace calls to this routine by something like:
if (abs(x)>1e-12) tmp = ANALYTICAL_EXPRESSION_OF_THE_DERIVATIVE{x,params}; else tmp = 0; end
#240: rewrite getPowerDeriv assignments in temporary terms --------------------------+------------------------------------------------- Reporter: houtanb | Owner: houtanb Type: bug | Status: new Priority: major | Milestone: 5.0 Component: Preprocessor | Version: Keywords: | --------------------------+------------------------------------------------- Changes (by houtanb):
* milestone: 4.3 => 5.0
#240: rewrite getPowerDeriv assignments in temporary terms --------------------------+------------------------------------------------- Reporter: houtanb | Owner: houtanb Type: enhancement | Status: new Priority: major | Milestone: 5.0 Component: Preprocessor | Version: Keywords: | --------------------------+------------------------------------------------- Changes (by sebastien):
* type: bug => enhancement
#240: rewrite getPowerDeriv assignments in temporary terms ---------------------------+--------------------- Reporter: houtanb | Owner: houtanb Type: enhancement | Status: new Priority: major | Milestone: 5.0 Component: Preprocessor | Version: Resolution: | Keywords: ---------------------------+---------------------
Comment (by houtanb):
Need to talk to Stéphane about this....
1) Solution above 2) getPowerDeriv as default, use analytical derivs instead with a flag 3) analytical deris as default, use getPowerDeriv instead with a flag
1) is the most detailed
Sébastien seems to think that Stéphane would be happy with either 2) or 3). If this is true, we'd need to decide which one would be the default. Argument for 2) as the default is that it'll work every time, even it might take longer. Argument for 3) as the default is that it will be faster and is usually ok for most models.