next up previous index
Next: Location Choice Model Up: Choice Model Previous: Estimation   Index

Simulation

The coefficients that result from the estimation run can be directly plugged into a simulation run:
>>> choices = choicemodel.run(specification,  coefficients, households)
Running Choice Model (from opus_core.choice_model): 
                                            started on Wed Nov  5 12:10:20 2008
    Total number of individuals: 10
    ChoiceM chunk 1 out of 1.: started on Wed Nov  5 12:10:20 2008
        Number of agents in this chunk: 10
    ChoiceM chunk 1 out of 1.: completed.................................0.0 sec
Running Choice Model (from opus_core.choice_model): completed............0.0 sec
>>> choices
array([1, 2, 1, 2, 2, 3, 3, 1, 2, 3])
The resulting choices is an array specifying the choice for each household. We can now assign those values to the dataset:
>>> households.modify_attribute(name="choice_id", data=choices)

Note that multiple runs will produce different results, which is due to random numbers used within the model. In order to receive reproducible results, one can fix the seed of the random number generator. The call above was preceded by

>>> from numpy.random import seed
>>> seed(1)

For demonstration purposes, we use the same dataset of households for estimation and simulation. This would not be usually the case in real simulation runs.

We can also create a coefficient class and assign their values directly (see Section 24.6.2 for more details):

>>> from opus_core.coefficients import Coefficients
>>> coefficients = Coefficients(
                     names=array(["beta01", "beta12", "beta03", "beta13"]),
                     values=array([0.5,      0.2,       -5.0,     1.3]))

If a variable $ x$ in the utility equations is choice dependent, one can create a dataset of choices and assign this attribute to the dataset. Besides a list and an array, the argument choice_set in the ChoiceModel constructor also accepts a dataset.


next up previous index
Next: Location Choice Model Up: Choice Model Previous: Estimation   Index
info (at) urbansim.org