the BasisMatrices routines are unfortunately not very efficient when evaluated at a single point.
This pull request tries to get around this by vectorizing the call to funeval in the innermost part of the s_wise_max set of routines.
The speedup was considerable. When solving a cdp with VFI at a tol of 1e-3, the monetary policy example went from 25 to 4 seconds and the optimal growth example went from 70 seconds to 8 seconds.
Another (related) change is using type parameters for all the function fields of ContinuousDP. Function is an abstract type in Julia 0.6, and all functions are concrete subtypes of Function. Thus, we if let ContinuousDP parameterize on these concrete types, all uses of cdp.(f|g|x_lb|x_ub) will be type-inferrable by the compiler.
EDIT
I still believe there are many performance optimizations on the table, but this is a first step.
I really should have focused on getting the API stable, but I couldn't resist.
the BasisMatrices routines are unfortunately not very efficient when evaluated at a single point.
This pull request tries to get around this by vectorizing the call to
funeval
in the innermost part of thes_wise_max
set of routines.The speedup was considerable. When solving a cdp with VFI at a tol of 1e-3, the monetary policy example went from 25 to 4 seconds and the optimal growth example went from 70 seconds to 8 seconds.
Another (related) change is using type parameters for all the function fields of ContinuousDP.
Function
is an abstract type in Julia 0.6, and all functions are concrete subtypes of Function. Thus, we if let ContinuousDP parameterize on these concrete types, all uses ofcdp.(f|g|x_lb|x_ub)
will be type-inferrable by the compiler.EDIT
I still believe there are many performance optimizations on the table, but this is a first step.
I really should have focused on getting the API stable, but I couldn't resist.