next up previous index
Next: Opus Variables Up: Regression Model Previous: Estimation   Index

Simulation

Suppose we have four locations with distance to cbd 2, 4, 6 and 8 respectively. We create a location dataset using a storage type `dict'. This type of storage is useful when we want to pass data directly without storing them on a physical storage media.

>>> dstorage = StorageFactory().get_storage('dict_storage')
>>> dstorage.write_table(table_name='gridcells',
                         table_data= {'id':array([1,2,3,4]),
                                      'distance_to_cbd':array([2,4,6,8])
                                    })
>>> ds = Dataset(in_storage=dstorage, in_table_name='gridcells',
                 id_name='id', dataset_name='gridcell')
We have created a table in the RAM space called gridcells which is passed into the Dataset constructor. Now we run the regression model with coefficients estimated in the previous section:
>>> cost = rm.run(specification, coefficients=coef, dataset=ds)
Running Regression Model (from opus_core.regression_model):
                                        started on Mon Mar 19 21:35:23 2007
    Total number of individuals: 4
    RM chunk 1 out of 1.: started on Mon Mar 19 21:35:23 2007
        Number of agents in this chunk: 4
    RM chunk 1 out of 1.: completed......................................0.0 sec
Running Regression Model (from opus_core.regression_model): completed....0.0 sec
>>> cost
array([ 971.77478027,  829.47613525,  687.17749023,  544.87878418])
As expected, the resulting cost decreases with increasing distance to cbd.


next up previous index
Next: Opus Variables Up: Regression Model Previous: Estimation   Index
info (at) urbansim.org