Compressing zero values in arrays
Posted: Fri Nov 26, 2021 8:08 am
Hi all,
Thanks in advance for your advice! I'm after guidance on how to mitigate the increase in model run file size when adding additional subscripts to a variable. In my case, many of the combinations in the array will be zero as I'm using mapping arrays of 1s and 0s to go between subscripts, and I'm looking for a way to tell Vensim to compress the zero values in the resultant array or something similar. To provide an example, I'm modelling energy demand in buildings, I want to go from Demand[technologies] to Demand[technologies,fuels]. Demand[technologies,fuels] = Demand[technologies] * map technologies to fuels[technologies,fuels].
The result is that I will have lines of 0 values in the array for combinations which don't exist, such as [WashingMachineA,Coal], whereas I'm just interested in keeping the combinations that have non-zero values, such as [WashingMachineA,Electricity].
I could define subsets within the subscripts to exclude the zero value combinations, but this would mean I would need to define an equation for each fuel for example, loosing some of the benefits of combining subscripts for quick and flexible coding.
Any ideas would be greatly appreciated and please let me know if more info is required!
Thanks very much.
Tim
Thanks in advance for your advice! I'm after guidance on how to mitigate the increase in model run file size when adding additional subscripts to a variable. In my case, many of the combinations in the array will be zero as I'm using mapping arrays of 1s and 0s to go between subscripts, and I'm looking for a way to tell Vensim to compress the zero values in the resultant array or something similar. To provide an example, I'm modelling energy demand in buildings, I want to go from Demand[technologies] to Demand[technologies,fuels]. Demand[technologies,fuels] = Demand[technologies] * map technologies to fuels[technologies,fuels].
The result is that I will have lines of 0 values in the array for combinations which don't exist, such as [WashingMachineA,Coal], whereas I'm just interested in keeping the combinations that have non-zero values, such as [WashingMachineA,Electricity].
I could define subsets within the subscripts to exclude the zero value combinations, but this would mean I would need to define an equation for each fuel for example, loosing some of the benefits of combining subscripts for quick and flexible coding.
Any ideas would be greatly appreciated and please let me know if more info is required!
Thanks very much.
Tim