Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
129aaf1
First pass at abstracting LCOE
tsmbland Aug 21, 2024
f0254aa
First pass at using LCOE function for MCA output
tsmbland Aug 21, 2024
fa12549
Abstract capacity_to_service_demand
tsmbland Aug 21, 2024
618131e
Move NPV, NPC, EAC and CRF code to quantities.py
tsmbland Aug 21, 2024
753948e
Formatting
tsmbland Aug 21, 2024
1e44c99
Merge branch 'develop' into lcoe
tsmbland Aug 21, 2024
8d1b364
Create costs module
tsmbland Aug 22, 2024
1641fc9
Fix imports, homogenise objectives code
tsmbland Aug 22, 2024
a5c80a9
Remove search_space from objectives
tsmbland Aug 22, 2024
8300272
Pass prices to objectives rather than full market object
tsmbland Aug 22, 2024
a721636
Agent object no longer passed to objectives
tsmbland Aug 22, 2024
35dc942
Rewrite tests, change objective function signature
tsmbland Aug 22, 2024
380986e
Make demand data optional for objectives
tsmbland Aug 22, 2024
578e1f8
Fix remaining test
tsmbland Aug 22, 2024
90cbb4f
Create tests for costs functions
tsmbland Aug 22, 2024
6d25c37
Address ruff complaints
tsmbland Aug 22, 2024
2a316d5
Hopefully fix failing test
tsmbland Aug 22, 2024
4c7aea0
Update another test to reflect previous change
tsmbland Aug 22, 2024
8012550
Re-order inputs for costs functions
tsmbland Aug 22, 2024
263c09a
Improve tests and docstrings
tsmbland Aug 22, 2024
72ff481
Fix issue with ALCOE argument order
tsmbland Aug 22, 2024
9eb9b7e
Docstrings
tsmbland Aug 23, 2024
77f4a17
Revert a previous change
tsmbland Aug 23, 2024
1065b0a
Fix mistake in docstring
tsmbland Aug 23, 2024
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
37 changes: 29 additions & 8 deletions src/muse/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,23 +278,44 @@ def next(
getLogger(__name__).critical("Search space is empty")
self.year += time_period
return None
decision = self._compute_objective(demand, search_space, technologies, market)

# Filter technologies according to the search space, forecast year and region
techs = self.filter_input(
technologies,
technology=search_space.replacement,
year=self.forecast_year,
).drop_vars("technology")

# Reduce dimensions of the demand array
reduced_demand = demand.sel(
{
k: search_space[k]
for k in set(demand.dims).intersection(search_space.dims)
}
)

# Filter prices according to the region
prices = self.filter_input(market.prices)

# Compute the objective
decision = self._compute_objective(
technologies=techs, demand=reduced_demand, prices=prices
)

self.year += time_period
return xr.Dataset(dict(search_space=search_space, decision=decision))

def _compute_objective(
self,
demand: xr.DataArray,
search_space: xr.DataArray,
technologies: xr.Dataset,
market: xr.Dataset,
demand: xr.DataArray,
prices: xr.DataArray,
) -> xr.DataArray:
objectives = self.objectives(self, demand, search_space, technologies, market)
objectives = self.objectives(
technologies=technologies, demand=demand, prices=prices
)
decision = self.decision(objectives)
nobroadcast_dims = [d for d in decision.dims if d not in search_space.dims]
decision = xr.broadcast(decision, search_space, exclude=nobroadcast_dims)[0]
return decision.sel({k: search_space[k] for k in search_space.dims})
return decision

def add_investments(
self,
Expand Down
Loading