Created
October 26, 2020 13:22
-
-
Save xalelax/53271e90cf1f22adb5e2b17c9521fdd9 to your computer and use it in GitHub Desktop.
Simulate function for PRG model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from model import Company | |
| def simulate_sample_company(n_steps, **kwargs): | |
| """ | |
| Runs a model for n_steps and returns a pandas.DataFrame | |
| containing the data collected at each step. | |
| kwargs are forwarded to init of company. | |
| """ | |
| model = Company(**kwargs) | |
| for i in range(n_steps): | |
| model.step() | |
| df = model.data_collector.get_model_vars_dataframe().copy() | |
| df['i'] = df.index | |
| df['competency_mechanism'] = model.competency_mechanism | |
| df['promotion_strategy'] = model.promotion_strategy | |
| df['year'] = df['i'] * model.timestep_years | |
| return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment