-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Wealth portfolio solver #1404
Update Wealth portfolio solver #1404
Conversation
It looks like this PR makes changes to ConsIndShock as well, moving some functions out of the solver. Looking through that, there's at least one actual code change, to |
Am in agreement with Matt. But maybe to prevent confusion for future users, the name of MPCmaxNow should be changed to something like |
This PR builds on #1395, so it's more appropriate to discuss MPC constructions there and leave this for later |
cNrm_now = np.empty_like(aNrmGrid) | ||
|
||
for a_idx, a_nrm in enumerate(aNrmGrid): | ||
cNrm_guess = euler( | ||
aNrmGrid, | ||
a_nrm, | ||
CRRA, | ||
WealthShare, | ||
WealthShift, | ||
end_dvda_now[a_idx], | ||
) | ||
|
||
self.solution.shareEndFunc = self.shareEndFunc | ||
lower_bound = aNrmGrid[cNrm_guess > 0][-1] | ||
upper_bound = aNrmGrid[cNrm_guess < 0][0] | ||
|
||
def solve(self): | ||
# Make arrays of end-of-period assets and end-of-period marginal values | ||
self.prepare_to_calc_EndOfPrd() | ||
if self.method in ["root", "fxp"]: | ||
self.calc_EndOfPrdvP() | ||
elif self.method == "max": | ||
self.calc_EndOfPrdv() | ||
result = root_scalar( | ||
euler, | ||
method="toms748", | ||
bracket=[lower_bound, upper_bound], | ||
args=(a_nrm, CRRA, WealthShare, WealthShift, end_dvda_now[a_idx]), | ||
) | ||
|
||
# Construct a basic solution for this period | ||
self.prepare_to_optimize_share() | ||
self.optimize_risky_share() | ||
cNrm_now[a_idx] = result.root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mnwhite could you give me your thoughts on this re-worked solver?
This problem does not have an invertible euler equation, so I instead try to do root-finding
everything else should be the same as the simple portfolio problem, and I have confirmed that when WealthShare=0.0, it is indeed the same result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be easier to just see the solver rather than try to see the diffs
This is on my immediate list. |
@mnwhite can you take a look now? |
Deleted some comments that were not valid anymore (about defining functions, which is done outside the solver). Added two TODOs, explained in comments on PR thread.
I haven't gone through every single line of math in the auxiliary functions, but I have three pieces of feedback on the solution method:
|
|
Please ensure your pull request adheres to the following guidelines: