<jupyter_start><jupyter_text>Register all estimated models with OrcaThis step takes the persisted models (.yaml files) in the /configs directory and makes them Python model objects that we can run in simulation.  The yaml files store model coefficients/settings.<jupyter_code>mm.initialize()<jupyter_output>Registering model step 'elcm5'
Registering model step 'tenure_choice_model'
Registering model step 'repm_sf_detached'
Registering model step 'repm_industrial'
Registering model step 'repm_duplex_townhome'
Registering model step 'elcm12'
Registering model step 'tenure_choice_model2'
Registering model step 'elcm6'
Registering model step 'tenure_choice_model1'
Registering model step 'elcm9'
Registering model step 'elcm1'
Registering model step 'elcm11'
Registering model step 'elcm2'
Registering model step 'repm_multifamily'
Registering model step 'elcm7'
Registering model step 'repm_retail'
Registering model step 'elcm10'
Registering model step 'elcm3'
Registering model step 'elcm8'
Registering model step 'elcm13'
Registering model step 'repm_residential'
Registering model step 'elcm15'
Registering model step 'elcm4'
Registering model step 'repm_office'
Registering model step 'hlcm2'
Registering model step 'household_relocation_choice_model'
Registering model step 'elcm14'
Registering mod[...]<jupyter_text>Optionally, fix the random seed for replicabilityMicrosimulation models like UrbanSim will display run-to-run variability in results if the random seed is allowed to vary (the default).   This can be useful for gauging the breadth of possible outcomes.  But fixing the random seed makes the result repeatable.<jupyter_code>np.random.seed(1)<jupyter_output><empty_output><jupyter_text>Initialize the network accessibility calculatorThis pre-processing step makes `pandana` accessibility queries run much faster.  Each parcel is associated with the nearest node, and node-to-node impedance distances within some buffer are pre-calculated.<jupyter_code>orca.run(['build_networks'])<jupyter_output>Running step 'build_networks'<jupyter_text>Household transitionIntroduce new households into the region to match control totals.Household control totals can be pretty arbitrarily detailed and can utilize any household table attributes.Notice the year argument passed to `orca.run`-  for control-total-based transition (as opposed to growth rate-based), a year is needed the model knows what targets to match.<jupyter_code>orca.run(['household_transition'], iter_vars=[2030])
len(orca.get_table('households').local.query('building_id == -1'))<jupyter_output><empty_output><jupyter_text>Building_id for new households will be set to -1 (an UrbanSim convention denoting "unplaced" status)<jupyter_code>orca.get_table('households').local.tail()<jupyter_output><empty_output><jupyter_text>Jobs transition Introduce new households into the region to match control totals.Employment control totals are typically segmented by sector.<jupyter_code>orca.run(['job_transition'], iter_vars=[2030])
orca.get_table('jobs').local.tail()
##  Where's the relocation models??
orca.run(['household_relocation_choice_model'])
orca.get_table('households').local.tail()
len(orca.get_table('households').local.query('building_id == -1'))
## Household tenure model
orca.get_table('households').tenure.value_counts()
orca.run(['tenure_choice_model1','tenure_choice_model2','tenure_choice_model3'])
orca.get_table('households').tenure.value_counts()
len(orca.get_table('households').local.query('building_id == -1'))
orca.run(['hlcm1', 'hlcm2'])
len(orca.get_table('households').local.query('building_id == -1'))
len(orca.get_table('jobs').local.query('building_id == -1'))
orca.run(['elcm1', 'elcm2', 'elcm3', 'elcm4', 'elcm5', 'elcm6',
   'elcm7', 'elcm8', 'elcm9', 'elcm10', 'elcm11', 'elcm12',
   'elcm13', 'elcm14'])
len(orca.get_table('jobs').local.query('building_id == -1'))
orca.run(['repm_sf_detached', 'repm_duplex_townhome', 'repm_multifamily',
                    'repm_industrial', 'repm_retail', 'repm_office'])
orca.run(['feasibility', 'residential_developer', 'non_residential_developer'])
feas = orca.get_table('feasibility').local.query('form=="residential"')  ## Summarize residential by zone_district_id
feas['zone_district_id'] = orca.get_table('parcels').zone_district_id
feas['zone_id'] = orca.get_table('parcels').zone_id
feas['profit_per_sqft'] = feas.max_profit / feas.residential_sqft
feas.groupby('zone_district_id').profit_per_sqft.mean()
## Try with residential REPM (craigslist), and then re-plot profitability surface
import geopandas as gpd
zone_geoms = gpd.read_file('data/zones/zones.geojson').set_index('zone_id')
zone_geoms['mean_profit_sqft'] = feas.groupby('zone_id').profit_per_sqft.mean()
zone_geoms['mean_profit_sqft'] = zone_geoms['mean_profit_sqft'].fillna(0)
%matplotlib inline
import matplotlib.pyplot as plt

f = plt.figure(figsize=(10, 8))
ax = f.gca()
kw = dict(column='mean_profit_sqft', k=6, cmap='YlGn', alpha=1, legend=True, edgecolor='gray', linewidth=0.3)
zone_geoms.plot(scheme='Quantiles', ax=ax, **kw)
ax.set_axis_off()
orca.add_injectable('forecast_year', 2011)
orca.run(['generate_indicators'])<jupyter_output>Running step 'generate_indicators'
Calculating sum_non_residential_sqft of buildings for parcels
Calculating sum_non_residential_sqft of buildings for zones
Disaggregating zone_id to buildings from parcels
Calculating number of jobs for zones
Disaggregating zone_id to jobs from parcels
Calculating number of households for zones
Disaggregating zone_id to households from parcels
Calculating sum_residential_units of buildings for zones
Calculating sum_job_spaces of buildings for zones
Calculating sum_residential_units of buildings for parcels
Calculating number of households for parcels
Calculating density of jobs for parcels
Calculating number of jobs for parcels
Calculating mean_income of households for parcels
Calculating density of buildings for parcels
Calculating number of buildings for parcels
Calculating density of households for parcels
Time to execute step 'generate_indicators': 13.16 s
Total time to execute iteration 1 with iteration value None: 13.16 s
{'fraction_non_alphanumeric': 0.10081433224755701, 'fraction_numerical': 0.013843648208469055, 'mean_word_length': 7.685997171145686, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '341353', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1895, 'n_words': 537, 'path': 'bayarea/Stepping_Through_Simulation.ipynb', 'repo_name': 'ual/bayarea', 'size': '6140'}