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

Remove apply_law_of_motion in simulate by selecting child indices with choices. #376

Open
tobiasraabe opened this issue Aug 17, 2020 · 0 comments
Labels
enhancement An addition or change to an existing feature.

Comments

@tobiasraabe
Copy link
Member

  • respy version used, if any: 2.0.0
  • Python version, if any: any
  • Operating System: any

What would you like to enhance and why? Is it related to an issue/problem?

When the decisions of individuals are simulated for one period in _simulate_single_period, we apply the law of motion to get the states of the next period in simulate. The law of motion takes the current choice and advances experiences, previous choices and the period. Then, we have to map the advanced states to their state space indices with map_observations_to_states to get information like wages, etc. from the state space and simulate decisions in the next period.

Describe the solution you'd like

As @mo2561057 noted in #373 (comment), we can take a short-cut.

  • In _simulate_single_period we have the current choice and the child indices. So, we can simply select the state space indices for the next period without using the law of motion.
  • _simulate_single_period could pass the child index along all other information back to _simulate. Then, the call to map_observations_to_states in simulate becomes obsolete.
  • Instead of current_df we could only pass the child indices to _simulate_single_period and the function collects the dataframe rows from the frames by itself.

Caveat

The general idea behind this change is to avoid costly computations especially when the law of motion is complex. At the same time, we are transforming an operation which is CPU bound to something which is IO bound because we have to read states from the disk. We need some testing and benchmarks to see where it pays off.

@tobiasraabe tobiasraabe added the enhancement An addition or change to an existing feature. label Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An addition or change to an existing feature.
Projects
None yet
Development

No branches or pull requests

1 participant