next up previous index
Next: ChoiceModel Class Up: ChunkModel Class Previous: The Run Method   Index

Implementing a Child Class

All models that are derived from the ChunkModel class must have the method run_chunk() implemented. It has two non-keyword arguments: an integer array and an object of class Dataset. The first argument is an index of elements within the second argument. The method can have additional keyword arguments. The method is expected to return an array of the same size as the size of the first argument (i.e. the chunk size). The $ i$ -th value of the result is expected to be associated with the dataset element indexed by index[$ i$ ].

Optionally, the method get_agents_order() can be implemented in the child class. It determines the order in which dataset elements are passed into chunks. This method takes a dataset as an argument which is an object of class DatasetSubset containing only those elements of the original dataset that are defined by dataset_index. It returns an index of elements within the given subset determining the order in which the elements should be processed. For example, if this method returns a randomized index, the elements passed into run_chunk() will be processed in randomized order.

An example of a user-defined ChunkModel is in Section 23.4.


next up previous index
Next: ChoiceModel Class Up: ChunkModel Class Previous: The Run Method   Index
info (at) urbansim.org