EnergySystemsModellingLab / MUSE_OS

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

New constraints are ignored #336

Closed dalonsoa closed 3 months ago

dalonsoa commented 3 months ago

When working on #323 , I've found another issue...

Problem

In theory, it is possible to add new constrains simply y adding an appropriately coded and decorated function and then indicating in the toml file to use it:

@register_constraint
def new_constraint(...):
    ...

And then, in the relevant subsector of the toml file, add:

[sectors.residential.subsectors.retro_and_new]
...
constraints = [
    ...,
    "new_constraint"
]

However, these settings are ignored unless the agent is of type Agent; retrofit and newcapa agents, the only ones we use as far as I can tell, are InvestingAgents and they DO NOT use this setting but use instead a hardcoded list of constraints - all of them.

Solution

To enable customisation of the InvestmingAgents constraints, the agents_factory needs to be enabled to use that and pass the appropriate parameter to the function call in the subsectors factory. These constraints settings might need to be propagated down to the appropriate level to ensure they are used by the agents.