next up previous index
Next: Data Storage Up: Interaction Sets Previous: Initialization   Index

Using InteractionDataset

The method get_attribute() returns a 2-d array, where a value $ x_{ij}$ belongs to interaction of the $ i$ -th element within elements of dataset1 given by index1 and the $ j$ -th element within elements of dataset2 given by index2. Thus, the array size corresponds to size of index1 $ \times$ size of index2.

The two interacting datasets can be accessed by the method get_dataset() which takes either 1 or 2 as an argument value for dataset1 or dataset2.

The method get_attribute_of_dataset(name, dataset_number) returns values of the given attribute that belongs to the dataset given by dataset_number where only values associated to the corresponding index are included. Thus, a call self.get_attribute_of_dataset("attr", 1) gives an array of size index1, whereas a call self.get_dataset(1).get_attribute("attr") gives an array containing values for all elements of dataset1.

The method compute_variables() determines from the fully-qualified names of variables, to which dataset the variable belongs to. If it belongs to the dataset1 or dataset2, it calls compute_variables() on those datasets (the values are computed for all elements of the datasets, regardless of the given index). If it is an interaction variable, it is computed only for elements given by index1 and index2.

The InteractionDataset class contains several methods that are useful for variable computation, such as multiply() and divide().

An interaction set is automatically created and used in the ChoiceModel class (see Section 7.5.3).


next up previous index
Next: Data Storage Up: Interaction Sets Previous: Initialization   Index
info (at) urbansim.org