NREL / buildstock-query

BuildStockQuery is a python library for querying datasets generated by ResStock™ and ComStock™.
https://nrel.github.io/buildstock-query/
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

Better options combination report in upgrades analyzer #27

Closed rajeee closed 1 year ago

rajeee commented 1 year ago

Resolves #9 .

Pull Request Description

Previously, the upgrades_analyzer detailed report function would not print combination report if there were too many options. For example, if there were 14 options it will say this:

Combination report not printed because 14 options would require 16369 rows.

This is, however, only the upper limit of how many possible ways 2 or more options can be applied out of 14 options. (2^14 - 14 -1) = 16369

In reality, the options are typically applied in certain combinations guided by the apply logic and the number of ways they are applied is almost never as high as that upper limit. So, instead of going through each possible combination and counting number of buildings that got applied that combination, in this PR, we directly analyze the number of unique combinations of options being applied to the buildings and list them out.

The result is a much cleaner report of how different combinations of options are being applied to the stock, even for very high number of options in an upgrade.

An example report below:

Report of how the 14 options were applied to the buildings.

                   Applied options Applied buildings Cumulative sub Cumulative all
Number of options                                                                 
4                    1, 10, 13, 14         75 (0.1%)      75 (0.1%)      75 (0.1%)
4                    1, 11, 13, 14       2279 (2.3%)    2354 (2.4%)    2354 (2.4%)
4                    1, 12, 13, 14        309 (0.3%)    2663 (2.7%)    2663 (2.7%)
5                  1, 2, 3, 13, 14          8 (0.0%)       8 (0.0%)    2671 (2.7%)
5                  1, 2, 4, 13, 14        158 (0.2%)     166 (0.2%)    2829 (2.8%)
5                  1, 2, 5, 13, 14         65 (0.1%)     231 (0.2%)    2894 (2.9%)
5                  1, 6, 7, 13, 14         23 (0.0%)     254 (0.3%)    2917 (2.9%)
5                  1, 6, 8, 13, 14         42 (0.0%)     296 (0.3%)    2959 (3.0%)