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
1 change: 0 additions & 1 deletion examples/circularity/model.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
milestone_years = [2020, 2030, 2040]
please_give_me_broken_results = true
19 changes: 9 additions & 10 deletions src/simulation/investment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ use super::optimisation::{DispatchRun, FlowMap};
use crate::agent::{Agent, AgentID};
use crate::asset::{Asset, AssetIterator, AssetRef, AssetState};
use crate::commodity::{Commodity, CommodityID, CommodityMap};
use crate::model::ALLOW_BROKEN_OPTION_NAME;
use crate::model::Model;
use crate::output::DataWriter;
use crate::region::RegionID;
use crate::simulation::CommodityPrices;
use crate::time_slice::{TimeSliceID, TimeSliceInfo};
use crate::units::{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;
Expand Down Expand Up @@ -102,6 +101,14 @@ impl InvestmentSet {
previously_selected_assets,
writer,
)
.with_context(|| {
format!(
"Investments failed for market set {self} with cyclical dependencies. \
Please note that the investment algorithm is currently experimental for \
models with circular commodity dependencies and may not work in all \
scenarios."
)
})
}
InvestmentSet::Layer(investment_sets) => {
debug!("Starting asset selection for layer '{self}'");
Expand Down Expand Up @@ -332,14 +339,6 @@ fn select_assets_for_cycle(
// Precompute a joined string for logging
let markets_str = markets.iter().map(|(c, r)| format!("{c}|{r}")).join(", ");

if !model.parameters.allow_broken_options {
bail!(
"Detected cycle for markets ({markets_str}). \
Cyclic investment sets are currently experimental. \
To run anyway, set the {ALLOW_BROKEN_OPTION_NAME} option to true."
);
}

// Iterate over the markets to select assets
let mut current_demand = demand.clone();
let mut assets_for_cycle = HashMap::new();
Expand Down
5 changes: 0 additions & 5 deletions tests/regenerate_test_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ run_example() {
}

for example in $examples; do
# Skip the circularity example
if [ "$example" = circularity ]; then
continue
fi

# We only need debug files for the simple model
debug=false
if [ "$example" = simple ]; then
Expand Down
8 changes: 8 additions & 0 deletions tests/regression_circularity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! A regression test for the `circularity` example
mod regression;
use regression::run_regression_test;

#[test]
fn regression_circularity() {
run_regression_test("circularity");
}
Loading