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: 5 additions & 1 deletion docs/release_notes/upcoming.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ ready to be released, carry out the following steps:
## Breaking changes

- Changed the default `pricing_strategy` for SED/SVD commodities from "shadow" to "full_average" ([#1281])
- The `agent_search_space.csv` input file has been renamed to `agent_search_spaces.csv` for
consistency ([#1293])

## Bug fixes

- Fix misleading warning message for assets decommissioned before simulation start ([#1259])
- Fix parsing and validation of agent search space file ([#1293])

[highs-opts-docs]: https://energysystemsmodellinglab.github.io/MUSE2/developer_guide/custom_highs_options.html
[#1259]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1259
[#1281]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1281
[#1276]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1276
[#1281]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1281
[#1293]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1293
1 change: 0 additions & 1 deletion examples/circularity/agent_search_space.csv

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ fields:
type: string
description: The processes in which this agent will invest
notes: |
One or more process IDs separated by semicolons. If this field is empty or `all`, all
processes will be considered.
One or more process IDs separated by semicolons or `all`, meaning all processes
producing the relevant commodity in the given year in a relevant region.
28 changes: 14 additions & 14 deletions src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! assets.
use crate::commodity::CommodityID;
use crate::id::define_id_type;
use crate::process::{FlowDirection, Process};
use crate::process::Process;
use crate::region::RegionID;
use crate::units::Dimensionless;
use indexmap::{IndexMap, IndexSet};
Expand All @@ -18,8 +18,8 @@ pub type AgentMap = IndexMap<AgentID, Agent>;
/// A map of commodity portions for an agent, keyed by commodity and year
pub type AgentCommodityPortionsMap = HashMap<(CommodityID, u32), Dimensionless>;

/// A map for the agent's search space, keyed by commodity and year
pub type AgentSearchSpaceMap = HashMap<(CommodityID, u32), Rc<Vec<Rc<Process>>>>;
/// A map for the agent's search space, keyed by commodity, region, and year
pub type AgentSearchSpaceMap = HashMap<(CommodityID, RegionID, u32), Rc<Vec<Rc<Process>>>>;

Comment thread
alexdewar marked this conversation as resolved.
/// A map of objectives for an agent, keyed by year.
///
Expand Down Expand Up @@ -48,19 +48,19 @@ pub struct Agent {

impl Agent {
/// Get all the processes in this agent's search space which produce the commodity in the given
/// year
pub fn iter_possible_producers_of<'a>(
&'a self,
/// region and year.
///
/// # Panics
///
/// If the agent does not operate in the given region or is not responsible for the given
/// commodity in the given year.
pub fn iter_search_space(
&self,
region_id: &RegionID,
commodity_id: &'a CommodityID,
commodity_id: &CommodityID,
year: u32,
) -> impl Iterator<Item = &'a Rc<Process>> + use<'a> {
let flows_key = (region_id.clone(), year);
self.search_space[&(commodity_id.clone(), year)]
.iter()
.filter(move |process| {
process.flows[&flows_key][commodity_id].direction() == FlowDirection::Output
})
) -> impl Iterator<Item = &Rc<Process>> {
self.search_space[&(commodity_id.clone(), region_id.clone(), year)].iter()
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/input/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::path::Path;
mod objective;
use objective::read_agent_objectives;
mod search_space;
use search_space::read_agent_search_space;
use search_space::read_agent_search_spaces;
Comment thread
alexdewar marked this conversation as resolved.
mod commodity_portion;
use commodity_portion::read_agent_commodity_portions;

Expand Down Expand Up @@ -58,7 +58,7 @@ pub fn read_agents(
) -> Result<AgentMap> {
let mut agents = read_agents_file(model_dir, region_ids)?;

// We read commodity portions first as they are required by `read_agent_search_space`
// We read commodity portions first as they are required by `read_agent_search_spaces`
let mut agent_commodities = read_agent_commodity_portions(
model_dir,
&agents,
Expand All @@ -74,7 +74,7 @@ pub fn read_agents(

let mut objectives = read_agent_objectives(model_dir, &agents, milestone_years)?;
let commodity_ids = commodities.keys().cloned().collect();
let mut search_spaces = read_agent_search_space(
let mut search_spaces = read_agent_search_spaces(
model_dir,
&agents,
processes,
Expand Down
Loading
Loading