Skip to content
Open
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
20 changes: 11 additions & 9 deletions src/simulation/investment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use crate::region::RegionID;
use crate::simulation::prices::Prices;
use crate::time_slice::{TimeSliceID, TimeSliceInfo, TimeSliceLevel};
use crate::units::{ActivityPerCapacity, Capacity, Dimensionless, Flow, FlowPerCapacity};
use anyhow::{Context, Result, bail, ensure};
use anyhow::{Context, Result, ensure};
use indexmap::IndexMap;
use itertools::{Itertools, chain};
use log::debug;
use log::{debug, warn};
use std::collections::{HashMap, HashSet};
use std::fmt::Display;
use strum::IntoEnumIterator;
Expand Down Expand Up @@ -861,25 +861,27 @@ fn select_best_assets(
// Sort by investment priority and discard non-feasible options
sort_and_filter_appraisal_outputs(&mut outputs_for_opts);

// Check if there are any remaining options. If not, we cannot meet demand, so have to bail
// out.
// If none of the remaining options are feasible, we terminate the loop. We may still be
// able to meet the full demands with assets selected so far, so we continue anyway with a
// warning.
if outputs_for_opts.is_empty() {
let remaining_demands: Vec<_> = demand
.iter()
.filter(|(_, flow)| **flow > Flow(0.0))
Comment on lines 869 to 870
.map(|(time_slice, flow)| format!("{} : {:e}", time_slice, flow.value()))
.collect();

bail!(
"No feasible investment options left for \
commodity '{}', region '{}', year '{}', agent '{}' after appraisal.\n\
Remaining unmet demand (time_slice : flow):\n{}",
warn!(
"Investment appraisal completed with unmet demand for commodity '{}', region '{}', \
year '{}', agent '{}'. No additional feasible investments were identified. \
The unmet demand reported below may still be satisfied during the full system \
dispatch:\n{}",
&commodity.id,
region_id,
year,
agent.id,
remaining_demands.join("\n")
);
break;
}

// Warn if there are multiple equally good assets
Expand Down
Loading