Esempio n. 1
0
 def execute(self):
     result = GovernmentalEmploymentLocationChoiceModelConfigurationCreator.execute(self)
     result['import'] = {
             'psrc_parcel.models.%s' % self._model_name: 'ScalingJobsModelByGeography'
             }
     result['init']['name'] = 'ScalingJobsModelByGeography'
     result["run"]["arguments"]["geography_set"] = 'zone'
     return result
Esempio n. 2
0
 def execute(self):
     conf = GovernmentalEmploymentLocationChoiceModelConfigurationCreator.execute(
         self)
     conf['import'] = {
         'washtenaw.models.regional_scaling_jobs_model':
         'RegionalScalingJobsModel'
     }
     conf['init']['name'] = 'RegionalScalingJobsModel'
     return conf
 def execute(self):  
     conf = GovernmentalEmploymentLocationChoiceModelConfigurationCreator.execute(self)
     conf['import'] = {'washtenaw.models.regional_scaling_jobs_model': 'RegionalScalingJobsModel'}
     conf['init']['name'] = 'RegionalScalingJobsModel'
     return conf
    def _get_initial_config(self):
        """Encapsulate dirty inner workings"""
        debuglevel = 4

        config = {
            'models_configuration': {
                'development_project_types': DevelopmentProjectTypesConfigurationCreator(
                    commercial = DevelopmentProjectTypeConfigurationCreator(
                        categories = [1000, 2000, 5000, 10000],
                        #categories = [],
                        developable_maximum_unit_variable_full_name = 'urbansim.gridcell.developable_maximum_commercial_sqft',
                        developable_minimum_unit_variable_full_name = 'urbansim.gridcell.developable_minimum_commercial_sqft',
                        residential = False,
                        units = 'commercial_sqft',
                        ),
                    industrial = DevelopmentProjectTypeConfigurationCreator(
                        categories = [1000,2000,5000,10000],
                        #categories = [],
                        developable_maximum_unit_variable_full_name = 'urbansim.gridcell.developable_maximum_industrial_sqft',
                        developable_minimum_unit_variable_full_name = 'urbansim.gridcell.developable_minimum_industrial_sqft',
                        residential = False,
                        units = 'industrial_sqft',
                        ),
                    residential = DevelopmentProjectTypeConfigurationCreator(
                        categories = [1,2,3,5,10,20],
                        #categories = [],
                        developable_maximum_unit_variable_full_name = 'urbansim.gridcell.developable_maximum_residential_units',
                        developable_minimum_unit_variable_full_name = 'urbansim.gridcell.developable_minimum_residential_units',
                        residential = True,
                        units = 'residential_units',
                        )
                    ).execute(),
                'residential_development_project_location_choice_model':{
                    'controller': DevelopmentProjectLocationChoiceModelConfigurationCreator(
                        project_type = 'residential',
                        coefficients_table = 'residential_development_location_choice_model_coefficients',
                        specification_table = 'residential_development_location_choice_model_specification',
                        #submodel_string = None
                        ).execute(),
                    },
                'commercial_development_project_location_choice_model':{
                    'controller': DevelopmentProjectLocationChoiceModelConfigurationCreator(
                        project_type = 'commercial',
                        coefficients_table = 'commercial_development_location_choice_model_coefficients',
                        specification_table = 'commercial_development_location_choice_model_specification',
                        #submodel_string = None
                        ).execute(),
                    },
                'industrial_development_project_location_choice_model':{
                    'controller': DevelopmentProjectLocationChoiceModelConfigurationCreator(
                        project_type = 'industrial',
                        coefficients_table = 'industrial_development_location_choice_model_coefficients',
                        specification_table = 'industrial_development_location_choice_model_specification',
                        #submodel_string = None
                        ).execute(),
                    },
                'prescheduled_events': {
                    'controller': PrescheduledEventsConfigurationCreator(
                        output_events = 'development_events',
                        ).execute(),
                    },
                'events_coordinator': {
                    'controller': EventsCoordinatorConfigurationCreator(
                        input_events = 'development_events',
                        output_changed_indices = 'changed_indices',
                        ).execute(),
                    'default_type_of_change':DevelopmentEventTypeOfChange.ADD,
                    },
                'home_based_choice_model': {
                    'controller': HomeBasedChoiceModelConfigurationCreator().execute(),
                    },
                'auto_ownership_choice_model': {
                    'controller': AutoOwnershipChoiceModelConfigurationCreator().execute(),
                    },
                'residential_land_share_model': {
                    'controller': ResidentialLandShareModelConfigurationCreator(
                        debuglevel = debuglevel,
                        input_changed_indices = 'changed_indices',
                        ).execute(),
                    },
                'land_price_model': {
                    'controller': LandPriceModelConfigurationCreator(
                        debuglevel = debuglevel,
                        ).execute(),
                    },
                'development_project_transition_model': {
                    'controller': DevelopmentProjectTransitionModelConfigurationCreator(
                        debuglevel = debuglevel,
                        output_results = 'dptm_results',
                        ).execute(),
                    },
                'development_event_transition_model': {
                    'controller': DevelopmentEventTransitionModelConfigurationCreator(
                        input_projects = 'dptm_results',
                        output_events = 'development_events',
                        ).execute(),
                    },
                'household_transition_model': {
                    'controller': HouseholdTransitionModelConfigurationCreator().execute(),
                    },
                'employment_transition_model': {
                    'controller': EmploymentTransitionModelConfigurationCreator().execute(),
                    },
                'household_relocation_model': {
                    'controller': HouseholdRelocationModelConfigurationCreator(
                        output_index = 'hrm_index',
                        ).execute(),
                    },
                'household_location_choice_model': {
                    'controller': HouseholdLocationChoiceModelConfigurationCreator(
                        input_index = 'hrm_index',
                        ).execute(),
                    },
                'employment_relocation_model': {
                    'controller': EmploymentRelocationModelConfigurationCreator(
                        output_index = 'erm_index',
                        ).execute(),
                    },
                'employment_location_choice_model': {
                    'controller': EmploymentLocationChoiceModelConfigurationCreator(
                        input_index = 'erm_index',
                        ).execute(),
                    },
                # These are deviations from the general ELCM for the two home_based ELCMs (sfh, mfh)
                'home_based_employment_location_choice_model': {
                    'controller': HomeBasedEmploymentLocationChoiceModelConfigurationCreator(
                        input_index = 'erm_index',
                        ).execute(),
                    },
                'governmental_employment_location_choice_model': {
                    'controller': GovernmentalEmploymentLocationChoiceModelConfigurationCreator(
                        input_index = 'erm_index',
                        ).execute(),
                    },
                'distribute_unplaced_jobs_model': {
                    'controller': DistributeUnplacedJobsModelConfigurationCreator().execute(),
                    },
                'real_estate_price_model': {
                    'controller': RealEstatePriceModelConfigurationCreator().execute(),
                    },
                'building_transition_model': {
                    'controller': BuildingTransitionModelConfigurationCreator().execute(),
                    },
                'building_relocation_model': {
                    'controller': BuildingRelocationModelConfigurationCreator(
                        output_index = 'brm_index',
                        ).execute(),
                    },
                'building_location_choice_model': {
                    'controller': BuildingLocationChoiceModelConfigurationCreator(
                        input_index = 'brm_index',
                        ).execute(),
                    },
                },
            'model_system':'urbansim.model_coordinators.model_system',
            'models':[ # models are executed in the same order as in this list
                "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"
                ],
            'years':(2001, 2030),
            'debuglevel':debuglevel,
            'flush_variables':False,
            'seed':None,#(0,0),
            'chunk_specification':{ # Default value
                'nchunks':1,
                },
            'datasets_to_cache_after_each_model':[ # datasets to be cached after each model,
                'gridcell',
                'household',
                'job'],
            'datasets_to_preload': { # Datasets that should be loaded before each year, e.g. in order to pass them as model arguments.
                'gridcell':{         # All remaining datasets are used via SessionConfiguration
                    'nchunks':2
                    },               # linked to the cache.
                'household':{
                    },
                'job':{
                    },
                'zone':{
                    },
                'development_type':{},
                'target_vacancy':{},
                'development_event_history':{},
                'development_constraint':{},
                'job_building_type':{},
                #                'building_type':{},
                #                'building':{},
                'vacant_land_and_building_type':{},
                'urbansim_constant':{},
                },
            'dataset_pool_configuration': DatasetPoolConfiguration(
                package_order=['urbansim', 'opus_core'],
                ),
            'services_database_configuration':ServicesDatabaseConfiguration(),
            }

        return config
    def __init__(self):
        Configuration.__init__(self)
        self['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',
        ]
        self['model_system'] = 'urbansim.model_coordinators.model_system'
        my_controller_configuration = {
            'real_estate_price_model':
            RealEstatePriceModelConfigurationCreator(
                dataset='building',
                outcome_attribute='ln_unit_price=ln(building.avg_value)',
                submodel_string='building_type_id',
                filter_variable=None,
            ).execute(),
            'residential_development_project_location_choice_model':
            DevelopmentProjectLocationChoiceModelConfigurationCreator(
                project_type='residential',
                coefficients_table=
                'residential_development_location_choice_model_coefficients',
                specification_table=
                'residential_development_location_choice_model_specification',
                units='residential_units',
                sampler=None,
                capacity_string=
                'urbansim_zone.zone.developable_residential_units',
            ).execute(),
            'commercial_development_project_location_choice_model':
            DevelopmentProjectLocationChoiceModelConfigurationCreator(
                project_type='commercial',
                coefficients_table=
                'commercial_development_location_choice_model_coefficients',
                specification_table=
                'commercial_development_location_choice_model_specification',
                units='commercial_job_spaces',
                sampler=None,
            ).execute(),
            'industrial_development_project_location_choice_model':
            DevelopmentProjectLocationChoiceModelConfigurationCreator(
                project_type='industrial',
                coefficients_table=
                'industrial_development_location_choice_model_coefficients',
                specification_table=
                'industrial_development_location_choice_model_specification',
                units='industrial_job_spaces',
                sampler=None,
            ).execute(),
            'development_project_transition_model':
            DevelopmentProjectTransitionModelConfigurationCreator(
                vacancy_variables={
                    "commercial":
                    "urbansim_zone.zone.number_of_vacant_commercial_jobs",
                    "industrial":
                    "urbansim_zone.zone.number_of_vacant_industrial_jobs"
                },
                output_results='dptm_results',
            ).execute(),
            'add_projects_to_buildings':
            AddProjectsToBuildingsConfigurationCreator().execute(),
            'employment_transition_model':
            EmploymentTransitionModelConfigurationCreator(
                location_id_name="zone_id", ).execute(),
            'household_transition_model':
            HouseholdTransitionModelConfigurationCreator(
                location_id_name="zone_id", ).execute(),
            'employment_relocation_model':
            EmploymentRelocationModelConfigurationCreator(
                location_id_name='zone_id',
                output_index='erm_index').execute(),
            'household_relocation_model':
            HouseholdRelocationModelConfigurationCreator(
                location_id_name='zone_id',
                output_index='hrm_index',
            ).execute(),
            'household_location_choice_model':
            HouseholdLocationChoiceModelConfigurationCreator(
                location_set="zone",
                capacity_string='urbansim_zone.zone.vacant_residential_units',
                estimation_weight_string=
                'urbansim_zone.zone.vacant_residential_units',
                portion_to_unplace=1 / 3.0,
                nchunks=3,
                number_of_units_string=None,
                input_index='hrm_index',
            ).execute(),
            'employment_location_choice_model':
            EmploymentLocationChoiceModelConfigurationCreator(
                location_set="zone",
                input_index='erm_index',
                agents_for_estimation_table="jobs_for_estimation",
                estimation_weight_string=None,
                number_of_units_string=None,
                portion_to_unplace=0,
                capacity_string="urbansim_zone.zone.number_of_vacant_SSS_jobs",
            ).execute(),
            'home_based_employment_location_choice_model':
            EmploymentLocationChoiceModelConfigurationCreator(
                location_set="zone",
                input_index='erm_index',
                estimation_weight_string="urbansim.zone.number_of_households",
                agents_for_estimation_table=
                None,  # will take standard jobs table 
                estimation_size_agents=0.5,
                number_of_units_string=None,
                portion_to_unplace=0,
                capacity_string="urbansim.zone.number_of_households",
            ).execute(),
            'governmental_employment_location_choice_model':
            GovernmentalEmploymentLocationChoiceModelConfigurationCreator(
                input_index='erm_index', location_set='zone').execute(),
            'distribute_unplaced_jobs_model':
            DistributeUnplacedJobsModelConfigurationCreator(
                location_set='zone').execute(),
        }
        self['models_configuration'] = {}
        for model in my_controller_configuration.keys():
            if model not in self["models_configuration"].keys():
                self["models_configuration"][model] = {}
            self['models_configuration'][model][
                'controller'] = my_controller_configuration[model]

        self["datasets_to_preload"] = {
            'building': {},
            'zone': {},
            'household': {},
            'job': {},
            'job_building_type': {},
            'target_vacancy': {},
            'development_event_history': {},
            'building_type': {}
        }