New function that solves VFI with NO d variable using grid interp layer and sparse matrix with Howard.
To test it, choose the following options when calling the VFI command:
vfoptions.lowmemory = 0; % already default
vfoptions.howardsgreedy = 0; % already default
vfoptions.howardssparse = 1;
vfoptions.gridinterplayer = 1;
vfoptions.ngridinterp = 15;
I have tested in a model with entrepreneurs and is about 5 times faster than the case vfoptions.howardssparse=0, so good news!
@robertdkirkby When you have time, you could test this new function on the Aiyagari example and let me know if you also see a substantial speed gain. In my test I used n_a=1000 and n_z=40, which is larger than what is needed for Aiyagari. Also, let me know if you want me to modify it, I should have some time before Tuesday when I start teaching.
Important note: In this function I loop over z, so this should be a low memory feature. However, since it is fast, in my PR I put in the normal case. I started with the ‘looping over z’ approach since it is easier to code. By the way, is there a lowmemory=1 in ValueFnIter_GridInterpLayer? I also consider only the postGI case. In preGI, I left the error message ‘not implemented yet’. I do not plan to implement preGI since it is too memory intensive.
Question. In the toolkit function ValueFnIter_GridInterpLayer there is an if condition if isscalar(n_a) in a couple of places, but I don’t understand what happens if n_a is not scalar (i.e. if there is more than one endogenous state). I think if this case is not implemented yet, there should be an error message. By the way, my sparse improvement is only for scalar a variable.