ExpAsset improvements#77
Conversation
|
Converting to draft, because it really depends on the PType/TPath pull request being accepted first. Once that is merged, I'll merge those changes into this, and it should reduce the changed file count from 58 to 38. |
|
In the PolicyInd2Val commands you write I get what you are doing, but this is wrong. n_d should not contain zeros (unless is simply is equal to a scalar zero). I assume it is something about you setting n_d incorrectly? |
|
ExpAsset does not need its own Kron and UnKron commands. |
|
I'm no longer creating an n_d with a zero in the first position. I'll look through my commits to see what I was thinking when I did that. I will resolve the conflicts newly created by your adoption. Thanks! |
|
Comment in |
|
the change to |
My history tells me that I hit this because I was setting n_d to scalar zero, and I was trying to make it robust in the case where zero might be an entry in a string of entries. I'll revert this (if you haven't already). |
Does this mean we need to modify the existing commands to overridethe |
|
Do you want to revert (and so remove) the change to [will help reduce size of the pull request so I can make further progress on it] |
Anything that is not the 'standard Case 1' uses 'Case 2' for Kron and UnKron. All the various different 'not standard' setups just involve slightly different inputs to the Case 2 Kron and UnKron. |
|
I just pushed which implements a lot of the experienceasset in FHorz TPath setup. It now works for It does not yet work for I did both simoptions.fastOLG=0 and simoptions.fastOLG=1 [you never want to use simoptions.fastOLG=0, it is really just there so the thing is coded twice as a way to check solutions are correct] I only did vfoptions.fastOLG=0, and did not do divide-and-conquer nor grid-interpolation-layer (nor the combo of both). I plan to do the fastOLG (including with DC and GI). And to do the TransitionPath_Case1_FHorz. But I figure there is enough progress there to push now. |
|
PS. The only test I ran so far was solving a 'nothing happens' transition path. That worked just fine (no d1, with z, no e). |
|
Excellent! I will take a deep breath and dive in. I see your UnKron Case2 patterns and will take guidance from them. |
Done. |
|
oops, missed a file, just added now |
New info: In TransitionPath_InfHorz_PType_ExpAsset_singlepath.m there's this call at line 84: As you can see, it creates an |
|
If I understand the question correctly the trick is to do |
The UnKornPolicyIndexes_Case2_FHorz function is defined with this signature: but called like this: You did say that the FHorz_TPath stuff is not yet working. This seems to be the first major sticking point my code has noticed, and it's far enough out of round that I'll await your guidance as to when I should proceed. I've commited the small change fixing calls to |
|
Bit of cheating. Using a function for things that were not it's original intent but which it does a nice job of. The UnKron Case2 was designed to take inputs (n_d,n_a,n_z,N_j) and then create output a Policy of size [length(n_d),n_a,n_z,N_j] I later realised this could be reused for all sorts of other things. For example in a model with any combo of d,a and complicated endo states, you can put an input in place of n_d that captures the actual things that can be chosen in that model. The other example is I realised if I input (n_d,N_a,N_z,N_j) then it essentially only unpacks the first dimension and leaves the rest in 'kron' form. The ones you are referring to are doing both those examples as once. Is a trick I picked up along the way that saved defining a new function. |
|
I've added a comment to the Case2 UnKron commands that mentions the second example. Will be included in my next push. Hopefully helps someone in future. |
|
got my first fastOLG case for VFI with experienceasset in FHorz TPath running also adds those comments I mentioned |
|
My problems trace back to this known problem I created for myself (in ValueFnIter_FHorz_TPath_SingleStep_ExpAsset_raw): I'll see whether the new comments help me solve this on my own, but I think I need your help handling the rem/ceil scissors. |
|
My guess as to what is going on. You have Policy as a joint-index, say for (d1,d2,a1prime) [this last is a guess] Likely what you are wanting to do is You would then set Policy3(1,:) to d1, Policy3(2,:) to d2, and Policy3(3,:) to a1prime. |
|
Thanks! I'll give it a go (after confirming that the joint index hypothesis is valid...I think it is but will check). |
|
It appears that Almost. My Policy has a first dimension of 7, but PolicyIndexesPath has a first dimension of 6. I'll see where the discrepancy is coming in. At least now I don't have the wrong number of dimensions. |
UnKron Case2 is only designed to handle when the index is joint. UnKron Case1 handles that it is one index for d (if any), one index for aprime, one index for L2index (if using grid interp layer). More likely, just don't covert joint index to Policy3, and instead pass to UnKron Case2. |
|
Looks like |
|
I made it to the end of my script in fast mode. First time in a while. Please see comments in latest commit (1201627). I will run larger test cases overnight. |
Now working for TPath (I think)!
A variety of potentially helpful ways to better use lowmemory with and without lowmemory==3.
This makes it through!
End-to-end success!
|
I adopted changes to you can revert changes are all part of |
|
TransitionPaths/InfHorz/subcodes/EvalFnOnAgentDist_TPath_SingleStep/EvalFnOnAgentDist_InfHorz_TPath_SingleStep_AggVars.m |
|
This is great--thanks! I'll be back on the tools Wednesday evening. Looking forward to it 😁 |
|
you can revert you can move all the |
|
I adopted a lot of the |
|
once you do a bunch of those, we can take a look at what is left |
The fixes I needed are now in master.
If there's a problem (such as `temp` being sparse), it's the caller's fault.
We now complete end-to-end for small model, small_z_no_e (with AgentDistOnTransPath_MixHorz_PType change coming).
We test Scenario=3 because Scenario=4 is too large for fastOLG.
Address some of these issues. Not out of the woods yet.
These are the changes to ExpAssets to enable a large model to use ExpAssets in a wider range of circumstances.
This is also a branch from which additional PType changes (and other changes) will be cherry-picked out for separate merging. When all those pre-requisites have been merged, this pull request should consist entirely of ExpAsset changes.
NOTE: Files such as
VFIToolkit-matlab\EvaluateFnOnAgentDist\TransPathFHorz\SubCodes\ExpAsset\EvalFnOnAgentDist_AggVars_FHorz_ExpAsset_fastOLG.mwhich come from code generators need to be modified to add the ExpAsset argument to thearrayfunfunction calls. I have manually fixed up thew few cases I have tested, but every call must be adjusted to use the ExpAsset.NOTE ALSO: I'm virtually certain I'm not calculating
Policy3correctly inVFIToolkit-matlab\TransitionPaths\FHorz\subcodes\ValueFnSingleStep\slowOLG\ExpAsset\ValueFnIter_FHorz_TPath_ExpAsset_SingleStep_raw.m(and similar). I could use help with my mod/ceil math at the end of the file. The calculations I do provide the correct shapes, but not the correct answers.