def __init__(self, cache_directory_root = mktemp(prefix='opus_tmp'), cache_scenario_database = 'opus_core.cache.cache_scenario_database', cache_from_database = True, baseyear_cache = None, existing_cache_to_copy = None, years_to_cache = BaseyearCacheConfiguration.ALL_YEARS, tables_to_cache = [], tables_to_cache_nchunks = {}, tables_to_copy_to_previous_years = {}, scenario_database_configuration = None, ): if (baseyear_cache is None) and existing_cache_to_copy: baseyear_cache = BaseyearCacheConfiguration(existing_cache_to_copy, years_to_cache=years_to_cache) if baseyear_cache is None and not cache_from_database: raise TypeError("Parameter 'baseyear_cache' must be specified if " "parameter 'cache_from_database' is not True!") self.scenario_database_configuration = scenario_database_configuration self.baseyear_cache = baseyear_cache self.cache_directory_root = cache_directory_root self.cache_from_database = cache_from_database self.cache_scenario_database = cache_scenario_database self.tables_to_cache = tables_to_cache self.tables_to_cache_nchunks = tables_to_cache_nchunks self.tables_to_copy_to_previous_years = tables_to_copy_to_previous_years
def __my_configuration(self): tables_to_cache = [ # 'business', 'households', 'buildings', 'parcels', 'zones', # "households_for_estimation" ] return { 'cache_directory' : r'/home/lmwang/work/sf/cache_source_0125', # change or leave out 'creating_baseyear_cache_configuration':CreatingBaseyearCacheConfiguration( # cache_directory_root = '/tmp/urbcache/sandbox_runs/estimation', unroll_gridcells = False, cache_from_database = True, baseyear_cache = BaseyearCacheConfiguration( existing_cache_to_copy = r'/urbansim_cache/sanfrancisco/cache_source', ), cache_scenario_database = 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache = tables_to_cache, tables_to_copy_to_previous_years = {}, ), 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name = 'sanfrancisco_baseyear_start', ), 'estimation_database_configuration': EstimationDatabaseConfiguration( database_name = 'sanfrancisco_baseyear_change_20080121', ), 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['sanfrancisco', 'urbansim', 'opus_core'], ), 'base_year': 2001, }
def __my_configuration(self): tables_to_cache = Baseline( )['creating_baseyear_cache_configuration'].tables_to_cache tables_to_cache.append('workers_for_estimation') return { 'cache_directory': 'D:/urbansim_cache/psrc/estimation', # change or leave out 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( # cache_directory_root = '/tmp/urbcache/sandbox_runs/estimation', unroll_gridcells=True, cache_from_database=True, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy=r'D:/urbansim_cache/full_psrc', ), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache=tables_to_cache, tables_to_cache_nchunks={ 'parcels': 4, 'gridcells': 5 }, tables_to_copy_to_previous_years={}, ), 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name='GSPSRC_2000_baseyear_change_20070102', ), 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['psrc', 'urbansim', 'opus_core'], ), 'base_year': 2000, }
def prepare_run_manager(option_group=None): if option_group is None: option_group = StartRunOptionGroup() parser = option_group.parser options, args = option_group.parse() run_manager = RunManager( option_group.get_services_database_configuration(options)) if options.pickled_resource_file is not None: f = file(options.pickled_resource_file, 'r') try: config = pickle.load(f) finally: f.close() elif options.configuration_path is not None: opus_path = options.configuration_path try: config = get_config_from_opus_path(opus_path) except ImportError: # TODO: Once all fully-specified configurations are stored as classes, # get rid of this use. import_stmt = 'from %s import run_configuration as config' % opus_path exec(import_stmt) insert_auto_generated_cache_directory_if_needed(config) elif options.xml_configuration is not None: if options.scenario_name is None: parser.print_help() sys.exit(1) config = XMLConfiguration( options.xml_configuration).get_run_configuration( options.scenario_name) insert_auto_generated_cache_directory_if_needed(config) else: parser.print_help() sys.exit(1) if options.existing_cache_to_copy is not None: config[ 'creating_baseyear_cache_configuration'].cache_from_database = False config[ 'creating_baseyear_cache_configuration'].baseyear_cache = BaseyearCacheConfiguration( existing_cache_to_copy=options.existing_cache_to_copy, ) if options.years_to_cache is not None: config[ 'creating_baseyear_cache_configuration'].baseyear_cache.years_to_cache = eval( options.years_to_cache) if options.profile_filename is not None: config["profile_filename"] = options.profile_filename run_manager.setup_new_run(cache_directory=config['cache_directory'], configuration=config) return options, config, run_manager
def __my_configuration(self): tables_to_cache = ['business', 'households', 'buildings', 'development_event_history', 'target_vacancies', 'annual_household_control_totals', 'annual_business_control_totals', 'annual_relocation_rates_for_business', 'annual_relocation_rates_for_households', 'household_characteristics_for_ht', 'parcels', 'zones', "tracts", "households_for_estimation", "business_for_estimation", "persons", "travel_data", "annual_relocation_rates_for_business", "buildings_for_estimation", "building_use", "building_use_classification", 'urbansim_constants' ] return { 'cache_directory' : r'/urbansim_cache/sanfrancisco/cache_source', # change or leave out 'creating_baseyear_cache_configuration':CreatingBaseyearCacheConfiguration( # cache_directory_root = '/tmp/urbcache/sandbox_runs/estimation', unroll_gridcells = False, cache_from_database = True, baseyear_cache = BaseyearCacheConfiguration( existing_cache_to_copy = r'/urbansim_cache/sanfrancisco/cache_source', ), cache_scenario_database = 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache = tables_to_cache, tables_to_copy_to_previous_years = {}, ), 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name = 'sanfrancisco_baseyear', ), 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['sanfrancisco', 'urbansim', 'opus_core'], ), 'base_year': 2001, }
def test_creating_baseyear_cache_configuration(self): expected_cache_scenario_database = 'urbansim.model_coordinators.cache_scenario_database' expected_cache_directory_root = os.path.join('path', 'to', 'cache') expected_cache_from_database = True expected_baseyear_cache = BaseyearCacheConfiguration( existing_cache_to_copy=os.path.join('path', 'to', 'baseyear', 'cache'), years_to_cache=BaseyearCacheConfiguration.ALL_YEARS, ) expected_tables_to_cache = [ 'table1', 'table2', 'table3', ] expected_tables_to_cache_nchunks = {'table1': 5} expected_tables_to_copy_to_previous_years = {'table3': 1995} expected_unroll_gridcells = True cbcc = CreatingBaseyearCacheConfiguration( cache_scenario_database=expected_cache_scenario_database, cache_directory_root=expected_cache_directory_root, cache_from_database=expected_cache_from_database, baseyear_cache=expected_baseyear_cache, tables_to_cache=expected_tables_to_cache, tables_to_cache_nchunks=expected_tables_to_cache_nchunks, tables_to_copy_to_previous_years= expected_tables_to_copy_to_previous_years, unroll_gridcells=expected_unroll_gridcells, ) self.assertEqual(cbcc.cache_scenario_database, expected_cache_scenario_database) self.assertEqual(cbcc.cache_directory_root, expected_cache_directory_root) self.assertEqual(cbcc.cache_from_database, expected_cache_from_database) self.assertEqual(cbcc.baseyear_cache, expected_baseyear_cache) self.assertEqual(cbcc.tables_to_cache, expected_tables_to_cache) self.assertEqual(cbcc.tables_to_cache_nchunks, expected_tables_to_cache_nchunks) self.assertEqual(cbcc.tables_to_copy_to_previous_years, expected_tables_to_copy_to_previous_years) self.assertEqual(cbcc.unroll_gridcells, expected_unroll_gridcells)
def __init__(self): from copy import deepcopy config = deepcopy(AbstractUrbansimConfiguration()) cache_directory = os.path.join(package().get_opus_core_path(), 'data', 'test_cache') config_changes = { 'description': 'Test cache', 'base_year': 1980, 'years': (1981, 1982), 'models': [ 'prescheduled_events', 'events_coordinator', 'residential_land_share_model', 'land_price_model', 'development_project_transition_model', 'residential_development_project_location_choice_model', 'commercial_development_project_location_choice_model', 'industrial_development_project_location_choice_model', 'development_event_transition_model', 'events_coordinator', 'residential_land_share_model', 'household_transition_model', 'employment_transition_model', 'household_relocation_model', 'household_location_choice_model', 'employment_relocation_model', { 'employment_location_choice_model': { 'group_members': '_all_' } }, 'distribute_unplaced_jobs_model', ], 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name='eugene_1980_baseyear', ), 'cache_directory': cache_directory, 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( cache_directory_root='c:/urbansim_cache', cache_from_database=False, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy=cache_directory, ), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache=[ 'annual_employment_control_totals', 'annual_household_control_totals', 'buildings', 'building_types', 'development_event_history', 'gridcells', 'households', 'job_building_types', 'jobs', 'travel_data', 'zones', 'counties', 'commercial_development_location_choice_model_coefficients', 'commercial_development_location_choice_model_specification', 'commercial_employment_location_choice_model_coefficients', 'commercial_employment_location_choice_model_specification', 'home_based_employment_location_choice_model_specification', 'home_based_employment_location_choice_model_coefficients', 'industrial_employment_location_choice_model_coefficients', 'industrial_employment_location_choice_model_specification', 'industrial_development_location_choice_model_coefficients', 'industrial_development_location_choice_model_specification', 'residential_development_location_choice_model_coefficients', 'residential_development_location_choice_model_specification', #'fazes', 'urbansim_constants', 'household_location_choice_model_coefficients', 'household_location_choice_model_specification', 'land_price_model_coefficients', 'land_price_model_specification', 'residential_land_share_model_coefficients', 'residential_land_share_model_specification', #'plan_type_group_definitions', #'plan_type_groups', #'large_areas', 'household_characteristics_for_ht', 'development_types', 'development_type_group_definitions', 'development_constraints', 'annual_relocation_rates_for_households', 'annual_relocation_rates_for_jobs', 'base_year', 'cities', #'development_events', 'development_type_groups', 'employment_adhoc_sector_group_definitions', 'employment_adhoc_sector_groups', 'employment_sectors', 'plan_types', 'race_names', 'target_vacancies' #'jobs_for_estimation', #'households_for_estimation', #'development_events_exogenous', ], tables_to_cache_nchunks={'gridcells': 1}, tables_to_copy_to_previous_years={ 'development_type_group_definitions': 1975, 'development_type_groups': 1975, 'development_types': 1975, 'urbansim_constants': 1975, }, ), } config.merge(config_changes) self.merge(config)
# Copyright (C) 2005-2009 University of Washington # See opus_core/LICENSE import os from opus_core.configurations.baseyear_cache_configuration import BaseyearCacheConfiguration from opus_core.database_management.configurations.scenario_database_configuration import ScenarioDatabaseConfiguration from urbansim.configurations.creating_baseyear_cache_configuration import CreatingBaseyearCacheConfiguration from baseline import Baseline my_cache_config = CreatingBaseyearCacheConfiguration( cache_directory_root='/Users/hana/urbansim_cache/washtenaw/runs', cache_from_database=False, unroll_gridcells=False, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy= '/Users/hana/urbansim_cache/washtenaw/cache_source', #years_to_cache = range(2005,2006) ), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache=Baseline.tables_to_cache, tables_to_copy_to_previous_years=Baseline.tables_to_copy_to_previous_years, ) my_configuration = { 'scenario_database_configuration': ScenarioDatabaseConfiguration(database_name='region_pilot_baseyear', ), # 'models': [ #'prescheduled_events', #'events_coordinator', #'residential_land_share_model',
def __my_configuration(self): # tables_to_cache = Baseline()['creating_baseyear_cache_configuration'].tables_to_cache tables_to_cache =[ #'development_event_history', 'edges', 'parcels', 'gridcells', 'households', 'households_for_estimation', 'jobs', 'travel_data', 'persons', #need to cache 'persons_for_estimation', 'zones', 'cities', 'buildings', 'building_types', 'urbansim_constants', 'job_building_types', 'tours', #'land_price_model_coefficients', #'land_price_model_specification',] ] return { 'cache_directory' : 'C:/tmp/urbansim_cache/psrc_parcel', # change or leave out 'creating_baseyear_cache_configuration':CreatingBaseyearCacheConfiguration( # cache_directory_root = '/tmp/urbcache/sandbox_runs/estimation', unroll_gridcells = False, cache_from_database = True, baseyear_cache = BaseyearCacheConfiguration( existing_cache_to_copy = r'D:/urbansim_cache/full_psrc', ), cache_scenario_database = 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache = tables_to_cache, tables_to_cache_nchunks = { 'parcels':8, 'gridcells':5, 'buildings':10, }, # tables_to_copy_to_previous_years = { # 'development_type_groups': 1995, # 'development_types': 1995, # 'development_type_group_definitions': 1995, # 'development_constraints': 1995, # 'urbansim_constants': 1995, # }, ), 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name = "psrc_activity2006_ver2" # 2006 PSRC Activity Survey for households_for_estimation, ), 'estimation_database_configuration':EstimationDatabaseConfiguration( database_name = 'PSRC_2000_parcels_estimation_output', ), 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['psrc', 'urbansim', 'opus_core'], ), 'base_year': 2000, 'years': (2000,2000), 'datasets_to_preload' :{ 'gridcell':{ 'package_name':'urbansim', 'nchunks':2, }, 'parcel':{ 'package_name':'psrc', 'nchunks':3, }, 'household':{ 'package_name':'urbansim', }, 'person':{ 'package_name':'psrc', }, 'zone':{ 'package_name':'urbansim', }, 'travel_data':{ 'package_name':'urbansim', }, 'building':{ 'package_name':'urbansim', }, # 'edge':{ # 'package_name':'transit_accessibility', # } }, 'seed':1,#(1,1) }
def __init__(self): config = AbstractUrbansimConfiguration() config_changes = { 'project_name': 'washtenaw', 'description': 'Region Pilot Baseline', 'scenario_database_configuration': ScenarioDatabaseConfiguration(database_name='washtenaw_class', ), 'models': [ 'prescheduled_events', 'events_coordinator', 'residential_land_share_model', 'land_price_model', 'regional_development_project_transition_model', 'residential_regional_development_project_location_choice_model', 'commercial_regional_development_project_location_choice_model', 'industrial_regional_development_project_location_choice_model', 'development_event_transition_model', 'events_coordinator', 'residential_land_share_model', 'jobs_event_model', #'households_event_model', 'regional_household_transition_model', 'regional_household_relocation_model', 'regional_household_location_choice_model', 'regional_employment_transition_model', 'regional_employment_relocation_model', { 'regional_employment_location_choice_model': { 'group_members': ['_all_'] } }, 'regional_distribute_unplaced_jobs_model' ], 'cache_directory': None, ### TODO: Set this cache_directory to something useful. 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( cache_directory_root="/urbansim_cache/washtenaw", cache_from_database=True, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy= "/urbansim_cache/washtenaw/cache_source", ), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache=self.tables_to_cache, tables_to_cache_nchunks={'gridcells': 1}, tables_to_copy_to_previous_years=self. tables_to_copy_to_previous_years, ), 'datasets_to_preload': { 'development_constraint': {}, 'development_event_history': {}, 'development_type': {}, 'gridcell': { 'nchunks': 2 }, 'household': {}, 'job': {}, 'job_building_type': {}, 'target_vacancy': {}, 'zone': {}, 'jobs_event': {}, #'households_event': {}, }, 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['washtenaw', 'urbansim', 'opus_core'], ), 'base_year': 2005, 'years': (2006, 2010), } config.merge(config_changes) self.merge(config) self.merge_with_controller() try: exec('from %s_local_config import my_configuration' % getuser()) local_config = True except: logger.log_note( "No user's settings found or error occured when loading.") local_config = False if local_config: self.merge(my_configuration)
def __init__(self): config = AbstractUrbansimConfiguration() db_server = DatabaseServer(ScenarioDatabaseConfiguration()) db = db_server.get_database('PSRC_2000_baseyear') config_changes = { 'description':'baseline with travel model', 'in_storage':StorageFactory().get_storage('sql_storage', storage_location = db ), 'cache_directory':None, ### TODO: Set this cache_directory to something useful. 'creating_baseyear_cache_configuration':CreatingBaseyearCacheConfiguration( cache_directory_root = 'd:/urbansim_cache', cache_from_database = True, baseyear_cache = BaseyearCacheConfiguration( r'D:\urbansim_cache\run_1417.2006_12_08_01_50'), cache_scenario_database = 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache = [ 'annual_employment_control_totals', 'annual_household_control_totals', 'buildings', 'building_types', 'development_event_history', 'gridcells', 'households', 'job_building_types', 'jobs', 'travel_data', 'zones', 'counties', 'commercial_development_location_choice_model_coefficients', 'commercial_development_location_choice_model_specification', 'commercial_employment_location_choice_model_coefficients', 'commercial_employment_location_choice_model_specification', 'home_based_employment_location_choice_model_specification', 'home_based_employment_location_choice_model_coefficients', 'industrial_employment_location_choice_model_coefficients', 'industrial_employment_location_choice_model_specification', 'industrial_development_location_choice_model_coefficients', 'industrial_development_location_choice_model_specification', 'residential_development_location_choice_model_coefficients', 'residential_development_location_choice_model_specification', 'fazes', 'urbansim_constants', 'household_location_choice_model_coefficients', 'household_location_choice_model_specification', 'land_price_model_coefficients', 'land_price_model_specification', 'residential_land_share_model_coefficients', 'residential_land_share_model_specification', 'plan_type_group_definitions', 'plan_type_groups', 'large_areas', 'household_characteristics_for_ht', 'development_types', 'development_type_group_definitions', 'development_constraints', 'annual_relocation_rates_for_households', 'annual_relocation_rates_for_jobs', 'base_year', 'cities', 'development_events', 'development_type_groups', 'employment_adhoc_sector_group_definitions', 'employment_adhoc_sector_groups', 'employment_events', 'employment_sectors', 'land_use_events', 'plan_types', 'race_names', 'target_vacancies', 'jobs_for_estimation', 'households_for_estimation', 'development_events_exogenous', 'job_building_types' ], tables_to_cache_nchunks = {'gridcells': 4}, tables_to_copy_to_previous_years = { 'development_type_groups': 1995, 'development_types': 1995, 'development_type_group_definitions': 1995, }, ), 'models':[], # run no urbansim models 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name = 'PSRC_2000_baseyear', ), 'base_year':2000, 'years':(2001, 2002), 'unroll_gridcells':False } config.merge(config_changes) travel_model_config = create_travel_model_configuration('baseline_travel_model_psrc_fresh', mode='get_emme2_data_after_run', years_to_run = {2001:'2000_06'}, emme2_batch_file='MODEL05.BAT') config['travel_model_configuration'] = travel_model_config self.merge(config)
from opus_core.database_management.configurations.database_configuration import DatabaseConfiguration from opus_core.configurations.baseyear_cache_configuration import BaseyearCacheConfiguration from urbansim.configs.base_config_zone import tables_to_cache #from urbansim.configs.base_config_zone import run_configuration from urbansim.configs.cache_baseyear_configuration import CacheBaseyearConfiguration from urbansim.configurations.creating_baseyear_cache_configuration import CreatingBaseyearCacheConfiguration cache_configuration = CacheBaseyearConfiguration() my_cache_config = CreatingBaseyearCacheConfiguration( cache_directory_root = '/tmp/urbcache/sandbox_runs/zones', unroll_gridcells = True, cache_from_database = True, baseyear_cache = BaseyearCacheConfiguration( existing_cache_to_copy = '/urbansim_cache/psrc_zone', years_to_cache = range(1996,2000), ), tables_to_cache = tables_to_cache().get_tables_to_cache(), tables_to_cache_nchunks = { 'gridcells':5, }, ) cache_configuration['creating_baseyear_cache_configuration'] = my_cache_config my_configuration = { 'remove_cache': False, # remove cache after finishing the simulation 'cache_directory': '/urbansim_cache/psrc_zone', ### TODO: Set this cache_directory to something useful. 'creating_baseyear_cache_configuration': cache_configuration['creating_baseyear_cache_configuration'], 'input_configuration': DatabaseConfiguration( database_name = 'PSRC_2000_estimation_zone_pwaddell', #change ), 'base_year':2000,
def __init__(self): opus_home = os.environ['OPUS_HOME'] config = UrbansimParcelConfiguration() config_changes = { 'project_name': 'seattle_parcel', 'description': 'Seattle parcel baseline', 'cache_directory': os.path.join(os.environ['OPUS_HOME'], 'data/vibe_parcel/base_year_data'), 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( cache_directory_root=os.path.join(os.environ['OPUS_HOME'], 'data/vibe_parcel/runs'), cache_from_database=True, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy=os.path.join( os.environ['OPUS_HOME'], 'data/vibe_gridcell/base_year_data'), ), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache=[ 'households', 'persons', 'buildings', 'parcels', 'gridcells', 'zones', "jobs", "households_for_estimation", "jobs_for_estimation", "development_event_history", "travel_data", "building_types", "job_building_types", 'urbansim_constants', "target_vacancies", "home_based_employment_location_choice_model_coefficients", "home_based_employment_location_choice_model_specification", "non_home_based_employment_location_choice_model_coefficients", "non_home_based_employment_location_choice_model_specification", "household_location_choice_model_coefficients", "household_location_choice_model_specification", "real_estate_price_model_coefficients", "real_estate_price_model_specification", "annual_household_control_totals", "annual_relocation_rates_for_households", "household_characteristics_for_ht", "annual_employment_control_totals", "annual_relocation_rates_for_jobs", "land_use_types", "generic_land_use_types", 'employment_sectors', 'employment_adhoc_sector_groups', 'employment_adhoc_sector_group_definitions', 'development_templates', 'development_template_components', 'development_constraints', "building_sqft_per_job", "fazes", "large_areas", "demolition_cost_per_sqft", 'constant_taz_columns' ], tables_to_cache_nchunks={'parcels': 1}, unroll_gridcells=False), 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name='urbansim_export_test', ), 'dataset_pool_configuration': DatasetPoolConfiguration( #package_order=['psrc_parcel', 'urbansim_parcel', 'urbansim', 'opus_core'], #), package_order=[ 'psrc_parcel', 'urbansim_parcel', 'urbansim', 'opus_core' ], ), 'base_year': 1980, 'years': (1981, 1985), 'models': [ # models are executed in the same order as in this list #"process_pipeline_events", # uncomented by model "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_'}}, #'distribute_unplaced_jobs_model' ], 'models_in_year': { 1980: [ # This is not run anymore, since all jobs are located and only a few households are not. "household_relocation_model_for_1980", "household_location_choice_model_for_1980", #"employment_relocation_model_for_1980", #{"employment_location_choice_model":{'group_members': '_all_'}} ] }, 'flush_dataset_to_cache_after_each_model': False, 'flush_variables': False, 'low_memory_run': False, 'datasets_to_cache_after_each_model': [ "parcel", "building", 'household', #'job', 'development_project_proposal_component', #to be cached for diagnostic purpose (lmwang) 'development_project_proposal', 'travel_data' ], 'unroll_gridcells': False, "datasets_to_preload": { 'zone': {}, 'household': {}, 'building': {}, 'parcel': { 'package_name': 'urbansim_parcel' }, 'person': { 'package_name': 'urbansim_parcel' }, 'development_template': { 'package_name': 'urbansim_parcel' }, 'development_template_component': { 'package_name': 'urbansim_parcel' }, #'job':{}, "building_type": { 'package_name': 'urbansim_parcel' }, 'travel_data': {}, #"job_building_type":{} } } config.replace(config_changes) '''config['models_configuration']["household_location_choice_model"]["controller"]["import"] = \ {"psrc_parcel.models.household_location_choice_model" : "HouseholdLocationChoiceModel"} config['models_configuration']["employment_location_choice_model"]['controller']["import"] = \ {"psrc_parcel.models.employment_location_choice_model" : "EmploymentLocationChoiceModel"} config['models_configuration']["home_based_employment_location_choice_model"]['controller']["import"] = \ {"psrc_parcel.models.employment_location_choice_model" : "EmploymentLocationChoiceModel"} config['models_configuration']['household_relocation_model_for_1980'] = {} config['models_configuration']['household_relocation_model_for_1980']['controller'] = \ HouseholdRelocationModelConfigurationCreator( location_id_name = 'building_id', probabilities = None, rate_table=None, output_index = 'hrm_index').execute() config['models_configuration']['household_location_choice_model_for_1980'] = Configuration( config['models_configuration']['household_location_choice_model'] ) config['models_configuration']['household_location_choice_model_for_1980']['controller']['run']['arguments']['chunk_specification'] = "{'nchunks':1}" config['models_configuration']['household_location_choice_model_for_1980']['controller']['run']['arguments']['maximum_runs'] = 1 config['models_configuration']['employment_relocation_model_for_1980'] = {} config['models_configuration']['employment_relocation_model_for_1980']['controller'] = \ EmploymentRelocationModelConfigurationCreator( location_id_name = 'building_id', probabilities = None, rate_table=None, output_index = 'erm_index').execute()''' if self.multiple_runs: from multiple_runs_modification import MultipleRunsModification MultipleRunsModification().modify_configuration(config) self.merge(config)
def __init__(self): Configuration.__init__( self, data={ 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name="washtenaw_class", ), 'datasets_to_cache_after_each_model': [], 'low_memory_mode': False, 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( unroll_gridcells=True, cache_from_database=False, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy= '/urbansim_cache/workshop/cache_source', #years_to_cache = range(1996,2001) ), tables_to_cache=[ 'annual_employment_control_totals', 'annual_household_control_totals', 'buildings', 'building_types', 'development_event_history', 'gridcells', 'households', 'job_building_types', 'jobs', 'travel_data', 'zones', 'counties', 'commercial_development_location_choice_model_coefficients', 'commercial_development_location_choice_model_specification', 'commercial_employment_location_choice_model_coefficients', 'commercial_employment_location_choice_model_specification', 'home_based_employment_location_choice_model_specification', 'home_based_employment_location_choice_model_coefficients', 'industrial_employment_location_choice_model_coefficients', 'industrial_employment_location_choice_model_specification', 'industrial_development_location_choice_model_coefficients', 'industrial_development_location_choice_model_specification', 'residential_development_location_choice_model_coefficients', 'residential_development_location_choice_model_specification', 'fazes', 'urbansim_constants', 'household_location_choice_model_coefficients', 'household_location_choice_model_specification', 'land_price_model_coefficients', 'land_price_model_specification', 'residential_land_share_model_coefficients', 'residential_land_share_model_specification', 'plan_type_group_definitions', 'plan_type_groups', 'large_areas', 'household_characteristics_for_ht', 'development_types', 'development_type_group_definitions', 'development_constraints', 'annual_relocation_rates_for_households', 'annual_relocation_rates_for_jobs', 'base_year', 'cities', 'development_events', 'development_type_groups', 'employment_adhoc_sector_group_definitions', 'employment_adhoc_sector_groups', 'employment_sectors', 'plan_types', 'race_names', 'target_vacancies', 'jobs_for_estimation', 'households_for_estimation', 'development_events_exogenous', 'job_building_types' ], tables_to_cache_nchunks={'gridcells': 1}, tables_to_copy_to_previous_years={ 'development_type_group_definitions': 1995, 'development_type_groups': 1995, 'development_types': 1995, 'development_constraints': 1995, 'urbansim_constants': 1995, }, ), 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['washtenaw', 'urbansim', 'opus_core'], ), 'base_year': 2000, 'years': (2000, 2000), })
run_configuration = AbstractUrbansimConfiguration() my_run_configuration = { 'models_configuration':models_configuration, 'scenario_database_configuration':ScenarioDatabaseConfiguration( database_name = 'randstad_021105_estimation', ), #'cache_directory':'C:/urbansim_cache/randstad_source', 'cache_directory':None, ### TODO: Set this cache_directory to something useful. 'creating_baseyear_cache_configuration':CreatingBaseyearCacheConfiguration( cache_directory_root = 'C:/urbansim_cache/randstad', cache_scenario_database = 'urbansim.model_coordinators.cache_scenario_database', unroll_gridcells = False, cache_from_database = False, # location of existing baseyear cache to use baseyear_cache = BaseyearCacheConfiguration( existing_cache_to_copy = r'C:\urbansim_cache\randstad\run_618.2006_07_16_18_06', years_to_cache = [1995], ), tables_to_cache = [ 'annual_employment_control_totals', 'annual_household_control_totals', 'development_event_history', 'gridcells', 'households', 'jobs', 'travel_data', 'zones', 'counties', # 'commercial_development_location_choice_model_coefficients', # 'commercial_development_location_choice_model_specification', 'employment_commercial_location_choice_model_coefficients', 'employment_commercial_location_choice_model_specification',
def __init__(self): config = UrbansimParcelConfiguration() config_changes = { 'description': 'data preparation for PSRC parcel (households)', 'cache_directory': None, 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( cache_directory_root=r'/Users/hana/urbansim_cache/psrc/parcel', #cache_directory_root = r'/urbansim_cache/psrc_parcel', #cache_directory_root = r'/workspace/urbansim_cache/psrc_parcel', cache_from_database=False, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy= r'/Users/hana/urbansim_cache/psrc/cache_source_parcel', #existing_cache_to_copy = r'/urbansim_cache/psrc_parcel/cache_source', #existing_cache_to_copy = r'/workspace/urbansim_cache/psrc_parcel/estimation', years_to_cache=[2000]), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', ), 'dataset_pool_configuration': DatasetPoolConfiguration(package_order=[ 'psrc_parcel', 'urbansim_parcel', 'urbansim', 'opus_core' ], ), 'base_year': 2000, 'years': (2001, 2001), 'models': [ # models are executed in the same order as in this list "household_relocation_model", "household_location_choice_model", ], "datasets_to_preload": { 'zone': {}, 'household': {}, 'building': {} } } #use configuration in config as defaults and merge with config_changes config.replace(config_changes) self.merge(config) 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()
from urbansim.configurations.creating_baseyear_cache_configuration import CreatingBaseyearCacheConfiguration my_configuration = { 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name="semcog_baseyear", #change ), 'estimation_database_configuration': EstimationDatabaseConfiguration( database_name="semcog_baseyear_estimation", ), 'datasets_to_cache_after_each_model': [], 'low_memory_mode': False, 'cache_directory': '/urbansim_cache/semcog/cache_source', # change or leave out 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( unroll_gridcells=True, cache_from_database=False, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy='/urbansim_cache/semcog/cache_source', #years_to_cache = range(1996,2001) ), tables_to_cache=[], tables_to_cache_nchunks={'gridcells': 1}, tables_to_copy_to_previous_years={}, ), 'base_year': 2005, 'years': (2005, 2005), }
def __init__(self): AbstractUrbansimConfiguration.__init__(self) config_changes = { 'project_name': 'vibe_gridcell', 'description': 'Eugene baseline', 'base_year': 1980, 'years': (1981, 1982, 1983), 'models': [ 'prescheduled_events', 'events_coordinator', #'residential_land_share_model', #'fertility_model' #'land_price_model', #'development_project_transition_model', #'residential_development_project_location_choice_model', #'commercial_development_project_location_choice_model', #'industrial_development_project_location_choice_model', #'development_event_transition_model', #'events_coordinator', #'residential_land_share_model', 'household_transition_model', #'employment_transition_model', 'household_relocation_model', 'household_location_choice_model', #'employment_relocation_model', #{ 'employment_location_choice_model': { 'group_members': '_all_'}}, #'distribute_unplaced_jobs_model', ], #'scenario_database_configuration': ScenarioDatabaseConfiguration(database_name = 'eugen_base_year_data_1980'), #'scenario_database_configuration': ScenarioDatabaseConfiguration(database_name = 'vibe_base_year_data_1980'), 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name='urbansim_export_test'), 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( #cache_directory_root = os.path.join(os.environ['OPUS_HOME'], 'data/eugene_gridcell/runs'), cache_directory_root=os.path.join(os.environ['OPUS_HOME'], 'data/vibe_gridcell/runs'), #cache_scenario_database = storage, cache_from_database=True, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy=os.path.join( os.environ['OPUS_HOME'], 'data/vibe_gridcell/base_year_data'), ), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache=[ #'annual_employment_control_totals', 'annual_household_control_totals', #'buildings', 'building_types', 'development_event_history', 'gridcells', 'households', 'job_building_types', 'jobs', #'travel_data', 'zones', #'counties', #'commercial_development_location_choice_model_coefficients', #'commercial_development_location_choice_model_specification', #'commercial_employment_location_choice_model_coefficients', #'commercial_employment_location_choice_model_specification', #'home_based_employment_location_choice_model_specification', #'home_based_employment_location_choice_model_coefficients', #'industrial_employment_location_choice_model_coefficients', #'industrial_employment_location_choice_model_specification', #'industrial_development_location_choice_model_coefficients', #'industrial_development_location_choice_model_specification', 'residential_development_location_choice_model_coefficients', 'residential_development_location_choice_model_specification', 'urbansim_constants', 'household_location_choice_model_coefficients', 'household_location_choice_model_specification', #'land_price_model_coefficients', #'land_price_model_specification', #'residential_land_share_model_coefficients', #'residential_land_share_model_specification', 'household_characteristics_for_ht', 'development_types', 'development_type_group_definitions', 'development_constraints', 'annual_relocation_rates_for_households', #'annual_relocation_rates_for_jobs', 'base_year', #'cities', 'development_type_groups', #'employment_adhoc_sector_group_definitions', #'employment_adhoc_sector_groups', #'employment_sectors', 'plan_types', 'plan_type_groups', 'plan_type_group_definitions', 'race_names', 'target_vacancies', #'jobs_for_estimation', 'households_for_estimation', ], tables_to_cache_nchunks={'gridcells': 1}, tables_to_copy_to_previous_years={ 'development_type_group_definitions': 1975, 'development_type_groups': 1975, 'development_types': 1975, 'development_constraints': 1975, 'urbansim_constants': 1975, }, ), 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['vibe_min', 'urbansim', 'opus_core'], ), } self.merge(config_changes)
def __init__(self): config = UrbansimParcelConfiguration() config_changes = { 'description': 'data preparation for PSRC parcel (buildings)', 'cache_directory': None, 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( #cache_directory_root = r'/Users/hana/urbansim_cache/psrc/parcel', cache_directory_root=r'/urbansim_cache/psrc_parcel', #cache_directory_root = r'/workspace/urbansim_cache/psrc_parcel', cache_from_database=False, baseyear_cache=BaseyearCacheConfiguration( #existing_cache_to_copy = r'/Users/hana/urbansim_cache/psrc/cache_source_parcel', existing_cache_to_copy= r'/urbansim_cache/psrc_parcel/cache_source', #existing_cache_to_copy = r'/workspace/urbansim_cache/psrc_parcel/estimation', years_to_cache=[2000]), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', ), 'dataset_pool_configuration': DatasetPoolConfiguration(package_order=[ 'psrc_parcel', 'urbansim_parcel', 'urbansim', 'opus_core' ], ), 'base_year': 2000, 'years': (2001, 2001), 'models': [ # models are executed in the same order as in this list "expected_sale_price_model", "development_proposal_choice_model", "building_construction_model", ], "datasets_to_preload": { 'zone': {}, 'household': {}, 'building': {}, #'development_project_proposal': {} }, "datasets_to_cache_after_each_model": [ 'parcel', 'building', 'development_project_proposal', 'household', 'job' ] } #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"] = "'non_residential'" self['models_configuration']['expected_sale_price_model'][ 'controller']["init"]['arguments'][ "filter_attribute"] = "'urbansim_parcel.development_project_proposal.is_size_fit'" self['models_configuration']['expected_sale_price_model']['controller']["prepare_for_run"]['arguments']["parcel_filter"] = \ "'numpy.logical_and(numpy.logical_or(numpy.logical_not(urbansim_parcel.parcel.is_residential_land_use_type), numpy.logical_and(parcel.land_use_type_id==26, urbansim_parcel.parcel.is_non_residential_plan_type)), urbansim_parcel.parcel.vacant_land_area > 0)'" #"'numpy.logical_or(parcel.land_use_type_id==26, numpy.logical_and(urbansim_parcel.parcel.is_residential_land_use_type, urbansim_parcel.parcel.vacant_land_area > 0))'" 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
def __my_configuration(self): tables_to_cache = [ 'households', 'buildings', 'parcels', 'gridcells', 'zones', "jobs", "households_for_estimation", "jobs_for_estimation", #"development_event_history", "persons", "persons_for_estimation", "travel_data", "building_types", "job_building_types", 'urbansim_constants', "target_vacancies", "home_based_employment_location_choice_model_coefficients", "home_based_employment_location_choice_model_specification", "non_home_based_employment_location_choice_model_coefficients", "non_home_based_employment_location_choice_model_specification", "household_location_choice_model_coefficients", "household_location_choice_model_specification", "real_estate_price_model_coefficients", "real_estate_price_model_specification", "annual_household_control_totals", "annual_relocation_rates_for_households", "household_characteristics_for_ht", "annual_employment_control_totals", "annual_relocation_rates_for_jobs", "land_use_types", "generic_land_use_types", 'employment_sectors', 'employment_adhoc_sector_groups', 'employment_adhoc_sector_group_definitions', 'development_templates', 'development_template_components', 'development_constraints', "building_sqft_per_job", "fazes", "large_areas", "demolition_cost_per_sqft", 'constant_taz_columns', 'zipcodes', 'cities', 'districts', 'area_types', "work_at_home_choice_model_coefficients", "work_at_home_choice_model_specification", "workplace_choice_model_for_resident_coefficients", "workplace_choice_model_for_resident_specification", "development_project_proposals", 'development_project_proposals_for_estimation', 'tours', 'households_2001', ] return { 'cache_directory': '/urbansim_cache/psrc_parcel/developer_model', # change or leave out #'cache_directory' : '/workspace/urbansim_cache/psrc_parcel_lmwang/estimation/', 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( # cache_directory_root = '/tmp/urbcache/sandbox_runs/estimation', unroll_gridcells=False, cache_from_database=True, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy= r'/urbansim_cache/psrc_parcel_2005/cache_source', ), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache=tables_to_cache, tables_to_cache_nchunks={ 'parcels': 4, 'buildings': 5 }, tables_to_copy_to_previous_years={}, ), 'scenario_database_configuration': ScenarioDatabaseConfiguration( #database_name = 'psrc_2005_parcel_baseyear_change_20070608', database_name='psrc_2005_parcel_baseyear_change_20080622_2006', ), 'dataset_pool_configuration': DatasetPoolConfiguration(package_order=[ 'psrc_parcel', 'urbansim_parcel', 'urbansim', 'opus_core' ], ), 'base_year': 2006, }
def __init__(self): UrbansimZoneConfiguration.__init__(self) config_changes = { 'project_name': 'eugene_zone', 'description': 'Eugene zone baseline', 'base_year': 1980, 'years': (1981, 1985), 'debuglevel': 4, 'models': [ 'real_estate_price_model', 'development_project_transition_model', 'commercial_development_project_location_choice_model', 'industrial_development_project_location_choice_model', 'residential_development_project_location_choice_model', 'add_projects_to_buildings', 'household_transition_model', 'employment_transition_model', 'household_relocation_model', 'household_location_choice_model', 'employment_relocation_model', { 'employment_location_choice_model': { 'group_members': '_all_' } }, 'distribute_unplaced_jobs_model', ], 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name='eugene_1980_baseyear_zone'), 'cache_directory': os.path.join(os.environ['OPUS_HOME'], 'data/eugene_zone/base_year_data'), 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( cache_directory_root=os.path.join(os.environ['OPUS_HOME'], 'data/eugene_zone/runs'), cache_from_database=False, baseyear_cache=BaseyearCacheConfiguration( existing_cache_to_copy=os.path.join( os.environ['OPUS_HOME'], 'data/eugene_zone/base_year_data')), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache=[ 'annual_employment_control_totals', 'annual_household_control_totals', 'households', 'job_building_types', 'building_types', 'jobs', 'travel_data', 'zones', 'pseudo_buildings', 'counties', 'commercial_development_location_choice_model_coefficients', 'commercial_development_location_choice_model_specification', 'commercial_employment_location_choice_model_coefficients', 'commercial_employment_location_choice_model_specification', 'home_based_employment_location_choice_model_specification', 'home_based_employment_location_choice_model_coefficients', 'industrial_employment_location_choice_model_coefficients', 'industrial_employment_location_choice_model_specification', 'industrial_development_location_choice_model_coefficients', 'industrial_development_location_choice_model_specification', 'residential_development_location_choice_model_coefficients', 'residential_development_location_choice_model_specification', #'fazes', 'urbansim_constants', 'household_location_choice_model_coefficients', 'household_location_choice_model_specification', 'household_characteristics_for_ht', 'annual_relocation_rates_for_households', 'annual_relocation_rates_for_jobs', 'base_year', 'cities', 'development_event_history', 'employment_adhoc_sector_group_definitions', 'employment_adhoc_sector_groups', 'employment_sectors', 'race_names', 'target_vacancies', 'jobs_for_estimation', 'households_for_estimation', ], unroll_gridcells=False), 'dataset_pool_configuration': DatasetPoolConfiguration(package_order=[ 'eugene_zone', 'eugene', 'urbansim_zone', 'urbansim', 'opus_core' ], ), } self.merge(config_changes)
insert_auto_generated_cache_directory_if_needed(config) elif options.xml_configuration is not None: if options.scenario_name is None: parser.print_help() sys.exit(1) config = XMLConfiguration( options.xml_configuration).get_run_configuration( options.scenario_name) insert_auto_generated_cache_directory_if_needed(config) else: parser.print_help() sys.exit(1) if options.existing_cache_to_copy is not None: config[ 'creating_baseyear_cache_configuration'].cache_from_database = False config[ 'creating_baseyear_cache_configuration'].baseyear_cache = BaseyearCacheConfiguration( existing_cache_to_copy=options.existing_cache_to_copy, ) if options.years_to_cache is not None: config[ 'creating_baseyear_cache_configuration'].baseyear_cache.years_to_cache = eval( options.years_to_cache) if options.profile_filename is not None: config["profile_filename"] = options.profile_filename run_manager.setup_new_run(cache_directory=config['cache_directory'], configuration=config) run_manager.run_run(config, run_as_multiprocess=run_as_multiprocess)
def __init__(self): config = UrbansimParcelConfiguration() if os.environ.has_key('OPUS_DATA_PATH'): data_path_prefix = os.path.join(os.environ['OPUS_DATA_PATH'], 'psrc_parcel') else: data_path_prefix = os.path.join(os.environ['OPUS_HOME'], 'data/psrc_parcel') config_changes = { 'project_name': 'psrc_parcel', 'description': 'PSRC parcel baseline', 'cache_directory': os.path.join(data_path_prefix, 'base_year_data'), 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( cache_directory_root=os.path.join(data_path_prefix, 'runs'), cache_from_database=False, baseyear_cache=BaseyearCacheConfiguration( years_to_cache=[2000], #existing_cache_to_copy = r'/urbansim_cache/psrc_parcel/runs/cache_hh_persons_init', existing_cache_to_copy=os.path.join( data_path_prefix, 'base_year_data'), ), cache_scenario_database= 'urbansim.model_coordinators.cache_scenario_database', tables_to_cache=[ #'business', 'households', 'buildings', 'parcels', 'gridcells', 'zones', "jobs", "households_for_estimation", "households_for_estimation_LAG1", "jobs_for_estimation", #"development_event_history", "persons", "persons_for_estimation", "travel_data", "building_types", "job_building_types", 'urbansim_constants', "target_vacancies", "home_based_employment_location_choice_model_coefficients", "home_based_employment_location_choice_model_specification", "non_home_based_employment_location_choice_model_coefficients", "non_home_based_employment_location_choice_model_specification", "household_location_choice_model_coefficients", "household_location_choice_model_specification", "real_estate_price_model_coefficients", "real_estate_price_model_specification", "annual_household_control_totals", "annual_relocation_rates_for_households", "household_characteristics_for_ht", "annual_employment_control_totals", "annual_relocation_rates_for_jobs", "land_use_types", "generic_land_use_types", 'employment_sectors', 'employment_adhoc_sector_groups', 'employment_adhoc_sector_group_definitions', 'development_templates', 'development_template_components', 'development_constraints', "building_sqft_per_job", "fazes", "large_areas", "demolition_cost_per_sqft", 'constant_taz_columns', 'zipcodes', 'cities', 'districts', 'area_types', "work_at_home_choice_model_coefficients", "work_at_home_choice_model_specification", "workplace_choice_model_for_resident_coefficients", "workplace_choice_model_for_resident_specification", "development_project_proposals", "development_project_proposals_for_estimation", "school_districts", "tours", ## some attribute coding lookup tables "education", "employment_status", "grade", "race_names", "relationship", "sex", "student", ], tables_to_cache_nchunks={'parcels': 1}, unroll_gridcells=False), 'scenario_database_configuration': ScenarioDatabaseConfiguration( database_name='psrc_2005_parcel_baseyear', #database_name = 'psrc_2005_parcel_baseyear_change_20080804E', #database_name = 'psrc_2005_parcel_baseyear_change_lmwang', ), 'dataset_pool_configuration': DatasetPoolConfiguration(package_order=[ 'psrc_parcel', 'urbansim_parcel', 'urbansim', 'opus_core' ], ), # 'models_configuration':models_configuration, 'base_year': 2000, 'years': (2001, 2030), 'models': [ # models are executed in the same order as in this list #"process_pipeline_events", "real_estate_price_model", "expected_sale_price_model", "development_proposal_choice_model", "building_construction_model", "modify_workers_jobs_after_moving_households", # from demolished buildings "modify_workers_jobs_after_moving_jobs", # from demolished buildings "household_transition_model", "employment_transition_model", 'job_person_consistency_keeper', "household_relocation_model", "household_location_choice_model", "modify_workers_jobs_after_moving_households", "employment_relocation_model", #{"employment_location_choice_model":{'group_members': '_all_'}}, { "employment_location_choice_model": { 'group_members': ['non_home_based'] } }, 'distribute_unplaced_jobs_model', 'distribute_unplaced_mining_utilities_jobs_model', "modify_workers_jobs_after_moving_jobs", 'work_at_home_choice_model', 'workplace_choice_model_for_resident' ], 'models_in_year': { 2000: [ # This is not run anymore, since all jobs are located and only a few households are not. "household_relocation_model_for_2000", "household_location_choice_model_for_2000", "employment_relocation_model_for_2000", { "employment_location_choice_model": { 'group_members': '_all_' } } ] }, 'flush_dataset_to_cache_after_each_model': False, 'flush_variables': False, 'low_memory_run': False, 'datasets_to_cache_after_each_model': [ "parcel", "building", 'household', 'job', 'development_project_proposal_component', #to be cached for diagnostic purpose (lmwang) 'development_project_proposal', 'travel_data', 'persons' ], 'unroll_gridcells': False, "datasets_to_preload": { 'zone': {}, 'household': {}, 'building': {}, 'parcel': { 'package_name': 'urbansim_parcel' }, 'development_template': { 'package_name': 'urbansim_parcel' }, 'development_template_component': { 'package_name': 'urbansim_parcel' }, 'job': {}, 'person': { 'package_name': 'urbansim_parcel' }, "building_type": { 'package_name': 'urbansim_parcel' }, 'travel_data': {}, "job_building_type": {} } } config.replace(config_changes) config['models_configuration']["household_location_choice_model"]["controller"]["import"] = \ {"psrc_parcel.models.household_location_choice_model" : "HouseholdLocationChoiceModel"} config['models_configuration']["employment_location_choice_model"]['controller']["import"] = \ {"psrc_parcel.models.employment_location_choice_model" : "EmploymentLocationChoiceModel"} config['models_configuration']["home_based_employment_location_choice_model"]['controller']["import"] = \ {"psrc_parcel.models.employment_location_choice_model" : "EmploymentLocationChoiceModel"} config['models_configuration'][ 'household_relocation_model_for_2000'] = {} config['models_configuration']['household_relocation_model_for_2000']['controller'] = \ HouseholdRelocationModelConfigurationCreator( location_id_name = 'building_id', probabilities = None, rate_table=None, output_index = 'hrm_index').execute() config['models_configuration'][ 'household_location_choice_model_for_2000'] = Configuration( config['models_configuration'] ['household_location_choice_model']) config['models_configuration'][ 'household_location_choice_model_for_2000']['controller']['run'][ 'arguments']['chunk_specification'] = "{'nchunks':1}" config['models_configuration'][ 'household_location_choice_model_for_2000']['controller']['run'][ 'arguments']['maximum_runs'] = 1 config['models_configuration'][ 'employment_relocation_model_for_2000'] = {} config['models_configuration']['employment_relocation_model_for_2000']['controller'] = \ EmploymentRelocationModelConfigurationCreator( location_id_name = 'building_id', probabilities = None, rate_table=None, output_index = 'erm_index').execute() self.merge(config) if self.multiple_runs: self.sample_inputs()
def setUp(self): opus_core_path = package().get_opus_core_path() cache_dir = os.path.join(opus_core_path, 'data', 'test_cache') self.temp_dir = tempfile.mkdtemp(prefix='opus_tmp') run_dir = os.path.join(self.temp_dir, 'tests', 'runs') os.makedirs(run_dir) self.config = { 'models': ['my_regression_model', 'my_meta_model'], 'years': (1981, 1982), 'base_year': 1980, 'cache_directory': run_dir, 'models_configuration': { 'aging_model': { 'controller': { 'import': {'opus_core.simple_model': 'SimpleModel'}, 'init': {'name': 'SimpleModel'}, 'run': { 'arguments': { 'dataset': 'household', 'expression': "'household.age_of_head + 10'", 'outcome_attribute': "'age_of_head'", 'dataset_pool': 'dataset_pool' } } } }, 'my_meta_model': { 'controller': { 'import': {'opus_core.iterative_meta_model': 'IterativeMetaModel'}, 'init': {'arguments': {'models': ['aging_model'], 'configuration': 'resources', 'datasets_to_preload': ['household']}, 'name': 'IterativeMetaModel'}, 'run': {'arguments': { 'year': 'year', #'condition': "'alldata.aggregate_all(numpy.logical_not(household.age_of_head > 70)) == 0'", 'condition': "'household.age_of_head > 70'", } } } }, 'my_regression_model': { 'controller': { 'import': {'opus_core.regression_model': 'RegressionModel'}, 'init': {'arguments': {'dataset_pool': 'dataset_pool'}, 'name': 'RegressionModel'}, 'prepare_for_run': { 'arguments': { 'coefficients_storage': 'base_cache_storage', 'coefficients_table': "'land_price_model_coefficients'", 'specification_storage': 'base_cache_storage', 'specification_table': "'land_price_model_specification'", }, 'name': 'prepare_for_run', 'output': '(_specification, _coefficients, dummy)' }, 'run': { 'arguments': { 'coefficients': '_coefficients', 'specification': '_specification', 'dataset': 'gridcell' } } } }, }, 'datasets_to_preload': {'gridcell': {}}, 'creating_baseyear_cache_configuration': CreatingBaseyearCacheConfiguration( cache_directory_root = run_dir, cache_from_database = False, baseyear_cache = BaseyearCacheConfiguration(years_to_cache = [1980], existing_cache_to_copy = cache_dir) ), 'dataset_pool_configuration': DatasetPoolConfiguration( package_order=['urbansim', 'opus_core'], ), 'model_system':'urbansim.model_coordinators.model_system', } CacheFltData().run(self.config)