def get_configuration(self): run_configuration = Configuration(config) local_configuration = self.get_local_configuration() run_configuration.merge(local_configuration) return run_configuration
def __init__(self, model, specification_module=None, xml_configuration=None, model_group=None, configuration={}, save_estimation_results=False): """ If 'specification_module' is given, it contains the specification defined as a dictionary in a module. Alternatively, the specification can be passed in an xml format in the 'xml_configuration' argument (which should be an instance of XMLConfiguration). If both of those arguments are None, the specification is taken from the cache. 'configuration' is an Opus configuration. It can contain an entry 'config_changes_for_estimation' which is a dictionary where keys are model names and values are controller changes for that model. If 'configuration' is None, it is taken from 'xml_configuration'. If xml_configuration is used, and if it has a non-empty expression library, the dictionary representing the expression library is added to the configuration under the key 'expression_library'. If save_estimation_results is True, the estimation results are saved in the output configuration (if given in 'configuration') and in the cache. """ self.specification_module = specification_module self.xml_configuration = xml_configuration self.model_group = model_group self.estimated_model = model self.explored_model = model if configuration is None: if self.xml_configuration is None: raise StandardError, "Either dictionary based or XML based configuration must be given." config = self.xml_configuration.get_estimation_configuration(model, model_group) else: config = Configuration(configuration) config_changes = config.get('config_changes_for_estimation', {}) specification_dict=None if self.xml_configuration is not None: specification_dict = self.xml_configuration.get_estimation_specification(model, model_group) if model_group is None: if model in config_changes.keys(): config.merge(config_changes[model]) else: config['models'] = [{model: ["estimate"]}] if specification_module is not None: config = update_controller_by_specification_from_module( config, model, specification_module) elif specification_dict is not None: config = update_controller_by_specification_from_dict(config, model, specification_dict) else: if model in config_changes.keys(): if model_group in config_changes[model]: config.merge(config_changes[model][model_group]) else: config.merge(config_changes[model]) else: config['models'] = [{model: {"group_members": [{model_group: ["estimate"]}]}}] if (specification_module is not None) or (specification_dict is not None): if '%s_%s' % (model_group, model) in config["models_configuration"].keys(): model_name_in_configuration = '%s_%s' % (model_group, model) else: model_name_in_configuration = model if specification_module is not None: config = update_controller_by_specification_from_module(config, model_name_in_configuration, specification_module) config["models_configuration"][model_name_in_configuration]["controller"]["prepare_for_estimate"]["arguments"]["specification_dict"] = "spec['%s']" % model_group else: config = update_controller_by_specification_from_dict(config, model, specification_dict[model_group]) if model.startswith('%s_' % model_group): config['model_name_for_coefficients'] = model else: config['model_name_for_coefficients'] = '%s_%s' % (model_group, model) Estimator.__init__(self, config, save_estimation_results=save_estimation_results)
def get_configuration(self): run_configuration = Configuration(config) local_configuration = self.get_local_configuration() run_configuration.merge(local_configuration) return run_configuration
# Opus/UrbanSim urban simulation software. # Copyright (C) 2010-2011 University of California, Berkeley, 2005-2009 University of Washington # See opus_core/LICENSE from urbansim.configs.base_config_zone import run_configuration as config from urbansim.configs.estimation_base_config import estimation_configuration from opus_core.configuration import Configuration run_configuration = Configuration(config) run_configuration.merge(estimation_configuration) run_configuration["models_configuration"]["prepare_datasets_for_aggregation"]["controller"]["run"]["arguments"] = { "datasets_variables": "{household: ['urbansim.household.zone_id'], " + "job: ['urbansim.job.zone_id'], " + "building: ['urbansim.building.zone_id'], " + "zone: ['urbansim.zone.industrial_sqft_per_job', " + "'urbansim.zone.commercial_sqft_per_job', " + "'is_near_arterial = zone.aggregate(urbansim.gridcell.is_near_arterial, function=aggregate)', " + "'is_near_highway = zone.aggregate(urbansim.gridcell.is_near_highway, function=aggregate)', " + "'acres_of_land = zone.aggregate(urbansim.gridcell.acres_of_land)', " + "'urbansim.zone.avg_val_per_unit_commercial', " + "'urbansim.zone.avg_val_per_unit_industrial', " + "'urbansim.zone.avg_val_per_unit_governmental', " + "'urbansim.zone.avg_val_per_unit_vacant_land', " + "'urbansim.zone.avg_val_per_unit_residential', ]" + "}", "data_objects": "datasets" } run_configuration["models_configuration"]["household_location_choice_model"]["controller"]["run"]["arguments"]["maximum_runs"]=1 run_configuration["models_configuration"]["employment_location_choice_model"]["controller"]["run"]["arguments"]["maximum_runs"]=1
def __init__(self, model, specification_module=None, xml_configuration=None, model_group=None, configuration={}, save_estimation_results=False): """ If 'specification_module' is given, it contains the specification defined as a dictionary in a module. Alternatively, the specification can be passed in an xml format in the 'xml_configuration' argument (which should be an instance of XMLConfiguration). If both of those arguments are None, the specification is taken from the cache. 'configuration' is an Opus configuration. It can contain an entry 'config_changes_for_estimation' which is a dictionary where keys are model names and values are controller changes for that model. If 'configuration' is None, it is taken from 'xml_configuration'. If xml_configuration is used, and if it has a non-empty expression library, the dictionary representing the expression library is added to the configuration under the key 'expression_library'. If save_estimation_results is True, the estimation results are saved in the output configuration (if given in 'configuration') and in the cache. """ self.specification_module = specification_module self.xml_configuration = xml_configuration self.model_group = model_group self.estimated_model = model if configuration is None: if self.xml_configuration is None: raise StandardError, "Either dictionary based or XML based configuration must be given." config = self.xml_configuration.get_estimation_configuration( model, model_group) else: config = Configuration(configuration) config_changes = config.get('config_changes_for_estimation', {}) specification_dict = None if self.xml_configuration is not None: specification_dict = self.xml_configuration.get_estimation_specification( model, model_group) if model_group is None: if model in config_changes.keys(): config.merge(config_changes[model]) else: config['models'] = [{model: ["estimate"]}] if specification_module is not None: config = update_controller_by_specification_from_module( config, model, specification_module) elif specification_dict is not None: config = update_controller_by_specification_from_dict( config, model, specification_dict) else: if model in config_changes.keys(): if model_group in config_changes[model]: config.merge(config_changes[model][model_group]) else: config.merge(config_changes[model]) else: config['models'] = [{ model: { "group_members": [{ model_group: ["estimate"] }] } }] if (specification_module is not None) or (specification_dict is not None): if '%s_%s' % (model_group, model) in config["models_configuration"].keys(): model_name_in_configuration = '%s_%s' % (model_group, model) else: model_name_in_configuration = model if specification_module is not None: config = update_controller_by_specification_from_module( config, model_name_in_configuration, specification_module) config["models_configuration"][model_name_in_configuration][ "controller"]["prepare_for_estimate"]["arguments"][ "specification_dict"] = "spec['%s']" % model_group else: config = update_controller_by_specification_from_dict( config, model, specification_dict[model_group]) if model.startswith('%s_' % model_group): config['model_name_for_coefficients'] = model else: config['model_name_for_coefficients'] = '%s_%s' % (model_group, model) Estimator.__init__(self, config, save_estimation_results=save_estimation_results)
# Opus/UrbanSim urban simulation software. # Copyright (C) 2005-2009 University of Washington # See opus_core/LICENSE from urbansim.configs.base_config_zone import run_configuration as config from urbansim.configs.estimation_base_config import estimation_configuration from opus_core.configuration import Configuration run_configuration = Configuration(config) run_configuration.merge(estimation_configuration) run_configuration["models_configuration"]["prepare_datasets_for_aggregation"]["controller"]["run"]["arguments"] = { "datasets_variables": "{household: ['urbansim.household.zone_id'], " + "job: ['urbansim.job.zone_id'], " + "building: ['urbansim.building.zone_id'], " + "zone: ['urbansim.zone.industrial_sqft_per_job', " + "'urbansim.zone.commercial_sqft_per_job', " + "'is_near_arterial = zone.aggregate(urbansim.gridcell.is_near_arterial, function=aggregate)', " + "'is_near_highway = zone.aggregate(urbansim.gridcell.is_near_highway, function=aggregate)', " + "'acres_of_land = zone.aggregate(urbansim.gridcell.acres_of_land)', " + "'urbansim.zone.avg_val_per_unit_commercial', " + "'urbansim.zone.avg_val_per_unit_industrial', " + "'urbansim.zone.avg_val_per_unit_governmental', " + "'urbansim.zone.avg_val_per_unit_vacant_land', " + "'urbansim.zone.avg_val_per_unit_residential', ]" + "}", "data_objects": "datasets" } run_configuration["models_configuration"]["household_location_choice_model"]["controller"]["run"]["arguments"]["maximum_runs"]=1 run_configuration["models_configuration"]["employment_location_choice_model"]["controller"]["run"]["arguments"]["maximum_runs"]=1