sbenthall / SHARKFin

Simulating Heterogeneous Agents with Finance
7 stars 5 forks source link

Consolidate and document, and test build_population scripts #231

Closed sbenthall closed 1 year ago

sbenthall commented 1 year ago

I've been trying to work with the AgentPopulation.

When I try to solve() the most basic version of the AgentPopulation, I find that it takes a surprisingly long time to execute. Meaning ... I haven't actually seen it finish solving yet. It's been running for several minutes.

I wonder if @alanlujan91 can replicate this error? Maybe it's a configuration issue on my end?

$ ipython
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import simulate.parameters as params

In [2]: from HARK.ConsumptionSaving.ConsPortfolioModel import (SequentialPortfolioConsumerType)

In [4]: ap = params.build_population(SequentialPortfolioConsumerType, params.LUCAS0)

In [5]: ap.solve()
alanlujan91 commented 1 year ago

There are 1000 agents, all trying to solve the same problem. I thought we had settled on solving before exploding the population. I'll take a look.

alanlujan91 commented 1 year ago

There are 3 build_population methods in the codebase, in parameters.py, run_simulation.py, and run_whiteshark.py, we should probably settle on one and delete the others.

As for what I think should be the default build_population, in parameters.py, it does indeed solve the agents before exploding. So there is no need to solve again, especially because these agents all have the same solution.

So the point is, you don't have to ap.solve() after build_population.

alanlujan91 commented 1 year ago

https://github.com/sbenthall/SHARKFin/blob/874fd92b18a18652bb32a16beb98245ca554771d/simulate/parameters.py#L23-L26

sbenthall commented 1 year ago

Ah, yes, what you've said makes sense.

There are 3 build_population methods in the codebase, in parameters.py, run_simulation.py, and run_whiteshark.py, we should probably settle on one and delete the others.

That's a good point. Cleaning that up, and documenting the remaining one, would avoid this confusion. I think also the automated tests don't yet cover this method.

I've renamed this ticket to reflect and will reopen it, assigned to myself.