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

Undocumented AgentType.solution property, with awkward interface #482

Closed
sbenthall opened this issue Jan 31, 2020 · 12 comments
Closed

Undocumented AgentType.solution property, with awkward interface #482

sbenthall opened this issue Jan 31, 2020 · 12 comments

Comments

@sbenthall
Copy link
Contributor

sbenthall commented Jan 31, 2020

A key property of AgentType, referred to in all the tutorial materials, is AgentType.solution.

This property is not initialized when a subclass of AgentType is created.
It is not documented.

Rather, it is set when the class's solve() method is ran.

self.solution = solveAgent(self, verbose) # Solve the model by backward induction

Maybe because it isn't well documented, the interface for accessing this solution is a bit complicated and obscure. This seems to be typical of the coding pattern to inspect a model solution:

print('Linear perfect foresight consumption function:')
mMin = PFexample.solution[0].mNrmMin
plotFuncs(PFexample.solution[0].cFunc,mMin,mMin+10.)

What type is solution[0]? There's no way to know from the documentation.

Documenting how this works will make HARK more usable.
It may also reveal a way to make this part of the interface smoother and more idiomatic for scientific python.

@sbenthall
Copy link
Contributor Author

sbenthall commented Feb 15, 2020

It looks like one reason why this feature remains undocumented is because there's a workaround method defined for some subclasses, unpackcFunc()

https://github.com/econ-ark/HARK/blob/master/HARK/ConsumptionSaving/ConsIndShockModel.py#L1683-L1702

With a little work, it should be possible to 'unpack' the solution automatically without an additional method call.

@llorracc
Copy link
Collaborator

llorracc commented Feb 15, 2020 via email

@mnwhite
Copy link
Contributor

mnwhite commented Feb 15, 2020 via email

@mnwhite
Copy link
Contributor

mnwhite commented Feb 15, 2020 via email

@llorracc
Copy link
Collaborator

llorracc commented Feb 15, 2020 via email

@mnwhite
Copy link
Contributor

mnwhite commented Feb 15, 2020 via email

@llorracc
Copy link
Collaborator

llorracc commented Feb 15, 2020 via email

@sbenthall
Copy link
Contributor Author

For comparison, this is where dolark's DecisionRule, which would generalize over cFunc, etc., is defined:
https://github.com/EconForge/dolark/blob/master/dolark/dolo_improvements.py

In my view, it would make things clearer if those functions that were about control variables, vs. those functions that performed some other role in the solution apparatus (vFunc?) were distinguished during AgentType configuration.

@mnwhite
Copy link
Contributor

mnwhite commented Feb 15, 2020 via email

@llorracc
Copy link
Collaborator

llorracc commented Feb 15, 2020 via email

@mnwhite
Copy link
Contributor

mnwhite commented Feb 15, 2020 via email

@sbenthall
Copy link
Contributor Author

I wonder if this issue can be revisited in light of what we are discussing in #798

I wonder what, in an ideal future where we've done some refactoring, the "solution" might look like.

My impression is that it:

  • Should look like a decision rule, in that it provides a rule for each control variable, conditional on the state and shock inputs available at that point of control
  • May also include other calculated properties of interest.

@MridulS MridulS closed this as completed Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants