I just have a question regarding the discrete dynamic programming package ddp. In general, there is a single index to represent the state space. Thus, if there are multiple state variables, one needs to map pairs of integers to one integer.
With two state variables, in the context of, say, the Aiyagari model, the mapping is as follows:
s_i = a_i *z_size + z_i
for indices on assets a_i and productivity z_i.
This can be inverted as follows:
a_i = s_i//z_size (integer division)
z_i = s_i% z_size (remainder)
How does this mapping generalize with more than two state variables?