Well I’m still stuck: after eliminated the decision variable, this PolicyKron is coming back not in Kronecker form (line 24 of ValueFnIter_InfHorz_TPath_SingleStep:
[VKron,PolicyKron]=ValueFnIter_InfHorz_TPath_SingleStep_nod_raw(VKron,n_a, n_z, a_grid, z_gridvals, pi_z, ReturnFn, Parameters, DiscountFactorParamNames, ReturnFnParamNames, vfoptions);
This should be no problem for (line 51 of TransitionPath_InfHorz_PType_singlepath), since it’s declared as a Policy:
[V, Policy]=ValueFnIter_InfHorz_TPath_SingleStep(Vnext,n_d,n_a,n_z,d_grid, a_grid, z_grid, pi_z, ReturnFn, Parameters, DiscountFactorParamNames, ReturnFnParamNames, vfoptions);
but for the construction (lines 12-20) of the PolicyIndexesPath:
% For this agent type, first go back through the value & policy fns.
% Then forwards through agent dist and agg vars.
if N_d>0
l_d=length(n_d);
PolicyIndexesPath=zeros(2,N_a,N_z,T-1,'gpuArray'); %Periods 1 to T-1
else
l_d=0;
PolicyIndexesPath=zeros(N_a,N_z,T-1,'gpuArray'); %Periods 1 to T-1
end
which is clearly expecting its policies to be strictly in Kronecker format.
Is this just old bad code from TransitionPath_InfHorz_PType_shooting that I mistakenly copied? I see that the FHorz shooting functions set up PolicyIndexesPath as things like:
if vfoptions.gridinterplayer==0
PolicyIndexesPath=zeros(l_d+l_aprime,N_a,N_z,N_j,T-1,'gpuArray'); %Periods 1 to T-1
elseif vfoptions.gridinterplayer==1
PolicyIndexesPath=zeros(l_d+l_aprime+1,N_a,N_z,N_j,T-1,'gpuArray'); %Periods 1 to T-1
end
If we drop the N_j for the InfHorz case, then we have a shape match where l_d is zero and l_aprime is 2, giving us the expected 2x51x51. I’m not using gridinterplayer for InfHorz.