Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/application-flow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ This deeper level of the process is where most of the input options of MUSE are
Investment
~~~~~~~~~~

In the investment step is where new capacity is added to the different assets managed by the agents. This investment might be needed to cover an increase in demand (between now and forecast) or to match decommissioned assets, typically to do both.
In the investment step is where new capacity is added to the different assets managed by the agents. This investment might be needed to cover an increase in demand (between now and the investment year) or to match decommissioned assets, typically to do both.

The following graph summarises the process.

Expand Down Expand Up @@ -455,8 +455,8 @@ The following graph summarises the process.

First the demand is distributed among the available agents as requested by the ``demand_share`` argument of each ``subsector`` in the ``settings.toml`` file. This distribution can be done based on any attribute or property of the agents, as included in the ``Agents.csv`` file. Demand can also be shared across multiple agents, depending on the "quantity" attribute (defined in ``Agents.csv``). The two built-in options in MUSE are:

- `standard_demand` (default): The demand is split only amongst *new* agents (indeed there will be an error if a *retro* agent is found for this subsector). *New* agents get a share of the increase in demand for the forecast years well as the demand that occurs from decommissioned assets.
- `new_and_retro`: The input demand is split amongst both *new* and *retro* agents. *New* agents get a share of the increase in demand for the forecast year, whereas *retrofit* agents are assigned a share of the demand that occurs from decommissioned assets.
- `standard_demand` (default): The demand is split only amongst *new* agents (indeed there will be an error if a *retro* agent is found for this subsector). *New* agents get a share of the increase in demand over the investment period as well as the demand that occurs from decommissioned assets.
- `new_and_retro`: The input demand is split amongst both *new* and *retro* agents. *New* agents get a share of the increase in demand for the investment period, whereas *retrofit* agents are assigned a share of the demand that occurs from decommissioned assets.

Then, each agent select the technologies it can invest in based on what is needed and the **search rules** defined for it in the ``Agents.csv`` file. The possible search rules are described in :py:mod:`muse.filters`. These determine the search rules for each replacement technology.

Expand Down
5 changes: 2 additions & 3 deletions docs/inputs/toml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ Sectors contain a number of subsections:

- :py:func:`~muse.demand_share.standard_demand` (default): The input demand is
split amongst *new* agents. *New* agents get a share of the increase in demand
for the forecast years, as well as the demand that occurs from decommissioned
over the investment period, as well as the demand that occurs from decommissioned
assets.
- :py:func:`~muse.demand_share.new_and_retro`: The input demand is split amongst
both *new* and *retrofit* agents. *New* agents get a share of the increase in
demand for the forecast year, whereas *retrofit* agents are assigned a share
demand over the investment period, whereas *retrofit* agents are assigned a share
of the demand that occurs from decommissioned assets.

*constraints*
Expand Down Expand Up @@ -577,7 +577,6 @@ function of macro-economic data, i.e. population and gdp.
macrodrivers_path = '{path}/technodata/Macrodrivers.csv'
regression_path = '{path}/technodata/regressionparameters.csv'
timeslices_levels = {'day': ['all-day']}
forecast = [0, 5]

The following attributes are accepted:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
1 change: 0 additions & 1 deletion docs/tutorial-code/add-region/1-new-region/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 2 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand All @@ -66,7 +65,6 @@ agents = '{path}/technodata/Agents.csv'
existing_capacity = '{path}/technodata/power/ExistingCapacity.csv'
lpsolver = "scipy"
demand_share = "standard_demand"
forecast = 2

[sectors.gas]
type = 'default'
Expand All @@ -81,7 +79,6 @@ agents = '{path}/technodata/Agents.csv'
existing_capacity = '{path}/technodata/gas/ExistingCapacity.csv'
lpsolver = "scipy"
demand_share = "standard_demand"
forecast = 2

[sectors.residential_presets]
type = 'presets'
Expand Down
7 changes: 1 addition & 6 deletions docs/tutorial-code/modify-timing-data/generate_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from tomlkit import dumps, parse

from muse import examples
from muse.wizard import add_timeslice, get_sectors, modify_toml
from muse.wizard import add_timeslice, modify_toml

parent_path = Path(__file__).parent

Expand Down Expand Up @@ -80,11 +80,6 @@ def generate_model_2():
settings_file = model_path / "settings.toml"
time_framework = [2020, 2022, 2024, 2026, 2028, 2030, 2032, 2034, 2036, 2038, 2040]
modify_toml(settings_file, lambda x: x.update({"time_framework": time_framework}))
for sector in get_sectors(model_path):
modify_toml(
settings_file,
lambda x: x["sectors"][sector]["subsectors"]["all"].update({"forecast": 2}),
)


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion docs/tutorial-code/new-decision-metric/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ constraints = [
"search_space"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
15 changes: 0 additions & 15 deletions docs/user-guide/modify-timing-data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,6 @@
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We also have to modity the `forecast` value for each sector. For example, for the power sector the `sectors.power.subsectors.all` section should now look as follows:\n",
"\n",
"```toml\n",
"[sectors.power.subsectors.all]\n",
"agents = '{path}/technodata/Agents.csv'\n",
"existing_capacity = '{path}/technodata/power/ExistingCapacity.csv'\n",
"lpsolver = \"scipy\"\n",
"forecast = 2\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
10 changes: 0 additions & 10 deletions src/muse/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def __init__(
decision: Callable | None = None,
year: int = 2010,
maturity_threshold: float = 0,
forecast: int = 5,
housekeeping: Callable | None = None,
merge_transform: Callable | None = None,
demand_threshold: float | None = None,
Expand All @@ -137,7 +136,6 @@ def __init__(
year: year the agent is created / current year
maturity_threshold: threshold when filtering replacement
technologies with respect to market share
forecast: Number of years the agent will forecast
housekeeping: transform applied to the assets at the start of
iteration. Defaults to doing nothing.
merge_transform: transform merging current and newly invested assets
Expand Down Expand Up @@ -170,9 +168,6 @@ def __init__(
""" Current year. Incremented by one every time next is called."""
self.year = year

"""Number of years to look into the future for forecating purposed."""
self.forecast = forecast

"""Search rule(s) determining potential replacement technologies.

This is a string referring to a filter, or a sequence of strings
Expand Down Expand Up @@ -234,11 +229,6 @@ def __init__(
"""Threshold below which assets are not added."""
self.asset_threshold = asset_threshold

@property
def forecast_year(self):
"""Year to consider when forecasting."""
return self.year + self.forecast

def asset_housekeeping(self):
"""Reduces memory footprint of assets.

Expand Down
2 changes: 1 addition & 1 deletion src/muse/carbon_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def bisection(
# Create cache for emissions at different price points
emissions_cache = EmissionsCache(market, equilibrium, commodities)

# Carbon price and emissions threshold in the forecast year
# Carbon price and emissions threshold in the investment year
future = market.year[-1]
target = carbon_budget.sel(year=future).values.item()
price = market.prices.sel(year=future, commodity=commodities).mean().values.item()
Expand Down
1 change: 0 additions & 1 deletion src/muse/data/example/default/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
1 change: 0 additions & 1 deletion src/muse/data/example/default_retro/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "new_and_retro" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[[sectors.residential.interactions]]
net = 'new_to_retro'
Expand Down
1 change: 0 additions & 1 deletion src/muse/data/example/default_timeslice/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.power]
type = 'default'
Expand Down
1 change: 0 additions & 1 deletion src/muse/data/example/minimum_service/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "standard_demand" # Optional, default to standard_demand
forecast = 5 # Optional, defaults to 5

[sectors.industry_presets]
type = 'presets'
Expand Down
3 changes: 0 additions & 3 deletions src/muse/data/example/trade/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "new_and_retro"
forecast = 5
asset_threshold = 1e-4

[[sectors.residential.interactions]]
Expand Down Expand Up @@ -90,7 +89,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "unmet_forecasted_demand"
forecast = 5
asset_threshold = 1e-4

[sectors.gas]
Expand Down Expand Up @@ -118,7 +116,6 @@ constraints = [
"demand_limiting_capacity"
]
demand_share = "unmet_forecasted_demand"
forecast = 5
asset_threshold = 1e-4

[timeslices]
Expand Down
2 changes: 1 addition & 1 deletion src/muse/readers/toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ def read_technodata(
technologies[name] = data

# make sure technologies includes the requisite years
maxyear = getattr(settings, "forecast", 5) + max(time_framework)
maxyear = max(time_framework)
if technologies.year.max() < maxyear:
msg = "Forward-filling technodata to fit simulation timeframe"
getLogger(__name__).info(msg)
Expand Down
22 changes: 1 addition & 21 deletions src/muse/sectors/preset_sector.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,29 +143,9 @@ def next(self, mca_market: Dataset) -> Dataset:
consumption = self._interpolate(presets.consumption, mca_market.year)
costs = self._interpolate(presets.costs, mca_market.year)

result = Dataset({"supply": supply, "consumption": consumption})
result["costs"] = drop_timeslice(costs)
result = Dataset({"supply": supply, "consumption": consumption, "costs": costs})
assert isinstance(result, Dataset)
return result

def _interpolate(self, data: DataArray, years: DataArray) -> DataArray:
"""Chooses interpolation depending on whether forecast is available."""
if "forecast" in data.dims:
baseyear = int(years.min())
forecasted = (years - baseyear).values
result = (
data.interp(
year=baseyear,
method=self.interpolation_mode,
kwargs={"fill_value": "extrapolate"},
)
.interp(
forecast=forecasted,
method=self.interpolation_mode,
kwargs={"fill_value": "extrapolate"},
)
.drop_vars(("year", "forecast"))
)
result["year"] = "forecast", years.values
return result.set_index(forecast="year").rename(forecast="year")
return data.interp(year=years, method=self.interpolation_mode).ffill("year")
9 changes: 0 additions & 9 deletions src/muse/sectors/sector.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,6 @@ def __init__(
"""Full supply, consumption and costs data for the most recent year."""
self.output_data: xr.Dataset

@property
def forecast(self):
"""Maximum forecast horizon across agents.

It cannot be lower than 1 year.
"""
forecasts = [getattr(agent, "forecast") for agent in self.agents]
return max(1, max(forecasts))

def next(
self,
mca_market: xr.Dataset,
Expand Down
Loading
Loading