Skip to content

Instantly share code, notes, and snippets.

@xalelax
Created October 26, 2020 13:22
Show Gist options
  • Select an option

  • Save xalelax/53271e90cf1f22adb5e2b17c9521fdd9 to your computer and use it in GitHub Desktop.

Select an option

Save xalelax/53271e90cf1f22adb5e2b17c9521fdd9 to your computer and use it in GitHub Desktop.
Simulate function for PRG model
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