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

The Run Method

Input:
chunk_specification
- a dictionary specifying how to determine the number of chunks to run the model in (see Section 4.2.3).
dataset
- an object of class Dataset along whose elements the model will be chunked.
dataset_index
- an index of elements within dataset that are to be chunked.
result_array_type
- a type of the resulting array. It can be any numerical type of numpy array. The default value is float32.
...
- optional additional arguments that are passed to the method run_chunk(). They are expected to be keyword arguments.

Algorithm
For each chunk (determined by the chunk_specification) the model calls the method run_chunk() and passes as arguments the corresponding portion of dataset_index, the whole dataset and all additional arguments. By default the order of elements in dataset_index is preserved. This can be changed by redefining the method get_agents_order(). This method takes a dataset as 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 in the given dataset 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.

Output
The class returns result_array (passed to the method as input) filled by values returned by run_chunk() are filled into. This requires that the method run_chunk() returns an array of the same type as result_array and its size corresponds to the number of elements in one chunk.


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