EnergySystemsModellingLab / MUSE_OS

Welcome to the MUSE-OS repository
https://muse-os.readthedocs.io/en/latest/
GNU General Public License v3.0
22 stars 8 forks source link

maturity and spend_limit filters adapt the search_space faulty [BUG] #254

Closed LennartMorlock closed 1 month ago

LennartMorlock commented 3 months ago

Describe the bug

Some filters (I have noticed that maturity and spend_limit do this, but I am not sure if there is another one) alter the search_space by removing the columns from the search_space DataArray that belong to replacement technologies that don't satisfy the condition and should not be considered. That leads to two problems:

  1. Some filters, like spend_limit, require all replacement columns to remain present when applied. Otherwise, applying the .sel() function within the filter may throw an error as not all indices it tries to select can be found in the search_space.

  2. with_asset_technology should add the existing asset being replaced to the search space as a possible replacement. It does this by setting the corresponding boolean values to True. However, this requires that the relevant (asset, replacement) combinations exist in the search_space Dataarray, as it does not add a new column with the correct boolean values. Thus, if it is applied after the maturity filter, it can not add the existing technologies to the search_space since those columns don't exist.

To Reproduce

  1. Change an agent's search rule to maturity->spend_limit with high values for maturity and spend_limit such that spend_limit allows technologies that maturity doesn't

  2. Change any retrofit agent's search rule to maturity with a maturity threshold bigger than the highest share of any existing technology.

Expected behaviour

  1. Should run, however, throws an error message.

  2. The retrofit agent should still be able to invest in the existing technologies as the with_asset_technology filter is automatically applied to retrofit agents with one search rule. However, the previously described problem will lead to a critical warning of an empty search space in the log.

Context

Please complete the following to better understand the system you are using to run MUSE.

alexdewar commented 1 month ago

Would you mind attaching config files which replicate the bug, please?