HARK
HARK copied to clipboard
HARK.algos
This PR aims to provide two general purpose algorithms for the optimization 'step' of consumer problems, with automated tests confirming their results replicate teh SolvingMicroDSOPs results to a high degree of precision.
I'm hoping that this:
- Provides automated tests that can used in further HARK 1.0 or Dolo integration work
- Offers examples of general purpose solution algorithms that are usable incrementally in HARK
- Perhaps, existing problem solutions can be refactored to use these algorithms, where appropriate. (Much like earlier solutions were refactored to use a general
expectations
method.) This provides an implementation path from HARK's current state to HARK 1.0. - These concrete examples can be workshoped with respect to their interface and notation,
- Perhaps, existing problem solutions can be refactored to use these algorithms, where appropriate. (Much like earlier solutions were refactored to use a general
It introduces two new subdirectories for HARK modules:
-
HARK.algos
is intended to contain general purpose algorithms, and their tests. C.f.dolo.algos
(link) -
HARK.gothic
is a direct copy/fork of thegothic_class
andresources
files from SolvingMicroDSOPs. These are used in the automated tests for the algorithms.
The two algorithms provided are:
- In
foc.py
, solving the optimal policy decision based on numerically solving the first order condition - In
egm.py
, solving the optimal policy decision analytically using EGM
As of this writing, there is a passing test for the optimal_policy_foc()
method. The substantive test for the EGM algorithm is still a work in progress. Most of this code is from the BARK PR #1186 . But what I have done here is separate out the algorithmic component, made it more general (see below), and provided more robust testing (relative to SolvingMicroDSOPs).
The algorithms provided generalize from BARK in that they do not depend on a Stage
object explicitly. Rather, they are stand-alone functions. However, they do rely on some notation that we've settled on in BARK. Notably, I'm following Sargent and Stachurski and using: $X$ for states, $Z$ for shocks, and $A$ for actions. I think this leaves $Y$ as a natural choice for post-states. I suppose that could be debated.
I believe these algorithms can be used in existing HARK solvers, allowing some hard-coded mathematical statements to be replaced with mathematical functions. I think that moving in this direction will make it easier to move HARK towards HARK 1.0 while maintaining backwards compatibility.
- [x] Tests for new functionality/models or Tests to reproduce the bug-fix in code.
- [x] Updated documentation of features that add new functionality.
- [x] Update CHANGELOG.md with major/minor changes.