当前位置: 首页>>代码示例>>Python>>正文


Python HouseholdDataset.set_values_of_one_attribute方法代码示例

本文整理汇总了Python中urbansim.datasets.household_dataset.HouseholdDataset.set_values_of_one_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python HouseholdDataset.set_values_of_one_attribute方法的具体用法?Python HouseholdDataset.set_values_of_one_attribute怎么用?Python HouseholdDataset.set_values_of_one_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urbansim.datasets.household_dataset.HouseholdDataset的用法示例。


在下文中一共展示了HouseholdDataset.set_values_of_one_attribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_ALCM

# 需要导入模块: from urbansim.datasets.household_dataset import HouseholdDataset [as 别名]
# 或者: from urbansim.datasets.household_dataset.HouseholdDataset import set_values_of_one_attribute [as 别名]
def run_ALCM(niter):
    nhhs = 100
    ngcs = 10
    ngcs_attr = ngcs/2
    ngcs_noattr = ngcs - ngcs_attr
    hh_grid_ids = array(nhhs*[-1])
    
    storage = StorageFactory().get_storage('dict_storage')

    households_table_name = 'households'        
    storage.write_table(
        table_name = households_table_name,
        table_data = {
            'household_id': arange(nhhs)+1, 
            'grid_id': hh_grid_ids
            }
        )
        
    gridcells_table_name = 'gridcells'        
    storage.write_table(
        table_name = gridcells_table_name,
        table_data = {
            'grid_id': arange(ngcs)+1, 
            'cost':array(ngcs_attr*[100]+ngcs_noattr*[1000])
            }
        )

    households = HouseholdDataset(in_storage=storage, in_table_name=households_table_name)
    gridcells = GridcellDataset(in_storage=storage, in_table_name=gridcells_table_name)
    
    # create coefficients and specification
    coefficients = Coefficients(names=('costcoef', ), values=(-0.001,))
    specification = EquationSpecification(variables=('gridcell.cost', ), coefficients=('costcoef', ))
    logger.be_quiet()
    result = zeros((niter,ngcs))
    for iter in range(niter):
        hlcm = HouseholdLocationChoiceModelCreator().get_model(location_set=gridcells, compute_capacity_flag=False, 
                choices = 'opus_core.random_choices_from_index', 
                sampler=None,
                #sample_size_locations = 30
                )
        hlcm.run(specification, coefficients, agent_set=households, debuglevel=1,
                  chunk_specification={'nchunks':1})
        
        # get results
        gridcells.compute_variables(['urbansim.gridcell.number_of_households'],
            resources=Resources({'household':households}))
        result_more_attractive = gridcells.get_attribute_by_id('number_of_households', arange(ngcs_attr)+1)
        result_less_attractive = gridcells.get_attribute_by_id('number_of_households', arange(ngcs_attr+1, ngcs+1))
        households.set_values_of_one_attribute(attribute='grid_id', values=hh_grid_ids)
        gridcells.delete_one_attribute('number_of_households')
        result[iter,:] = concatenate((result_more_attractive, result_less_attractive))
        #print result #, result_more_attractive.sum(), result_less_attractive.sum()
    return result
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:56,代码来源:variance_anal.py

示例2: HouseholdLocationChoiceModelCreator

# 需要导入模块: from urbansim.datasets.household_dataset import HouseholdDataset [as 别名]
# 或者: from urbansim.datasets.household_dataset.HouseholdDataset import set_values_of_one_attribute [as 别名]
results = hlcm.run(specification, coef, agents)
hlcm.upc_sequence.plot_choice_histograms( 
                    capacity=locations.get_attribute("vacant_units"))
hlcm.upc_sequence.show_plots()

hlcm2 = HouseholdLocationChoiceModelCreator().get_model(
    location_set = locations,
    sampler=None,
    utilities="opus_core.linear_utilities",
    probabilities="opus_core.mnl_probabilities",
    choices="urbansim.lottery_choices", 
    compute_capacity_flag=True, 
    run_config=Resources({"capacity_string":"gridcell.vacant_units"}))

agents.set_values_of_one_attribute("location", -1*ones(agents.size()))
agents.get_attribute("location")

results = hlcm2.run(specification, coefficients, agents)
agents.get_attribute("location")
hlcm2.upc_sequence.plot_choice_histograms( 
                    capacity=locations.get_attribute("vacant_units"))
hlcm2.upc_sequence.show_plots()
coef, results = hlcm2.estimate(specification, agents)

#HLCM on PSRC
# households from PSRC
agents_psrc = HouseholdDataset(in_storage = StorageFactory().get_storage('flt_storage', 
        storage_location = "/home/hana/bandera/urbansim/data/GPSRC"), 
    in_table_name = "hh")
agents_psrc.summary()
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:32,代码来源:demo.py


注:本文中的urbansim.datasets.household_dataset.HouseholdDataset.set_values_of_one_attribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。