Skip to content

Model fails when existing capacity for all technologies in a sector is set to zero [BUG]  #427

@tsmbland

Description

@tsmbland

Describe the bug

Probably a niche scenario, but has come up for one of Sumin's models

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\tbland\AppData\Local\anaconda3\envs\muse_env\Scripts\muse.exe\__main__.py", line 7, in <module>  
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\__main__.py", line 61, in run
    muse_main(args.settings, args.model, args.copy)
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\__main__.py", line 56, in muse_main
    MCA.factory(settings).run()
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\mca.py", line 343, in run
    _, new_market, self.sectors = self.find_equilibrium(new_market)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\mca.py", line 208, in find_equilibrium
    return find_equilibrium(
           ^^^^^^^^^^^^^^^^^
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\mca.py", line 552, in find_equilibrium
    market, equilibrium_sectors = single_year_iteration(market, sectors)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\mca.py", line 464, in single_year_iteration
    sector_market = sector.next(
                    ^^^^^^^^^^^^
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\sectors\sector.py", line 231, in next
    subsector.invest(
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\sectors\subsector.py", line 68, in invest
    lp_problem = self.aggregate_lp(
                 ^^^^^^^^^^^^^^^^^^
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\sectors\subsector.py", line 110, in aggregate_lp
    demands = self.demand_share(
              ^^^^^^^^^^^^^^^^^^
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\demand_share.py", line 105, in demand_share
    return function(agents, market, technologies, **keyword_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\registration.py", line 174, in decorated
    result = inner_decorated(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\demand_share.py", line 286, in new_and_retro
    retro_demands: MutableMapping[Hashable, xr.DataArray] = _inner_split(
                                                            ^^^^^^^^^^^^^
  File "C:\Users\tbland\Documents\Code\MUSE_OS\src\muse\demand_share.py", line 472, in _inner_split
    .groupby("technology")
     ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tbland\AppData\Local\anaconda3\envs\muse_env\Lib\site-packages\xarray\core\dataarray.py", line 6759, in groupby
    rgrouper = ResolvedGrouper(UniqueGrouper(), group, self)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 6, in __init__
  File "C:\Users\tbland\AppData\Local\anaconda3\envs\muse_env\Lib\site-packages\xarray\core\groupby.py", line 440, in __post_init__
    self.group: T_Group = _resolve_group(self.obj, self.group)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tbland\AppData\Local\anaconda3\envs\muse_env\Lib\site-packages\xarray\core\groupby.py", line 785, in _resolve_group
    raise ValueError(f"{newgroup.name} must not be empty")
ValueError: technology must not be empty

To Reproduce

Set all values in the ExistingCapacity.csv for a sector to zero (current and future years)

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Context

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

  • Operating system (eg. Windows 10):
  • MUSE version (eg. 1.0.1): dev
  • Installation method (eg. pipx, pip, development mode):
  • Python version (you can get this running python --version): 3.12

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions