Skip to content
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

Make non-OO consumption-saving solvers #1394

Merged
merged 58 commits into from
Mar 27, 2024
Merged

Make non-OO consumption-saving solvers #1394

merged 58 commits into from
Mar 27, 2024

Commits on Mar 5, 2024

  1. Add simplified PF solver

    Adds a non-OO solve_one_period function for the ConsPerfectForesight model. Will do for the other solvers as well.
    
    The value function in the PF model isn't right when there's an artificial borrowing constraint (in current HARK). This commit makes it less wrong, but I don't think it's *right* yet.
    mnwhite committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    35c63b1 View commit details
    Browse the repository at this point in the history
  2. Add simplified based ConsIndShockSolver

    Still need to add CubicBool and vFuncBool options.
    mnwhite committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    3ed2e45 View commit details
    Browse the repository at this point in the history

Commits on Mar 6, 2024

  1. Configuration menu
    Copy the full SHA
    a3b3c78 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a3f3a6c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    34b7555 View commit details
    Browse the repository at this point in the history
  4. Add simplified ConsKinkedR solver

    This ended up 75 lines longer on net, but it's much easier to understand.
    mnwhite committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    3d92dd1 View commit details
    Browse the repository at this point in the history
  5. Run black again

    mnwhite committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    ab4b086 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    8faf1a1 View commit details
    Browse the repository at this point in the history
  7. Actually fix error properly

    mnwhite committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    8c4e060 View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2024

  1. Discrepancy actually due to indexing offset error

    Had an off-by-one error in the "coefficient hacking" line, creating a discrepancy in the fourth decimal place. Now fixed,
    mnwhite committed Mar 7, 2024
    Configuration menu
    Copy the full SHA
    f245acb View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2024

  1. Made basic ConsPortfolio simplified solver

    Matches behavior exactly for the default dictionary. Need to add vFunc functionality, then expand to discretized version.
    
    This commit has the new solver commented out in the type init method so as to not create a ton of new failing tests while it's still a WIP.
    mnwhite committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    747eeab View commit details
    Browse the repository at this point in the history
  2. Add vFunc capability to simplified portfolio solver

    Have not tested fixed share functionality, but I expect it works.
    mnwhite committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    45d645c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d9cda03 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2024

  1. Add discrete choice capability to simplified portfolio solver

    Still doesn't handle non-independent shock distributions.
    mnwhite committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    830764b View commit details
    Browse the repository at this point in the history
  2. Run black, move import line

    mnwhite committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    264186a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    936930a View commit details
    Browse the repository at this point in the history
  4. Add simple solver for ConsPrefShock

    This is where we really start to see that subfunctions for solvers really should be used, as this is almost entirely a copy-paste from ConsIndShock. The idea behind the OO solver encapsulation wasn't bad, but the resulting code was horrible.
    mnwhite committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    fb10736 View commit details
    Browse the repository at this point in the history
  5. More formatting nonsense

    mnwhite committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    f592a98 View commit details
    Browse the repository at this point in the history
  6. Make simple KinkyPrefShock solver

    This solver also makes clear that we need encapsulation within solution methods. That will happen after I've "flattened" everything.
    mnwhite committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    0dd9ab3 View commit details
    Browse the repository at this point in the history
  7. Actually use new KinkyPref solver

    Whoops.
    mnwhite committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    5c6a5a5 View commit details
    Browse the repository at this point in the history

Commits on Mar 12, 2024

  1. Make simple solver for ConsMarkovModel

    Value function capability has not been set up yet, will do on next commit. The Markov model code is where we see most clearly that the "timing change" will make everything better and easier to read. There's a *lot* of confusing stuff going on due to the fact that both t and t+1 activities are being handled by the period-t solver. Ugly.
    mnwhite committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    491a6f6 View commit details
    Browse the repository at this point in the history
  2. Fix formatting error and cubic interpolation typo

    Forgot to test CubicBool=True on prior commit, but there was only one tiny error, 3 character fix. Began to implement value function, but ran out of time.
    mnwhite committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    8d3cc8d View commit details
    Browse the repository at this point in the history

Commits on Mar 13, 2024

  1. Added vFunc capability to simple ConsMarkov solver

    Also fixed a bug/error in the existing vFunc code that made it incapable of actually solving. The good news is that the new code exactly replicates the old code. The bad news is that something is wrong with the vFunc extrapolation code, identically in both versions. Shouldn't be too hard to fix.
    mnwhite committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    00861e6 View commit details
    Browse the repository at this point in the history
  2. Resolve vFunc bug by suppressing extrapolation limit

    The math for the limiting linear function for the pseudo-inverse value function must not be correct, as that's what was causing the vFunc jump. It's been commented out for now.
    
    Need to look at whether the cFunc extrapolation code is correct for ConsMarkovModel.
    mnwhite committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    c6f8fc1 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ea15b11 View commit details
    Browse the repository at this point in the history
  4. Add simple solver for WarmGlowBequest

    This was very easy, basically a copy-paste of IndShock's simple solver with 3 lines added. Removed all the cubic and vFunc stuff to match current capability.
    mnwhite committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    056cbd6 View commit details
    Browse the repository at this point in the history
  5. Add simple solver for WarmGlowPortfolioModel

    I kept the vFunc and DiscreteShare capability in this solver, and looks like I could/should have left vFunc and CubicBool in the other one. Also found and fixed two bugs/typos in the existing code.
    mnwhite committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    1568878 View commit details
    Browse the repository at this point in the history
  6. Actually use new solver

    mnwhite committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    753df28 View commit details
    Browse the repository at this point in the history
  7. Missed one unneeded import

    mnwhite committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    ccbdd76 View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2024

  1. Add simple solver for ConsGenIncProcess

    I've tested it on the PersistentIncomeShock model, and it reproduces the solution exactly. Strangely, it's 5-6x *faster* than the existing code, even though I made this version by "flattening" the old version. That probably means there's a hidden loop of some kind that I (unknowingly) skipped over.
    
    Also: I think PersistentShockType doesn't initialize properly with default parameters. I'll look into it.
    mnwhite committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    f33f16d View commit details
    Browse the repository at this point in the history
  2. Remove unneeded imports

    mnwhite committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    9e014f0 View commit details
    Browse the repository at this point in the history

Commits on Mar 15, 2024

  1. First version of simple ConsRiskyAsset solver

    This version *only* has the non-independent distributions code, which turns out to be easier to adapt (when starting from the ConsIndShock solver). I will add the independent distributions version shortly. I also added cubic spline capability, but I'm slightly worried there's a small bug in it.
    
    Strangely, my "flat" code is again *much* faster than the current code: 10-12x faster. I have absolutely no idea why. The new non-independent solver is faster than the old independent solver.
    
    ALSO: The old independent solver doesn't generate the same solution as the non-independent solver. Some discrepancy is to be expected, but it's bigger than I expected.
    mnwhite committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    8b759b4 View commit details
    Browse the repository at this point in the history
  2. Value function works for ConsRiskyAsset

    It was trying to use broken values before.
    mnwhite committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    0a94ca7 View commit details
    Browse the repository at this point in the history
  3. Add independent distribution capability

    RiskyAsset simple solver can now handle IndepDstnBool=True. Solution is internally consistent with False version. Existing solver has a discrepancy between solutions.
    
    There's also a problem with independent distributions and CubicBool=True, but I'm out of work time today.
    mnwhite committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    28afed2 View commit details
    Browse the repository at this point in the history
  4. Fixed Cubic interpolation issue

    There was an errant point at aNrm=0, just had to remove it.
    mnwhite committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    1c3b683 View commit details
    Browse the repository at this point in the history

Commits on Mar 16, 2024

  1. Configuration menu
    Copy the full SHA
    7b4da9c View commit details
    Browse the repository at this point in the history

Commits on Mar 18, 2024

  1. Add simple solver for ConsMedShockModel

    The "medical shock" model now has a simple solver that replicates behavior of the existing solver. The current OO version's CubicBool capability is broken; it works in the new simple solver, but I haven't fixed it in the OO code.
    
    It looks like the tests for this model just make sure that it can run and simulate, but I've verified that the solution reproduces exactly on my own. As with other models, this solver runs faster than before, but not by as much: 0.5-2.5x faster.
    
    There are improvements and revisions to this model that should happen, but they're for another branch.
    mnwhite committed Mar 18, 2024
    Configuration menu
    Copy the full SHA
    bbdc412 View commit details
    Browse the repository at this point in the history

Commits on Mar 20, 2024

  1. Add vFunc and cubic capability to WarmGlowBequest

    I had cut this on a prior commit, but now that I've made other (small) improvements to other models, it seems fine to include it. It's almost entirely a copy-paste from ConsIndShock, as you would expect.
    mnwhite committed Mar 20, 2024
    Configuration menu
    Copy the full SHA
    f275116 View commit details
    Browse the repository at this point in the history
  2. Non-independent distributions for ConsPortfolioModel

    Last bit of functionality has been added to the simple solver for ConsPortfolioModel: non-independent income and return shocks. Value function differs slightly from legacy code, but that's because the old code does not construct end of period value function correctly (doesn't use CubicInterp).
    mnwhite committed Mar 20, 2024
    Configuration menu
    Copy the full SHA
    a4105a3 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    cf41a10 View commit details
    Browse the repository at this point in the history
  4. Now there was an extra tab

    mnwhite committed Mar 20, 2024
    Configuration menu
    Copy the full SHA
    260a3f1 View commit details
    Browse the repository at this point in the history

Commits on Mar 22, 2024

  1. Update CHANGELOG

    These updates include previously merged branches that didn't get entries. Whoops.
    mnwhite committed Mar 22, 2024
    Configuration menu
    Copy the full SHA
    ccf9c8a View commit details
    Browse the repository at this point in the history
  2. Begin moving OO solvers out of model files

    Had to move one very small agent type into its own file. It looks like it's a PortfolioConsumerType with a slightly different solver.
    mnwhite committed Mar 22, 2024
    Configuration menu
    Copy the full SHA
    561872e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6f9fc02 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    20352e6 View commit details
    Browse the repository at this point in the history

Commits on Mar 23, 2024

  1. Move more legacy code, fix more imports

    I said that this was like untangling rope, but it's more like brushing a badly groomed dog.
    mnwhite committed Mar 23, 2024
    Configuration menu
    Copy the full SHA
    715f845 View commit details
    Browse the repository at this point in the history
  2. Fix IndShockFast imports

    Redirect to another file.
    mnwhite committed Mar 23, 2024
    Configuration menu
    Copy the full SHA
    c0f76bb View commit details
    Browse the repository at this point in the history
  3. Remove ConsPortfolioJointDistSolver from tests

    This is now handled by the same solver: just set boolean flag and let it run.
    mnwhite committed Mar 23, 2024
    Configuration menu
    Copy the full SHA
    e2c38fb View commit details
    Browse the repository at this point in the history

Commits on Mar 25, 2024

  1. Add simple solver for alternate ConsPortfolio

    There used to be a special solver in ConsRiskyAssetModel.py that did the "basic" portfolio model, without discrete choice nor adjustment frictions. A simple solver of that kind has now been added.
    mnwhite committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    964894c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    eb96ab7 View commit details
    Browse the repository at this point in the history
  3. Formatting fixes

    mnwhite committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    736b424 View commit details
    Browse the repository at this point in the history
  4. Two tiny formatting fixes

    mnwhite committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    765be38 View commit details
    Browse the repository at this point in the history
  5. And again

    mnwhite committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    c1210e2 View commit details
    Browse the repository at this point in the history
  6. Restore fixed share type to ConsRiskyAssetModel

    There is now a "simple solver" for a model in which the risky share is *fixed* (but might vary by age), but is not necessarily 0 or 1. This previously existed, was temporarily exiled to a new file, and now has been restored.
    mnwhite committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    27c01ab View commit details
    Browse the repository at this point in the history
  7. Change import location

    mnwhite committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    4e0436c View commit details
    Browse the repository at this point in the history
  8. Even more formatting

    mnwhite committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    428ddd5 View commit details
    Browse the repository at this point in the history
  9. Lint loves linebreaks

    mnwhite committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    18c8f70 View commit details
    Browse the repository at this point in the history
  10. Update example notebooks

    Two very small compatibility changes
    mnwhite committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    b4583a8 View commit details
    Browse the repository at this point in the history