Skip to content
Draft
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
4 changes: 0 additions & 4 deletions schemas/input/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ properties:
type: number
description: The relative tolerance for price convergence in the ironing out loop
default: 1e-6
capacity_margin:
type: number
description: Slack proportion for assets selected during cycle balancing to absorb small demand shifts
default: 0.2
mothball_years:
type: integer
default: 0
Expand Down
3 changes: 2 additions & 1 deletion src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ impl AssetRef {
self.region_id(),
self.commission_year,
self.agent_id(),
hash_unit(self.capacity().tranche_size()),
))
}
}
Expand Down Expand Up @@ -1168,7 +1169,7 @@ impl Hash for AssetRef {
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash)]
enum AssetCmp<'a> {
WithID(AssetID),
WithoutID((&'a ProcessID, &'a RegionID, u32, Option<&'a AgentID>)),
WithoutID((&'a ProcessID, &'a RegionID, u32, Option<&'a AgentID>, u64)),
}

/// Additional methods for iterating over assets
Expand Down
12 changes: 9 additions & 3 deletions src/graph/investment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,19 @@
|_, node_weight| match node_weight.len() {
0 => unreachable!("Condensed graph node must have at least one member"),
1 => node_weight[0].clone(),
_ => MarketSet::Cycle(
node_weight
_ => MarketSet::Cycle {
first_pass: node_weight
.iter()
.flat_map(|s| s.iter_markets())
.cloned()
.collect(),
),
second_pass: node_weight // TODO: placeholder
.iter()
.flat_map(|s| s.iter_markets())
.cloned()
.collect(),
excluded_processes: vec![], // TODO: placeholder
},
},
// Keep edges the same
|_, edge_weight| edge_weight.clone(),
Expand Down Expand Up @@ -600,7 +606,7 @@
assert_eq!(result.len(), 1);
assert_eq!(
result[0],
MarketSet::Cycle(vec![("A".into(), "GBR".into()), ("B".into(), "GBR".into())])

Check failure on line 609 in src/graph/investment.rs

View workflow job for this annotation

GitHub Actions / pre-commit

expected value, found struct variant `MarketSet::Cycle`

Check failure on line 609 in src/graph/investment.rs

View workflow job for this annotation

GitHub Actions / Run tests (macos-latest)

expected value, found struct variant `MarketSet::Cycle`

Check failure on line 609 in src/graph/investment.rs

View workflow job for this annotation

GitHub Actions / Run benchmarks

expected value, found struct variant `MarketSet::Cycle`

Check failure on line 609 in src/graph/investment.rs

View workflow job for this annotation

GitHub Actions / Run tests (ubuntu-latest)

expected value, found struct variant `MarketSet::Cycle`

Check failure on line 609 in src/graph/investment.rs

View workflow job for this annotation

GitHub Actions / Run tests (windows-latest)

expected value, found struct variant `MarketSet::Cycle`
);
}

Expand Down
10 changes: 0 additions & 10 deletions src/model/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ pub struct ModelParameters {
/// The relative tolerance for price convergence in the ironing out loop
#[serde(deserialize_with = "deserialise_finite_non_negative")]
pub price_tolerance: Dimensionless,
/// Slack applied during cycle balancing, allowing newly selected assets to flex their capacity
/// by this proportion.
///
/// Existing assets remain fixed; this gives newly selected assets the wiggle-room to absorb
/// small demand changes before we would otherwise need to break for re-investment.
#[serde(deserialize_with = "deserialise_finite_non_negative")]
pub capacity_margin: Dimensionless,
/// Number of years an asset can remain unused before being decommissioned
pub mothball_years: u32,
/// Absolute tolerance when checking if remaining demand is close enough to zero
Expand Down Expand Up @@ -152,7 +145,6 @@ impl Default for ModelParameters {
annual_utilisation_penalty: MoneyPerCapacityPerYear(1e-6),
max_ironing_out_iterations: 1,
price_tolerance: Dimensionless(1e-6),
capacity_margin: Dimensionless(0.2),
mothball_years: 0,
remaining_demand_absolute_tolerance: DEFAULT_REMAINING_DEMAND_ABSOLUTE_TOLERANCE,
highs: HighsOptions::default(),
Expand Down Expand Up @@ -355,8 +347,6 @@ impl ModelParameters {

// price_tolerance already validated with deserialise_finite_non_negative

// capacity_margin already validated with deserialise_finite_non_negative

// remaining_demand_absolute_tolerance already validated with
// deserialise_finite_non_negative; check remaining constraints here
check_remaining_demand_absolute_tolerance(
Expand Down
13 changes: 4 additions & 9 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,11 @@ impl DebugDataWriter {
return Ok(());
}

// If the unmet demand writer already exist, we panic, as it should not happen
assert!(
self.unmet_demand_writer.is_none(),
"Unmet demand file already exists!"
);

let run_description = self.with_context(run_description);
let writer = self
.unmet_demand_writer
.insert(csv::Writer::from_path(&self.unmet_demand_file_path)?);
if self.unmet_demand_writer.is_none() {
self.unmet_demand_writer = Some(csv::Writer::from_path(&self.unmet_demand_file_path)?);
}
let writer = self.unmet_demand_writer.as_mut().unwrap();
for (commodity_id, region_id, time_slice, value) in rows {
let row = UnmetDemandRow {
milestone_year,
Expand Down
Loading
Loading