def __init__(self): config = Baseline() config_changes = { 'description': 'Run REPM and HLCM with bidding choice only', 'models': [ "real_estate_price_model", "household_relocation_model", "household_location_choice_model_with_price_adj", ], # 'models_in_year': {2000: # [ "household_relocation_model_for_2000", # "household_location_choice_model_for_2000",] # }, 'years': (2001, 2001), } config.replace(config_changes) config["models_configuration"][ "household_location_choice_model_with_price_adj"] = {} config["models_configuration"]["household_location_choice_model_with_price_adj"]["controller"] = \ HouseholdLocationChoiceModelWithPriceAdjConfigurationCreator( location_set = "building", sampler = "opus_core.samplers.weighted_sampler", sample_size_locations = 50, input_index = 'hrm_index', # filter = 'building.unit_price', demand_string="demand", capacity_string = "urbansim_parcel.building.vacant_residential_units", nchunks=1, lottery_max_iterations=20 ).execute() # config['models_configuration']['household_location_choice_model_with_price_adj']['controller']['run']['arguments']['chunk_specification'] = "{'nchunks':1}" self.merge(config)
def __init__(self): config = Baseline() config_changes = { "description": "Run REPM and HLCM with bidding choice only", "models": [ "real_estate_price_model", "household_relocation_model", "household_location_choice_model_with_price_adj", ], # 'models_in_year': {2000: # [ "household_relocation_model_for_2000", # "household_location_choice_model_for_2000",] # }, "years": (2001, 2001), } config.replace(config_changes) config["models_configuration"]["household_location_choice_model_with_price_adj"] = {} config["models_configuration"]["household_location_choice_model_with_price_adj"][ "controller" ] = HouseholdLocationChoiceModelWithPriceAdjConfigurationCreator( location_set="building", sampler="opus_core.samplers.weighted_sampler", sample_size_locations=50, input_index="hrm_index", # filter = 'building.unit_price', demand_string="demand", capacity_string="urbansim_parcel.building.vacant_residential_units", nchunks=1, lottery_max_iterations=20, ).execute() # config['models_configuration']['household_location_choice_model_with_price_adj']['controller']['run']['arguments']['chunk_specification'] = "{'nchunks':1}" self.merge(config)
def __init__(self): config = Baseline() config_changes = { 'description':'assigning jobs to workers', 'models_in_year':{2001:[ "work_at_home_choice_model",], 2002:[ "workplace_choice_model_for_resident" ] }, 'years': (2001,2002), 'datasets_to_cache_after_each_model':['person'], } config.replace(config_changes) self.merge(config) self['models_configuration']['work_at_home_choice_model']['controller']['run']['arguments']['run_choice_model'] = False self['models_configuration']['work_at_home_choice_model']['controller']['run']['arguments']['choose_job_only_in_residence_zone'] = False
def __init__(self): config = Baseline() config_changes = { 'description': 'assigning jobs to workers', 'models': [ #"process_pipeline_events", "real_estate_price_model", "expected_sale_price_model", "development_proposal_choice_model", "building_construction_model", "household_transition_model", "employment_transition_model", "household_relocation_model", "household_location_choice_model", "employment_relocation_model", { "employment_location_choice_model": { 'group_members': '_all_' } }, "work_at_home_choice_model", "workplace_choice_model_for_resident", 'distribute_unplaced_jobs_model' ], # {2001:[ "work_at_home_choice_model",], # 2002:[ "workplace_choice_model_for_resident" ] }, 'years': (2001, 2006), # 'datasets_to_cache_after_each_model':['person'], } from psrc.configs.create_travel_model_configuration import create_travel_model_configuration travel_model_configuration = create_travel_model_configuration( 'baseline_travel_model_psrc_2008_lmwang', emme2_batch_file='MODEL1-0.BAT', mode='full', years_to_run={ 2005: '2006_v1.0aTG', 2010: '2010_v1.0aTG', 2015: '2010_v1.0aTG_2015', 2020: '2020_v1.0aTG' }) config['travel_model_configuration'] = travel_model_configuration config.replace(config_changes) self.merge(config)
def __init__(self): config = Baseline() config_changes = { 'description':'assigning jobs to workers', 'models_in_year':{2001:[ "work_at_home_choice_model",], 2002:[ "workplace_choice_model_for_resident" ] }, 'years': (2001,2002), 'datasets_to_cache_after_each_model':['person'], } config.replace(config_changes) self.merge(config) self['models_configuration']['work_at_home_choice_model']['controller']['run']['arguments']['run_choice_model'] = True self['models_configuration']['work_at_home_choice_model']['controller']['run']['arguments']['choose_job_only_in_residence_zone'] = True self['models_configuration']['work_at_home_choice_model']['controller']['init']['arguments']['filter'] = "'job.building_type==2'" self['models_configuration']['work_at_home_choice_model']['controller']['prepare_for_run']['arguments']['agents_filter'] = "'urbansim_parcel.person.is_worker'" self['models_configuration']['workplace_choice_model_for_resident']['controller']['init']['arguments']["run_config"].merge({"capacity_string":"job.building_type==1"}) self['models_configuration']['workplace_choice_model_for_resident']['controller']['init']['arguments']["filter"] = "'job.building_type==1'" self['models_configuration']['workplace_choice_model_for_resident']['controller']['run']['arguments']["agents_filter"] = "'urbansim_parcel.person.is_non_home_based_worker'" self['models_configuration']['workplace_choice_model_for_resident']['controller']['run']['arguments']["chunk_specification"] = "{'records_per_chunk':20000}"
def __init__(self): config = Baseline() config_changes = { 'description': 'assigning jobs to workers', 'models_in_year': { 2001: [ "work_at_home_choice_model", ], 2002: ["workplace_choice_model_for_resident"] }, 'years': (2001, 2002), 'datasets_to_cache_after_each_model': ['person'], } config.replace(config_changes) self.merge(config) self['models_configuration']['work_at_home_choice_model'][ 'controller']['run']['arguments']['run_choice_model'] = False self['models_configuration']['work_at_home_choice_model'][ 'controller']['run']['arguments'][ 'choose_job_only_in_residence_zone'] = False
def __init__(self): config = Baseline() config_changes = { 'description':'assigning jobs to workers', 'models':[ #"process_pipeline_events", "real_estate_price_model", "expected_sale_price_model", "development_proposal_choice_model", "building_construction_model", "household_transition_model", "employment_transition_model", "household_relocation_model", "household_location_choice_model", "employment_relocation_model", {"employment_location_choice_model":{'group_members': '_all_'}}, "work_at_home_choice_model", "workplace_choice_model_for_resident", 'distribute_unplaced_jobs_model' ], # {2001:[ "work_at_home_choice_model",], # 2002:[ "workplace_choice_model_for_resident" ] }, 'years': (2001,2006), # 'datasets_to_cache_after_each_model':['person'], } from psrc.configs.create_travel_model_configuration import create_travel_model_configuration travel_model_configuration = create_travel_model_configuration('baseline_travel_model_psrc_2008_lmwang', emme2_batch_file='MODEL1-0.BAT', mode='full', years_to_run={2005: '2006_v1.0aTG', 2010: '2010_v1.0aTG', 2015: '2010_v1.0aTG_2015', 2020: '2020_v1.0aTG'}) config['travel_model_configuration'] = travel_model_configuration config.replace(config_changes) self.merge(config)
'person_id': arange(len(hh_ids)) + 1, 'household_id': array(hh_ids), 'member_id': array(member_ids), 'is_worker': array(is_worker), 'job_id': array(job_ids), }, ) persons = PersonDataset(in_storage=in_storage, in_table_name=persons_table_name) persons.write_dataset(out_storage=out_storage, out_table_name=persons_table_name) if __name__ == '__main__': config = Baseline() config.replace( { 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name='psrc_2005_parcel_baseyear', ), 'estimation_database_configuration': EstimationDatabaseConfiguration( database_name='psrc_2005_parcel_baseyear_change_20080219', ), 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['urbansim_parcel', 'urbansim', 'opus_core'], ), 'low_memory_mode': False, 'cache_directory': '/urbansim_cache/psrc_parcel/persons',
in_storage.write_table( table_name=persons_table_name, table_data={ 'person_id':arange(len(hh_ids))+1, 'household_id':array(hh_ids), 'member_id':array(member_ids), 'is_worker':array(is_worker), 'job_id':array(job_ids), }, ) persons = PersonDataset(in_storage=in_storage, in_table_name=persons_table_name) persons.write_dataset(out_storage=out_storage, out_table_name=persons_table_name) if __name__ == '__main__': config = Baseline() config.replace({ 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name = 'psrc_2005_parcel_baseyear', ), 'estimation_database_configuration': EstimationDatabaseConfiguration( database_name = 'psrc_2005_parcel_baseyear_change_20080219', ), 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['urbansim_parcel','urbansim', 'opus_core'], ), 'low_memory_mode': False, 'cache_directory': '/urbansim_cache/psrc_parcel/persons', 'debuglevel':7, 'base_year': 2000, 'years': (2000,2000),
def __init__(self): config = PsrcParcelConfiguration() config[ 'creating_baseyear_cache_configuration'].cache_directory_root = r'/Users/hana/urbansim_cache/psrc/data_preparation/run_zipcodes' config[ 'creating_baseyear_cache_configuration'].baseyear_cache.existing_cache_to_copy = r'/Users/hana/urbansim_cache/psrc/data_preparation/cache_for_zipcodes' #config['scenario_database_configuration'].database_name = 'psrc_2005_parcel_baseyear_data_prep_start' config[ 'scenario_database_configuration'].database_name = 'psrc_2005_parcel_baseyear_data_prep_business_zip' config_changes = { 'description': 'data preparation for PSRC parcel (buildings)', 'flush_variables': False, 'cache_directory': '/Users/hana/urbansim_cache/psrc/data_preparation/cache_for_zipcodes', 'dataset_pool_configuration': DatasetPoolConfiguration(package_order=[ 'psrc_parcel', 'urbansim_parcel', 'urbansim', 'opus_core' ], ), 'base_year': 2000, 'years': (2001, 2003), 'models_in_year': { 2001: [ "employment_relocation_model", { "employment_location_choice_model": { "group_members": "_all_" } } ], 2002: [ "employment_relocation_model", "governmental_employment_location_choice_model", ], 2003: [ "employment_relocation_model", "governmental_employment_location_choice_model_without_filter" ] }, "datasets_to_preload": { 'zone': {}, 'job': {}, 'building': {}, "job_building_type": {}, "zipcode": {} }, "datasets_to_cache_after_each_model": ['parcel', 'building', 'job'] } #use configuration in config as defaults and merge with config_changes config.replace(config_changes) self.merge(config) self['models_configuration'][ 'non_home_based_employment_location_choice_model'] = {} self['models_configuration']['non_home_based_employment_location_choice_model']['controller'] = \ EmploymentLocationChoiceModelByZipcodesConfigurationCreator( location_set = "building", input_index = 'erm_index', sampler = None, records_per_chunk = 3000, capacity_string = "urbansim_parcel.building.vacant_non_home_based_job_space", number_of_units_string = None, lottery_max_iterations=30 ).execute() self['models_configuration'][ 'governmental_employment_location_choice_model'] = {} self['models_configuration']['governmental_employment_location_choice_model']['controller'] = \ ScalingJobsModelByZipcodesConfigurationCreator( location_set = "building", input_index = 'erm_index', filter = "urbansim_parcel.building.is_governmental" ).execute() self['models_configuration']['governmental_employment_location_choice_model_without_filter'] = {} self['models_configuration']['governmental_employment_location_choice_model_without_filter']['controller'] = \ ScalingJobsModelByZipcodesConfigurationCreator( location_set = "building", input_index = 'erm_index', ).execute() self['models_configuration'][ 'home_based_employment_location_choice_model'] = {} self['models_configuration']['home_based_employment_location_choice_model']['controller'] = \ EmploymentLocationChoiceModelByZipcodesConfigurationCreator( location_set = "building", input_index = 'erm_index', sampler = None, capacity_string = "urbansim_parcel.building.vacant_home_based_job_space", number_of_units_string = None, lottery_max_iterations=30 ).execute() self['models_configuration']['employment_relocation_model']['controller'] = \ EmploymentRelocationModelConfigurationCreator( location_id_name = 'building_id', probabilities = None, rate_table=None, output_index = 'erm_index').execute()
def __init__(self): config = PsrcParcelConfiguration() config['creating_baseyear_cache_configuration'].cache_directory_root = r'/Users/hana/urbansim_cache/psrc/data_preparation/run' config['creating_baseyear_cache_configuration'].baseyear_cache.existing_cache_to_copy = r'/Users/hana/urbansim_cache/psrc/data_preparation/cache_tmp' config['scenario_database_configuration'].database_name = 'psrc_2005_parcel_baseyear_data_prep_start' config_changes = { 'description':'data preparation for PSRC parcel (buildings)', 'flush_variables': False, 'cache_directory': '/Users/hana/urbansim_cache/psrc/data_preparation/cache', 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['psrc_parcel', 'urbansim_parcel', 'urbansim', 'opus_core'], ), 'base_year':2000, 'years':(2001, 2005), 'models_in_year': { 2001: # Step 2 (Create new residential buildings) [ "real_estate_price_model", "expected_sale_price_model", "development_proposal_choice_model", "building_construction_model", ], 2002: # Step 3 (Assign buildings to households) [ "household_relocation_model", "household_location_choice_model", ], 2003: # Step 4 (Assign buildings to jobs with known parcel_id) [ 'assign_buildings_to_jobs' ], 2004: # Step 5 (Create new non-residential buildings) [ "expected_sale_price_model", "development_proposal_choice_model_nr", "building_construction_model", ], 2005: # Step 6 (Assign buildings to remaining jobs) [ "employment_relocation_model", {"employment_location_choice_model": {"group_members": "_all_" }}, "employment_relocation_model", "governmental_employment_location_choice_model_without_filter" ] }, "datasets_to_preload":{ 'zone':{}, 'household':{}, 'job': {}, 'building': {}, 'parcel': {}, "job_building_type":{}, #'development_project_proposal': {} }, #"low_memory_mode": True, "datasets_to_cache_after_each_model": [ 'parcel', 'building', 'development_project_proposal', 'household', 'job', 'development_project_proposal_component' ] } #use configuration in config as defaults and merge with config_changes config.replace(config_changes) self.merge(config) self['models_configuration']['development_proposal_choice_model']['controller']["import"] = { "psrc_parcel.models.development_proposal_sampling_model_by_zones": "DevelopmentProposalSamplingModelByZones" } self['models_configuration']['development_proposal_choice_model']['controller']["init"]["name"] =\ "DevelopmentProposalSamplingModelByZones" self['models_configuration']['development_proposal_choice_model']['controller']['run']['arguments']["zones"] = 'zone' self['models_configuration']['development_proposal_choice_model']['controller']['run']['arguments']["type"] = "'residential'" self['models_configuration']['development_proposal_choice_model']['controller']['run']['arguments']["n"] = 50 self['models_configuration']['development_proposal_choice_model_nr'] = Configuration(self['models_configuration']['development_proposal_choice_model']) self['models_configuration']['development_proposal_choice_model_nr']['controller']['run']['arguments']["type"] = "'non_residential'" self['models_configuration']['expected_sale_price_model']['controller']["prepare_for_run"]['arguments']["parcel_filter_for_redevelopment"] = None #self['models_configuration']['expected_sale_price_model']['controller']["prepare_for_run"]['arguments']["create_proposal_set"] = False self['models_configuration']['expected_sale_price_model']['controller']["run"]['arguments']["chunk_specification"] = "{'nchunks': 5}" #self['models_configuration']['building_construction_model']['controller']["run"]['arguments']["consider_amount_built_in_parcels"] = False self['models_configuration']['building_construction_model']['controller']['run']['arguments']["current_year"] = 2000 self['models_configuration']['household_location_choice_model'] = {} self['models_configuration']['household_location_choice_model']['controller'] = \ HouseholdLocationChoiceModelByZonesConfigurationCreator( location_set = "building", sampler = None, input_index = 'hrm_index', capacity_string = "urbansim_parcel.building.vacant_residential_units", number_of_units_string = None, nchunks=1, lottery_max_iterations=20 ).execute() self['models_configuration']['household_relocation_model']['controller'] = \ HouseholdRelocationModelConfigurationCreator( location_id_name = 'building_id', probabilities = None, rate_table=None, output_index = 'hrm_index').execute() self['models_configuration']['non_home_based_employment_location_choice_model'] = {} self['models_configuration']['non_home_based_employment_location_choice_model']['controller'] = \ EmploymentLocationChoiceModelByZonesConfigurationCreator( location_set = "building", input_index = 'erm_index', sampler = None, capacity_string = "urbansim_parcel.building.vacant_non_home_based_job_space", number_of_units_string = None, lottery_max_iterations=30 ).execute() self['models_configuration']['governmental_employment_location_choice_model'] = {} self['models_configuration']['governmental_employment_location_choice_model']['controller'] = \ ScalingJobsModelByZonesConfigurationCreator( location_set = "building", input_index = 'erm_index', filter = "urbansim_parcel.building.is_governmental" ).execute() self['models_configuration']['governmental_employment_location_choice_model_without_filter'] = {} self['models_configuration']['governmental_employment_location_choice_model_without_filter']['controller'] = \ ScalingJobsModelByZonesConfigurationCreator( location_set = "building", input_index = 'erm_index', ).execute() self['models_configuration']['home_based_employment_location_choice_model'] = {} self['models_configuration']['home_based_employment_location_choice_model']['controller'] = \ EmploymentLocationChoiceModelByZonesConfigurationCreator( location_set = "building", input_index = 'erm_index', sampler = None, capacity_string = "urbansim_parcel.building.vacant_home_based_job_space", number_of_units_string = None, lottery_max_iterations=30 ).execute() self['models_configuration']['employment_relocation_model']['controller'] = \ EmploymentRelocationModelConfigurationCreator( location_id_name = 'building_id', probabilities = None, rate_table=None, output_index = 'erm_index').execute() self['models_configuration']['assign_buildings_to_jobs'] = {} self['models_configuration']['assign_buildings_to_jobs']['controller'] = { "import": { "psrc_parcel.data_preparation.assign_bldgs_to_jobs_when_multiple_bldgs_in_parcel": "RunAssignBldgsToJobs" }, "init": { "name": "RunAssignBldgsToJobs" }, "run": { "arguments": { "job_dataset": "job", "dataset_pool": "dataset_pool"} } }
'repm': ['real_estate_price_model', 'psrc_parcel.estimation.repm_specification', None], 'wcm' : ['workplace_choice_model_for_resident', 'wcm_specification', None], 'wahcm': ['work_at_home_choice_model', 'wahcm_specification', None], 'dppcm': ['development_project_proposal_choice_model', 'dppcm_specification', None] } if __name__ == '__main__': try: import wingdbstub except: pass model = 'hlcm' #model = 'elcm-non-home-based' #model = 'elcm-home_based' #model = 'repm' #model = 'wcm' #model = 'wahcm' #model = 'dppcm' config = Baseline() if 'models_in_year' in config.keys(): del config['models_in_year'] config.merge(my_configuration) config['config_changes_for_estimation'] = ConfigChangesForEstimation() ## set base_year and years to 2006 for HLCM for the psrc_parcel project config['config_changes_for_estimation']['household_location_choice_model'].merge({'base_year': 2006, 'years':(2006, 2006)}) er = EstimationRunner(models[model][0], specification_module=models[model][1], model_group=models[model][2], configuration=config, save_estimation_results=False) er.estimate() #er.predict() #er.create_prediction_success_table(geography_id_expression='choice.is_chosen')
def __init__(self): config = PsrcParcelConfiguration() config['creating_baseyear_cache_configuration'].cache_directory_root = r'/Users/hana/urbansim_cache/psrc/data_preparation/run_zipcodes' config['creating_baseyear_cache_configuration'].baseyear_cache.existing_cache_to_copy = r'/Users/hana/urbansim_cache/psrc/data_preparation/cache_for_zipcodes' #config['scenario_database_configuration'].database_name = 'psrc_2005_parcel_baseyear_data_prep_start' config['scenario_database_configuration'].database_name = 'psrc_2005_parcel_baseyear_data_prep_business_zip' config_changes = { 'description':'data preparation for PSRC parcel (buildings)', 'flush_variables': False, 'cache_directory': '/Users/hana/urbansim_cache/psrc/data_preparation/cache_for_zipcodes', 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['psrc_parcel', 'urbansim_parcel', 'urbansim', 'opus_core'], ), 'base_year':2000, 'years':(2001, 2003), 'models_in_year': { 2001: [ "employment_relocation_model", {"employment_location_choice_model": {"group_members": "_all_" }} ], 2002: [ "employment_relocation_model", "governmental_employment_location_choice_model", ], 2003: [ "employment_relocation_model", "governmental_employment_location_choice_model_without_filter" ] }, "datasets_to_preload":{ 'zone':{}, 'job': {}, 'building': {}, "job_building_type":{}, "zipcode": {} }, "datasets_to_cache_after_each_model": [ 'parcel', 'building', 'job' ] } #use configuration in config as defaults and merge with config_changes config.replace(config_changes) self.merge(config) self['models_configuration']['non_home_based_employment_location_choice_model'] = {} self['models_configuration']['non_home_based_employment_location_choice_model']['controller'] = \ EmploymentLocationChoiceModelByZipcodesConfigurationCreator( location_set = "building", input_index = 'erm_index', sampler = None, records_per_chunk = 3000, capacity_string = "urbansim_parcel.building.vacant_non_home_based_job_space", number_of_units_string = None, lottery_max_iterations=30 ).execute() self['models_configuration']['governmental_employment_location_choice_model'] = {} self['models_configuration']['governmental_employment_location_choice_model']['controller'] = \ ScalingJobsModelByZipcodesConfigurationCreator( location_set = "building", input_index = 'erm_index', filter = "urbansim_parcel.building.is_governmental" ).execute() self['models_configuration']['governmental_employment_location_choice_model_without_filter'] = {} self['models_configuration']['governmental_employment_location_choice_model_without_filter']['controller'] = \ ScalingJobsModelByZipcodesConfigurationCreator( location_set = "building", input_index = 'erm_index', ).execute() self['models_configuration']['home_based_employment_location_choice_model'] = {} self['models_configuration']['home_based_employment_location_choice_model']['controller'] = \ EmploymentLocationChoiceModelByZipcodesConfigurationCreator( location_set = "building", input_index = 'erm_index', sampler = None, capacity_string = "urbansim_parcel.building.vacant_home_based_job_space", number_of_units_string = None, lottery_max_iterations=30 ).execute() self['models_configuration']['employment_relocation_model']['controller'] = \ EmploymentRelocationModelConfigurationCreator( location_id_name = 'building_id', probabilities = None, rate_table=None, output_index = 'erm_index').execute()