-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
WIP: BARK: Bellman Abstract Representation toolKit. #1186
Conversation
Looks like my current implementation uses some Python 3.9 features that are available in a different form in 3.8. |
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.
Look at estimagic for alternative optimizers https://github.com/OpenSourceEconomics/estimagic
They also have constraints https://estimagic.readthedocs.io/en/stable/how_to_guides/optimization/how_to_specify_constraints.html
Perhaps the demo notebook should be reversed; start with growth, then allocation, then consumption
…(works) and pi* values (doesn't work yet)
Codecov ReportBase: 73.62% // Head: 72.92% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #1186 +/- ##
==========================================
- Coverage 73.62% 72.92% -0.70%
==========================================
Files 72 74 +2
Lines 11509 12023 +514
==========================================
+ Hits 8473 8768 +295
- Misses 3036 3255 +219
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
If we use estimagic in one part of the library, we probably should use it throughout. I'd like to talk more during a meeting about what it would mean to tie HARK to these tools. |
Things seem to be working now. There is one remaining issue I'd like to discuss, which involves the case where a stage is defined with a pre-given value for pi* for some state value. This is used in the consumption problems for the point where m = 0, so c = 0, but because of a binding constraint. The 'optimal' utility in this case is negative infinity, and this complicates both numerical optimization and interpolation. The question is: in generality, is it safe to dispense with the role of shocks in these cases? It is straightforward to say, "if (input state) I hope we can discuss this in a meeting. |
I've meet their lead contributor, and they seem to be on their way to being part of NumFocus so I am sure they would be happy to see us use their tools and maybe even future collaboration. |
I think it's safe to dispense with the shocks, as well as anything else in the dynamics. At So for |
Thanks @alanlujan91 this is all very helpful. I've been digging a bit deeper into this and have a new take it. How it works in this PR. Whatever And during the growth stage, there are no actions, so setting Does this mean that for generic Bellman stages, it should be possible to add points to the input value function |
Correct. Presumably,
I think it would be useful to be able to add points to the input value function. This however could be a generic treatment of the borrowing constraint. Perhaps not true universally, but for a few models if we set |
Ok, I am adding in the capability to add arbitrary points to both I am now wondering how to handle this for the growth stage, which takes both However... the transition function for the growth stage is of the form |
You are correct. It depends on the exact income process; specifically on This is why the calculation for the natural borrowing constraint is recursive. Assume last period; minimum So the treatment at the boundary depends on both the income process and the imposition of a borrowing constraint. In the Portfolio choice model, the artificial borrowing constraint is 0, so it only depends on |
OK, thank you. Since I am trying to build magic solver technology, I think I should be expecting the natural borrowing constraint to show up in the output of the model. But the artificial borrowing constraint must be an input to the model. I do understand that much of the (different kind of) magic of the SolvingMicroDSOPs methodology is to use analytical model results to improve the computational solution. What I have not yet figured out is if there is a way to use an analytically derived natural borrowing constraint to improve a magic solver. |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
I would like to revisit this PR, which has been on hold for several months. I thought I would add some context, as well as some ideas for next steps, here, to inform any review. Moving forward, I'm going to refer to the whole approach here, based on Bellman blocks, as BARK, to disambiguate it from the many other HARK redesign proposals floating around. This PR is original research supported by NSF #2105301 and the Econ-ARK project. The goals of my efforts here have been to:
The core ideas represented in this PR are that:
I have been using the term 'stage' for the most basic of these blocks. I now regret this choice. Moving forward, I will take a line out of Pablo's book. There are two structural forms in BARK:
Renaming of variables to better fit pre-defined blocks together is accomplished through a simple This PR includes an almost complete implementation of BARK. I believe my next step before putting this aside a few months ago was to verify that it can produce results equivalent to HARK for the ConsIndShockModel. A few other notes:
The main reason I put BARK aside earlier is that @llorracc has been keen on the next HARK version being integrated with Dolang and I was aiming to support that effort. However, in recent conversations, it sounds like @albop is not convinced that Dolang is necessary to support @llorracc 's use case, and proposed building a pure Python API for structural lifecycle models instead. In that case, I propose that BARK might be a solution to @llorracc 's problems. I would be immensely grateful for any feedback from @albop on the BARK design, if only for my own edification. In any case, I don't have any immediate plans to integrate BARK with Dolang; I don't have a need for Dolang, personally -- I'm fine with defining models in software code, as long as it can be done modularly. I see a few paths forward for BARK and I'm wondering which one is best:
I currently don't see any tools out there that are better than BARK for what I need for my research, and I've recently gotten excited about ways to extend BARK to solve asset pricing problems (this would involve defining new kinds of blocks). I'd be happy to pick up a different tool if somebody pointed me to it. |
I'll add that one reason prefer the 'block' terminology is that it lines up with Bence's work on the Sequence Space Jacobian. While the current implementation of BARK uses only a linear sequence of blocks, I could imagine a system where blocks form a DAG for the individual agent's problem. I don't want to add to the scope of this PR at all, which is minimal. I'm just here suggesting where BARK would go, if it evolves where I think it should go. |
@sbenthall thanks for this cogent post. @dedwar65 is right now working on a revision to SolvingMicroDSOPs, with the particular ambition to remove all references to the antique Mathematica code. If BARK is ready to be used to implement all of the elements in the SolvingMicroDSOPs notebook, using it to do that would seem to be a natural next step for demonstrating how BARK can be used in practice. Having you and Decory work together on that in the near term seems like a good path forward, since he is more familiar with the math and economics and you have more expertise on coding. |
I'd be happy to work with @dedwar65 on that. |
…lit off (stub), HARK/BARK test
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1186 +/- ##
==========================================
- Coverage 73.43% 72.47% -0.96%
==========================================
Files 77 79 +2
Lines 12845 13331 +486
==========================================
+ Hits 9433 9662 +229
- Misses 3412 3669 +257
☔ View full report in Codecov by Sentry. |
This PR has been superseded by more recent work on 'blocks', which have made it into the repository. I still draw on this work a great deal in my more recent implementations, but this code won't make it into HARK, so closing the PR. |
This PR introduces a new module,
stage
, which contains the implementation of a class representing a general Bellman-form stage. This stage can be solved using a generic value iteration algorithm. Stages can be composed to form more complex problems. A notebook demonstrates how thestage
module can be used to create and solve a Portfolio Consumption problem. The current PR includes some basic tests.This is the start of a much larger project that addresses some points raised in several issues, such as #1116, #997, #620, among others. It is work in progress. However, the state of this PR is at a point where it would be great to get reviews.