Compressing zero values in arrays

Use this forum to post Vensim related questions.
Post Reply
Tim_IEA
Junior Member
Posts: 2
Joined: Fri Nov 19, 2021 1:59 am
Vensim version: DSS

Compressing zero values in arrays

Post by Tim_IEA »

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
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Compressing zero values in arrays

Post by Administrator »

I would try and combine the two subscript ranges into one. How tricky would it be in your case? For example,
machine : washing machine electric, cooker gas, cooker electric, cooker fire, tv electric

That way you would not have any zeroes in the array.

If you then need to calculate energy consumption, you could have something like

energy source : electric, gas, fire

map technologies to fuels[washing machine electric,electric] = 1
map technologies to fuels[cooker gas,gas] = 1
map technologies to fuels[cooker electric,electric] = 1
map technologies to fuels[cooker fire,fire] = 1
map technologies to fuels[tv electric,electric] = 1

energy use[energy source] = sum ( map technologies to fuels[machine!,energy source] * energy use[machine!] )
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply