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

Unwind type dependencies in initialization #1537

Open
mnwhite opened this issue Feb 25, 2025 · 1 comment
Open

Unwind type dependencies in initialization #1537

mnwhite opened this issue Feb 25, 2025 · 1 comment
Labels
Version: 0.17 issue for next next release

Comments

@mnwhite
Copy link
Contributor

mnwhite commented Feb 25, 2025

This issue has been reproduced from communications among team members. Unlike normal issues, this communication happened after the programming work had been done, to document that it was done. So it's an "issue" that already has a corresponding PR.


MNWHITE writes:

The gist is that literally all __init__ methods for AgentType subclasses are now removed. They all use the same init method inherited from AgentType itself, with no special code being run. Subclasses now have a standard default_ dictionary with entries for parameters and solver, which is automatically used during initialization. All of the instance-specific time_inv and time_vary material has been removed, so that they should be more or less static (but still defined at the instance level, copied from class-level time_inv_ and time_vary_. Solution objects that are unpacked will still be added to time_vary, I think.

To improve debugging capability, it's now possible to pass the argument construct=False to the init method, which prevents any of the constructor functions from being run. As is, if you have a faulty constructor, or pass invalid inputs for a constructor, an AgentType might fail to initialize at all because an error is thrown during its call to construct. That prevents the user from inspecting the work that the instance was able to accomplish before that error. With the new functionality, a user can tell their AgentType instance "here are some parameters, but don't try to do anything with them; please just exist." They can then call construct sequentially on individual constructed inputs, inspect the results, and see how the error is occuring.

To the long-running problem of students / new users changing (e.g.) PermShkStd and then being surprised when the solution doesn't change when they solve the model again, we can add a couple lines that add similar functionality. See the separate work item I'm adding in a moment for the more comprehensive solution to that problem.

This work has been completed in #1529 , with a small extension in #1530

@mnwhite mnwhite added the Version: 0.17 issue for next next release label Feb 25, 2025
@mnwhite
Copy link
Contributor Author

mnwhite commented Feb 25, 2025

Those PRs also take care of another very closely related work item: making sure all appropriate model objects are built with a constructor function and not an class method. I.e. they can all be changed without making a new subclass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Version: 0.17 issue for next next release
Projects
None yet
Development

No branches or pull requests

1 participant