コード例 #1
0
    def __init__(self, location_set,
            sampler = "opus_core.samplers.weighted_sampler", 
            utilities = "opus_core.linear_utilities", 
            choices = "opus_core.random_choices", 
            probabilities = "opus_core.mnl_probabilities",
            estimation = "opus_core.bhhh_mnl_estimation",
            capacity_string = "vacant_residential_units",
            estimation_weight_string = "residential_units", 
            simulation_weight_string = None, # if this is None, weights are proportional to the capacity 
            number_of_agents_string = "number_of_households",
            number_of_units_string = "residential_units",            
            sample_proportion_locations = None, 
            sample_size_locations = 30, 
            estimation_size_agents = 1.0, 
            compute_capacity_flag = True, 
            filter=None,
            submodel_string = None, location_id_string = None,
            demand_string = None, # if not None, the aggregate demand for locations will be stored in this attribute
            run_config = None, estimate_config=None, debuglevel=0, dataset_pool=None,
            variable_package="urbansim",
            model_name=None,
            model_short_name=None,
            **kwargs):
        run_config = merge_resources_if_not_None(run_config, [ 
                    ("sample_proportion_locations", sample_proportion_locations), 
                    ("sample_size_locations", sample_size_locations), 
                    ("compute_capacity_flag", compute_capacity_flag),
                    ("capacity_string", capacity_string),
                    ("number_of_agents_string", number_of_agents_string),
                    ("number_of_units_string", number_of_units_string),
                    ("weights_for_simulation_string", simulation_weight_string),
                    ("demand_string", demand_string)                                                          
                                          ])
        estimate_config = merge_resources_if_not_None(estimate_config, [ 
                    ("estimation", estimation), 
                    ("sample_proportion_locations", sample_proportion_locations), 
                    ("sample_size_locations", sample_size_locations), 
                    ("estimation_size_agents", estimation_size_agents),
                    ("weights_for_estimation_string", estimation_weight_string)])         

        if model_name is not None:
            self.model_name = model_name
        if model_short_name is not None:
            self.model_short_name = model_short_name

        AgentLocationChoiceModel.__init__(self, location_set,
                                        model_name=self.model_name, 
                                        short_name=self.model_short_name, 
                                        sampler=sampler, 
                                        utilities=utilities, 
                                        probabilities=probabilities, 
                                        choices=choices, 
                                        filter=filter, 
                                        submodel_string=submodel_string,  
                                        location_id_string=location_id_string,
                                        run_config=run_config, 
                                        estimate_config=estimate_config, 
                                        debuglevel=debuglevel, dataset_pool=dataset_pool,
                                        variable_package=variable_package,
                                        **kwargs)
    def get_model(self, location_set,
            sampler = "opus_core.samplers.weighted_sampler", 
            utilities = "opus_core.linear_utilities", 
            choices = "opus_core.random_choices", 
            probabilities = "opus_core.mnl_probabilities", 
            estimation = "opus_core.bhhh_mnl_estimation", 
            sample_proportion_locations = None, 
            sample_size_locations = 20, 
            estimation_size_agents = 1.0, 
            compute_capacity_flag = False, 
            filter = None,
            submodel_string = "sector_id",
            run_config = None, estimate_config=None, debuglevel=0):
        run_config = merge_resources_if_not_None(run_config, [ 
            ("sample_proportion_locations", sample_proportion_locations), 
            ("sample_size_locations", sample_size_locations), 
            ("compute_capacity_flag", compute_capacity_flag)])
        run_config = merge_resources_with_defaults(run_config, 
            [("capacity_string", self.capacity_string_default)])
        estimate_config = merge_resources_if_not_None(estimate_config, [ 
                    ("estimation", estimation), 
                    ("sample_proportion_locations", sample_proportion_locations), 
                    ("sample_size_locations", sample_size_locations), 
                    ("estimation_size_agents", estimation_size_agents)])         
        estimate_config = merge_resources_with_defaults(estimate_config, 
            [("weights_for_estimation_string", self.estimation_weight_string_default)])

        return AgentLocationChoiceModel(location_set, agent_name="job", 
            model_name="Employment Location Choice Model", \
            short_name="ELCM", sampler=sampler, utilities=utilities, 
            probabilities=probabilities, choices=choices, filter=filter, submodel_string=submodel_string, 
            run_config=run_config, estimate_config=estimate_config, 
            debuglevel=debuglevel)
 def __init__(self, 
               project_type,
               location_set,
               model_configuration,
               sampler = "opus_core.samplers.weighted_sampler", 
               utilities = "opus_core.linear_utilities", 
               choices = "urbansim.first_agent_first_choices", 
               probabilities = "opus_core.mnl_probabilities", 
               estimation = "opus_core.bhhh_mnl_estimation", 
               sample_proportion_locations = None, 
               sample_size_locations = 30, 
               estimation_size_agents = 1.0, 
               compute_capacity_flag = True, 
               filter = "",
               submodel_string = "size_category", 
               location_id_string = None,
               run_config = None, 
               estimate_config=None, 
               debuglevel=0):
     units = model_configuration['units']
     developable_maximum_unit_variable_full_name = model_configuration['developable_maximum_unit_variable_full_name']
     developable_minimum_unit_variable_full_name = model_configuration['developable_minimum_unit_variable_full_name']
     
     default_capacity_attribute = "urbansim.gridcell.is_developable_for_%s" % units
     default_filter = "urbansim.gridcell.developable_%s" % units
     if filter == "":
         filter = default_filter
     run_config = merge_resources_if_not_None(run_config, [ 
         ("sample_proportion_locations", sample_proportion_locations), 
         ("sample_size_locations", sample_size_locations), 
         ("compute_capacity_flag", compute_capacity_flag)])
     run_config = merge_resources_with_defaults(run_config, 
         [("capacity_string", default_capacity_attribute)])
     estimate_config = merge_resources_if_not_None(estimate_config, [ 
                 ("estimation", estimation), 
                 ("sample_proportion_locations", sample_proportion_locations), 
                 ("sample_size_locations", sample_size_locations), 
                 ("estimation_size_agents", estimation_size_agents)])         
     estimate_config = merge_resources_with_defaults(estimate_config, 
         [("weights_for_estimation_string", self.estimation_weight_string_default)])
     
     DevelopmentProjectLocationChoiceModel.__init__(self, location_set, 
                                                  project_type=project_type, 
                                                  units=units,
                                                  developable_maximum_unit_variable_full_name=developable_maximum_unit_variable_full_name,
                                                  developable_minimum_unit_variable_full_name=developable_minimum_unit_variable_full_name,
                                                  model_name="Regional Development Project %s Location Choice Model" % project_type,
                                                  sampler=sampler, 
                                                  utilities=utilities, 
                                                  probabilities=probabilities, 
                                                  choices=choices, 
                                                  filter=filter,
                                                  submodel_string=submodel_string, 
                                                  location_id_string = location_id_string,
                                                  run_config=run_config, 
                                                  estimate_config=estimate_config, 
                                                  debuglevel=debuglevel)
コード例 #4
0
 def get_model(
         self,
         location_set,
         sampler="opus_core.samplers.weighted_sampler",
         utilities="opus_core.linear_utilities",
         choices="opus_core.random_choices",
         probabilities="opus_core.mnl_probabilities",
         estimation="opus_core.bhhh_mnl_estimation",
         sample_proportion_locations=None,
         sample_size_locations=30,
         estimation_size_agents=1.0,
         compute_capacity_flag=True,
         filter=None,
         submodel_string=None,
         location_id_string=None,
         demand_string=None,  # if not None, the aggregate demand for locations will be stored in this attribute
         run_config=None,
         estimate_config=None,
         debuglevel=0,
         dataset_pool=None):
     run_config = merge_resources_if_not_None(
         run_config,
         [("sample_proportion_locations", sample_proportion_locations),
          ("sample_size_locations", sample_size_locations),
          ("compute_capacity_flag", compute_capacity_flag)])
     run_config = merge_resources_with_defaults(
         run_config,
         [("capacity_string", self.capacity_string_default),
          ("number_of_agents_string", self.number_of_agents_string_default),
          ("number_of_units_string", self.number_of_units_string_default)])
     if demand_string:
         run_config["demand_string"] = demand_string
     estimate_config = merge_resources_if_not_None(
         estimate_config,
         [("estimation", estimation),
          ("sample_proportion_locations", sample_proportion_locations),
          ("sample_size_locations", sample_size_locations),
          ("estimation_size_agents", estimation_size_agents)])
     estimate_config = merge_resources_with_defaults(
         estimate_config, [("weights_for_estimation_string",
                            self.estimation_weight_string_default)])
     return AgentLocationChoiceModel(
         location_set,
         model_name="Household Location Choice Model",
         short_name="HLCM",
         sampler=sampler,
         utilities=utilities,
         probabilities=probabilities,
         choices=choices,
         filter=filter,
         submodel_string=submodel_string,
         location_id_string=location_id_string,
         run_config=run_config,
         estimate_config=estimate_config,
         debuglevel=debuglevel,
         dataset_pool=dataset_pool)
コード例 #5
0
    def get_model(self, 
                  location_set,
                  sampler = "opus_core.samplers.weighted_sampler", 
                  utilities = "opus_core.linear_utilities", 
                  choices = "urbansim.first_agent_first_choices", 
                  probabilities = "opus_core.mnl_probabilities", 
                  estimation = "opus_core.bhhh_mnl_estimation", 
                  sample_proportion_locations = None, 
                  sample_size_locations = 30, 
                  estimation_size_agents = 1.0, 
                  compute_capacity_flag = True, 
                  filter = "randstad.gridcell.is_developable",
                  submodel_string = "development_type_id",
                  run_config = None, 
                  estimate_config=None, 
                  debuglevel=0):

        default_capacity_string = "randstad.gridcell.is_developable"
        run_config = merge_resources_if_not_None(run_config, [ 
            ("sample_proportion_locations", sample_proportion_locations), 
            ("sample_size_locations", sample_size_locations), 
            ("compute_capacity_flag", compute_capacity_flag)
            ("filter", filter)])
        run_config = merge_resources_with_defaults(run_config, 
            [("capacity_string", default_capacity_string),
            ("simulation_sampling_include_current_choice", False)])
        estimate_config = merge_resources_if_not_None(estimate_config, [ 
                    ("estimation", estimation), 
                    ("sample_proportion_locations", sample_proportion_locations), 
                    ("sample_size_locations", sample_size_locations), 
                    ("estimation_size_agents", estimation_size_agents)])         
        estimate_config = merge_resources_with_defaults(estimate_config, 
            [("weights_for_estimation_string", self.estimation_weight_string_default),
            ("simulation_sampling_include_current_choice", True)])
        
        return LandUseDevelopmentLocationChoiceModel(location_set, 
                                                     opus_package='randstad',
                                                     model_name="Landuse Development Location Choice Model",
                                                     sampler=sampler, 
                                                     utilities=utilities, 
                                                     probabilities=probabilities, 
                                                     choices=choices, 
                                                     filter=filter,
                                                     submodel_string=submodel_string, 
                                                     run_config=run_config, 
                                                     estimate_config=estimate_config, 
                                                     debuglevel=debuglevel)

        
コード例 #6
0
 def get_model(self, location_set,
         sampler = "opus_core.samplers.weighted_sampler", 
         utilities = "opus_core.linear_utilities", 
         choices = "opus_core.random_choices", 
         probabilities = "opus_core.mnl_probabilities", 
         estimation = "opus_core.bhhh_mnl_estimation", 
         sample_proportion_locations = None, 
         sample_size_locations = 30, 
         estimation_size_agents = 1.0, 
         compute_capacity_flag = True, 
         filter=None,
         submodel_string = None, location_id_string = None,
         demand_string = None, # if not None, the aggregate demand for locations will be stored in this attribute
         run_config = None, estimate_config=None, debuglevel=0, dataset_pool=None):
     run_config = merge_resources_if_not_None(run_config, [ 
                 ("sample_proportion_locations", sample_proportion_locations), 
                 ("sample_size_locations", sample_size_locations), 
                 ("compute_capacity_flag", compute_capacity_flag)])
     run_config = merge_resources_with_defaults(run_config, 
         [("capacity_string", self.capacity_string_default),
         ("number_of_agents_string", self.number_of_agents_string_default),
         ("number_of_units_string", self.number_of_units_string_default)
           ])
     if demand_string:
         run_config["demand_string"] = demand_string
     estimate_config = merge_resources_if_not_None(estimate_config, [ 
                 ("estimation", estimation), 
                 ("sample_proportion_locations", sample_proportion_locations), 
                 ("sample_size_locations", sample_size_locations), 
                 ("estimation_size_agents", estimation_size_agents)])         
     estimate_config = merge_resources_with_defaults(estimate_config, 
         [("weights_for_estimation_string", self.estimation_weight_string_default)])
     return AgentLocationChoiceModel(location_set,
                                     model_name="Household Location Choice Model", 
                                     short_name="HLCM", 
                                     sampler=sampler, 
                                     utilities=utilities, 
                                     probabilities=probabilities, 
                                     choices=choices, 
                                     filter=filter, 
                                     submodel_string=submodel_string,  
                                     location_id_string=location_id_string,
                                     run_config=run_config, 
                                     estimate_config=estimate_config, 
                                     debuglevel=debuglevel, dataset_pool=dataset_pool)
コード例 #7
0
    def get_model(self,
                  location_set,
                  sampler="opus_core.samplers.weighted_sampler",
                  utilities="opus_core.linear_utilities",
                  choices="opus_core.random_choices",
                  probabilities="opus_core.mnl_probabilities",
                  estimation="opus_core.bhhh_mnl_estimation",
                  sample_proportion_locations=None,
                  sample_size_locations=20,
                  estimation_size_agents=1.0,
                  compute_capacity_flag=False,
                  filter=None,
                  submodel_string="sector_id",
                  run_config=None,
                  estimate_config=None,
                  debuglevel=0):
        run_config = merge_resources_if_not_None(
            run_config,
            [("sample_proportion_locations", sample_proportion_locations),
             ("sample_size_locations", sample_size_locations),
             ("compute_capacity_flag", compute_capacity_flag)])
        run_config = merge_resources_with_defaults(
            run_config, [("capacity_string", self.capacity_string_default)])
        estimate_config = merge_resources_if_not_None(
            estimate_config,
            [("estimation", estimation),
             ("sample_proportion_locations", sample_proportion_locations),
             ("sample_size_locations", sample_size_locations),
             ("estimation_size_agents", estimation_size_agents)])
        estimate_config = merge_resources_with_defaults(
            estimate_config, [("weights_for_estimation_string",
                               self.estimation_weight_string_default)])

        return AgentLocationChoiceModel(location_set, agent_name="job",
            model_name="Employment Location Choice Model", \
            short_name="ELCM", sampler=sampler, utilities=utilities,
            probabilities=probabilities, choices=choices, filter=filter, submodel_string=submodel_string,
            run_config=run_config, estimate_config=estimate_config,
            debuglevel=debuglevel)
コード例 #8
0
ファイル: rate_based_model.py プロジェクト: psrc/urbansim
 def __init__(self,
              probabilities = "opus_core.upc.rate_based_probabilities",
              choices = "opus_core.random_choices",
              model_name = None,
              debuglevel=0,
              resources=None
              ):
     if model_name is not None:
         self.model_name = model_name
     self.debug = DebugPrinter(debuglevel)
     self.upc_sequence = None
     if probabilities is not None:
         self.upc_sequence = UPCFactory().get_model(utilities=None,
                                                    probabilities=probabilities,
                                                    choices=choices,
                                                    debuglevel=debuglevel)
     self.resources = merge_resources_if_not_None(resources)
コード例 #9
0
 def __init__(self,
              probabilities = "urbansim.rate_based_probabilities",
              choices = "opus_core.random_choices",
              location_id_name="grid_id",
              model_name = "Agent Relocation Model",
              debuglevel=0,
              resources=None
              ):
     self.model_name = model_name
     self.location_id_name = location_id_name
     self.debug = DebugPrinter(debuglevel)
     self.upc_sequence = None
     if probabilities is not None:
         self.upc_sequence = UPCFactory().get_model(utilities=None,
                                                    probabilities=probabilities,
                                                    choices=choices,
                                                    debuglevel=debuglevel)
     self.resources = merge_resources_if_not_None(resources)
コード例 #10
0
 def __init__(self,
              probabilities="urbansim.rate_based_probabilities",
              choices="opus_core.random_choices",
              location_id_name="grid_id",
              model_name="Agent Relocation Model",
              debuglevel=0,
              resources=None):
     self.model_name = model_name
     self.location_id_name = location_id_name
     self.debug = DebugPrinter(debuglevel)
     self.upc_sequence = None
     if probabilities is not None:
         self.upc_sequence = UPCFactory().get_model(
             utilities=None,
             probabilities=probabilities,
             choices=choices,
             debuglevel=debuglevel)
     self.resources = merge_resources_if_not_None(resources)
コード例 #11
0
    def __init__(
            self,
            location_set,
            sampler="opus_core.samplers.weighted_sampler",
            utilities="opus_core.linear_utilities",
            choices="opus_core.random_choices",
            probabilities="opus_core.mnl_probabilities",
            estimation="opus_core.bhhh_mnl_estimation",
            capacity_string="vacant_residential_units",
            estimation_weight_string="residential_units",
            simulation_weight_string=None,  # if this is None, weights are proportional to the capacity 
            number_of_agents_string="number_of_households",
            number_of_units_string="residential_units",
            sample_proportion_locations=None,
            sample_size_locations=30,
            estimation_size_agents=1.0,
            compute_capacity_flag=True,
            filter=None,
            submodel_string=None,
            location_id_string=None,
            demand_string=None,  # if not None, the aggregate demand for locations will be stored in this attribute
            run_config=None,
            estimate_config=None,
            debuglevel=0,
            dataset_pool=None,
            variable_package="urbansim"):
        run_config = merge_resources_if_not_None(
            run_config,
            [("sample_proportion_locations", sample_proportion_locations),
             ("sample_size_locations", sample_size_locations),
             ("compute_capacity_flag", compute_capacity_flag),
             ("capacity_string", capacity_string),
             ("number_of_agents_string", number_of_agents_string),
             ("number_of_units_string", number_of_units_string),
             ("weights_for_simulation_string", simulation_weight_string),
             ("demand_string", demand_string)])
        estimate_config = merge_resources_if_not_None(
            estimate_config,
            [("estimation", estimation),
             ("sample_proportion_locations", sample_proportion_locations),
             ("sample_size_locations", sample_size_locations),
             ("estimation_size_agents", estimation_size_agents),
             ("weights_for_estimation_string", estimation_weight_string)])

        AgentLocationChoiceModel.__init__(
            self,
            location_set,
            model_name=self.model_name,
            short_name=self.model_short_name,
            sampler=sampler,
            utilities=utilities,
            probabilities=probabilities,
            choices=choices,
            filter=filter,
            submodel_string=submodel_string,
            location_id_string=location_id_string,
            run_config=run_config,
            estimate_config=estimate_config,
            debuglevel=debuglevel,
            dataset_pool=dataset_pool,
            variable_package=variable_package)
コード例 #12
0
    def __init__(
            self,
            group_member,
            location_set,
            agents_grouping_attribute='job.building_type',
            sampler="opus_core.samplers.weighted_sampler",
            utilities="opus_core.linear_utilities",
            choices="opus_core.random_choices",
            probabilities="opus_core.mnl_probabilities",
            estimation="opus_core.bhhh_mnl_estimation",
            capacity_string="vacant_SSS_job_space",
            estimation_weight_string="total_number_of_possible_SSS_jobs",
            simulation_weight_string=None,  # if this is None, weights are proportional to the capacity 
            number_of_agents_string="number_of_SSS_jobs",
            number_of_units_string="total_number_of_possible_SSS_jobs",
            sample_proportion_locations=None,
            sample_size_locations=30,
            estimation_size_agents=1.0,
            compute_capacity_flag=True,
            filter=None,
            submodel_string="sector_id",
            location_id_string=None,
            demand_string=None,  # if not None, the aggregate demand for locations will be stored in this attribute
            run_config=None,
            estimate_config=None,
            debuglevel=0,
            dataset_pool=None,
            variable_package="urbansim"):
        """ 'group_member' is of type ModelGroupMember. All SSS in variable names are replaced by the group member name.
        """
        group_member_name = group_member.get_member_name()
        if capacity_string:
            capacity_string = re.sub('SSS', group_member_name, capacity_string)
        if estimation_weight_string:
            estimation_weight_string = re.sub('SSS', group_member_name,
                                              estimation_weight_string)
        if simulation_weight_string:
            simulation_weight_string = re.sub('SSS', group_member_name,
                                              simulation_weight_string)
        if number_of_agents_string:
            number_of_agents_string = re.sub('SSS', group_member_name,
                                             number_of_agents_string)
        if number_of_units_string:
            number_of_units_string = re.sub('SSS', group_member_name,
                                            number_of_units_string)
        if demand_string:
            demand_string = re.sub('SSS', group_member_name, demand_string)

        run_config = merge_resources_if_not_None(
            run_config,
            [("sample_proportion_locations", sample_proportion_locations),
             ("sample_size_locations", sample_size_locations),
             ("compute_capacity_flag", compute_capacity_flag),
             ("capacity_string", capacity_string),
             ("number_of_agents_string", number_of_agents_string),
             ("number_of_units_string", number_of_units_string),
             ("weights_for_simulation_string", simulation_weight_string),
             ("demand_string", demand_string)])

        estimate_config = merge_resources_if_not_None(
            estimate_config,
            [("estimation", estimation),
             ("sample_proportion_locations", sample_proportion_locations),
             ("sample_size_locations", sample_size_locations),
             ("estimation_size_agents", estimation_size_agents),
             ("weights_for_estimation_string", estimation_weight_string)])

        AgentLocationChoiceModelMember.__init__(
            self,
            group_member,
            location_set,
            agents_grouping_attribute,
            model_name="Employment Location Choice Model",
            short_name="ELCM",
            sampler=sampler,
            utilities=utilities,
            probabilities=probabilities,
            choices=choices,
            filter=filter,
            submodel_string=submodel_string,
            location_id_string=location_id_string,
            run_config=run_config,
            estimate_config=estimate_config,
            debuglevel=debuglevel,
            dataset_pool=dataset_pool,
            variable_package=variable_package)
コード例 #13
0
    def __init__(self, group_member, location_set, 
            agents_grouping_attribute = 'job.building_type',
            sampler = "opus_core.samplers.weighted_sampler", 
            utilities = "opus_core.linear_utilities", 
            choices = "opus_core.random_choices", 
            probabilities = "opus_core.mnl_probabilities", 
            estimation = "opus_core.bhhh_mnl_estimation", 
            capacity_string = "vacant_SSS_job_space",
            estimation_weight_string = "total_number_of_possible_SSS_jobs",
            simulation_weight_string = None, # if this is None, weights are proportional to the capacity 
            number_of_agents_string = "number_of_SSS_jobs",
            number_of_units_string = "total_number_of_possible_SSS_jobs",
            sample_proportion_locations = None, 
            sample_size_locations = 30, 
            estimation_size_agents = 1.0, 
            compute_capacity_flag = True, 
            filter = None,
            submodel_string = "sector_id", location_id_string = None,
            demand_string = None, # if not None, the aggregate demand for locations will be stored in this attribute
            run_config = None, estimate_config=None, debuglevel=0, dataset_pool=None,
            variable_package="urbansim"):
        """ 'group_member' is of type ModelGroupMember. All SSS in variable names are replaced by the group member name.
        """
        group_member_name = group_member.get_member_name()
        if capacity_string:
            capacity_string = re.sub('SSS', group_member_name, capacity_string)
        if estimation_weight_string:
            estimation_weight_string = re.sub('SSS', group_member_name, estimation_weight_string)
        if simulation_weight_string:
            simulation_weight_string = re.sub('SSS', group_member_name, simulation_weight_string)
        if number_of_agents_string:
            number_of_agents_string = re.sub('SSS', group_member_name, number_of_agents_string)
        if number_of_units_string:
            number_of_units_string = re.sub('SSS', group_member_name, number_of_units_string)
        if demand_string:
            demand_string = re.sub('SSS', group_member_name, demand_string)
            
        run_config = merge_resources_if_not_None(run_config, [ 
            ("sample_proportion_locations", sample_proportion_locations), 
            ("sample_size_locations", sample_size_locations), 
            ("compute_capacity_flag", compute_capacity_flag),
            ("capacity_string", capacity_string),
            ("number_of_agents_string", number_of_agents_string),
            ("number_of_units_string", number_of_units_string),
            ("weights_for_simulation_string", simulation_weight_string),
            ("demand_string", demand_string)                                                  
            ])
        
        estimate_config = merge_resources_if_not_None(estimate_config, [ 
                    ("estimation", estimation), 
                    ("sample_proportion_locations", sample_proportion_locations), 
                    ("sample_size_locations", sample_size_locations), 
                    ("estimation_size_agents", estimation_size_agents),
                    ("weights_for_estimation_string", estimation_weight_string)])

        AgentLocationChoiceModelMember.__init__(self, group_member, location_set, 
                                        agents_grouping_attribute, 
                                        model_name = "Employment Location Choice Model", 
                                        short_name = "ELCM", 
                                        sampler=sampler, 
                                        utilities=utilities, 
                                        probabilities=probabilities, 
                                        choices=choices,
                                        filter=filter, 
                                        submodel_string=submodel_string,   
                                        location_id_string=location_id_string,
                                        run_config=run_config, 
                                        estimate_config=estimate_config, 
                                        debuglevel=debuglevel, dataset_pool=dataset_pool,
                                        variable_package=variable_package)
コード例 #14
0
    def __init__(self, location_set,
            sampler = "opus_core.samplers.weighted_sampler", 
            utilities = "opus_core.linear_utilities", 
            choices = "opus_core.random_choices", 
            probabilities = "opus_core.mnl_probabilities",
            estimation = "opus_core.bhhh_mnl_estimation",
            capacity_string = "clip_to_zero((parcel.parcel_acres*parcel.max_du_acre*(1-parcel.pct_undevelopable)) - (parcel.aggregate(building.non_residential_sqft)/1500.0) - parcel.aggregate(building.residential_units))",
            estimation_weight_string = "parcel_acres", 
            simulation_weight_string = None, # if this is None, weights are proportional to the capacity 
            ###number_of_agents_string = "building.residential_units",
            #number_of_units_string = "clip_to_zero((parcel.parcel_acres*parcel.max_du_acre*(1-parcel.pct_undevelopable)) - (parcel.aggregate(building.non_residential_sqft)/1500.0) - parcel.aggregate(building.residential_units))",    
            agent_units_string = "building.residential_units",            
            sample_proportion_locations = None, 
            sample_size_locations = 250, 
            estimation_size_agents = 1.0, 
            compute_capacity_flag = True, 
            filter=None,
            submodel_string = None, location_id_string = None,
            demand_string = None, # if not None, the aggregate demand for locations will be stored in this attribute
            run_config = None, estimate_config=None, debuglevel=0, dataset_pool=None,
            variable_package="urbansim",
            model_name=None,
            model_short_name=None,
            **kwargs):
        run_config = merge_resources_if_not_None(run_config, [ 
                    ("sample_proportion_locations", sample_proportion_locations), 
                    ("sample_size_locations", sample_size_locations), 
                    ("compute_capacity_flag", compute_capacity_flag),
                    ("capacity_string", capacity_string),
                    ###("number_of_agents_string", number_of_agents_string),
                    ###("number_of_units_string", number_of_units_string),
                    ("agent_units_string", agent_units_string),
                    ("weights_for_simulation_string", simulation_weight_string),
                    ("demand_string", demand_string),
                    ("lottery_max_iterations", 20)
                                          ])
        estimate_config = merge_resources_if_not_None(estimate_config, [ 
                    ("estimation", estimation), 
                    ("sample_proportion_locations", sample_proportion_locations), 
                    ("sample_size_locations", sample_size_locations), 
                    ("estimation_size_agents", estimation_size_agents),
                    ("weights_for_estimation_string", estimation_weight_string)])         

        if model_name is not None:
            self.model_name = model_name
        if model_short_name is not None:
            self.model_short_name = model_short_name

        AgentLocationChoiceModel.__init__(self, location_set,
                                        model_name=self.model_name, 
                                        short_name=self.model_short_name, 
                                        sampler=sampler, 
                                        utilities=utilities, 
                                        probabilities=probabilities, 
                                        choices=choices, 
                                        filter=filter, 
                                        submodel_string=submodel_string,  
                                        location_id_string=location_id_string,
                                        run_config=run_config, 
                                        estimate_config=estimate_config, 
                                        debuglevel=debuglevel, dataset_pool=dataset_pool,
                                        variable_package=variable_package,
                                        **kwargs)
    def get_model(self, 
                  project_type,
                  location_set,
                  sampler = "opus_core.samplers.weighted_sampler", 
                  utilities = "opus_core.linear_utilities", 
                  choices = "urbansim.first_agent_first_choices", 
                  probabilities = "opus_core.mnl_probabilities", 
                  estimation = "opus_core.bhhh_mnl_estimation", 
                  sample_proportion_locations = None, 
                  sample_size_locations = 30, 
                  estimation_size_agents = 1.0, 
                  compute_capacity_flag = True, 
                  filter = "",
                  submodel_string = "size_category", 
                  model_configuration = None,
                  location_id_string = None,
                  run_config = None, 
                  estimate_config = None, 
                  debuglevel = 0,
                  units = '',
                  developable_maximum_unit_variable_full_name = '',
                  developable_minimum_unit_variable_full_name = '',
                  residential = False):
        
        if model_configuration is not None:
            units = model_configuration['units']
            developable_maximum_unit_variable_full_name = model_configuration['developable_maximum_unit_variable_full_name']
            developable_minimum_unit_variable_full_name = model_configuration['developable_minimum_unit_variable_full_name']
        
        default_capacity_attribute = "urbansim.gridcell.is_developable_for_%s" % units
        default_filter = "urbansim.gridcell.developable_%s" % units
        if filter == "":
            filter = default_filter
        run_config = merge_resources_if_not_None(run_config, [ 
            ("sample_proportion_locations", sample_proportion_locations), 
            ("sample_size_locations", sample_size_locations), 
            ("compute_capacity_flag", compute_capacity_flag)])
        run_config = merge_resources_with_defaults(run_config, 
            [("capacity_string", default_capacity_attribute)])
        estimate_config = merge_resources_if_not_None(estimate_config, [ 
                    ("estimation", estimation), 
                    ("sample_proportion_locations", sample_proportion_locations), 
                    ("sample_size_locations", sample_size_locations), 
                    ("estimation_size_agents", estimation_size_agents)])         
        estimate_config = merge_resources_with_defaults(estimate_config, 
            [("weights_for_estimation_string", self.estimation_weight_string_default)])
        
        return DevelopmentProjectLocationChoiceModel(location_set, 
                                                     project_type=project_type, 
                                                     units=units,
                                                     developable_maximum_unit_variable_full_name=developable_maximum_unit_variable_full_name,
                                                     developable_minimum_unit_variable_full_name=developable_minimum_unit_variable_full_name,
                                                     model_name="Development Project %s Location Choice Model" % project_type,
#                                                     residential = residential,
                                                     sampler=sampler, 
                                                     utilities=utilities, 
                                                     probabilities=probabilities, 
                                                     choices=choices, 
                                                     filter=filter,
                                                     submodel_string=submodel_string, 
                                                     location_id_string = location_id_string,
                                                     run_config=run_config, 
                                                     estimate_config=estimate_config, 
                                                     debuglevel=debuglevel)