Skip to content

Commit 9be3c66

Browse files
committed
pass region_id directly instead of getting from arbitrary asset
1 parent 9bab38a commit 9be3c66

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/simulation/investment.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ fn select_assets_for_single_market(
284284
opt_assets,
285285
commodity,
286286
agent,
287+
region_id,
287288
prices,
288289
demand_portion_for_market,
289290
year,
@@ -621,6 +622,7 @@ fn get_candidate_assets<'a>(
621622
}
622623

623624
fn select_from_assets_with_equal_metric(
625+
region_id: &RegionID,
624626
agent_id: &AgentID,
625627
commodity_id: &CommodityID,
626628
equally_good_assets: Vec<AppraisalOutput>,
@@ -643,8 +645,7 @@ fn select_from_assets_with_equal_metric(
643645
.collect::<Vec<_>>()
644646
.join(", ");
645647
let warning_message = format!(
646-
"Could not resolve deadlock between equally good appraisals for Agent id: {agent_id}, Commodity: '{commodity_id}', Region: {}. Options: [{asset_details}]. Selecting first option.",
647-
equally_good_assets[0].asset.region_id()
648+
"Could not resolve deadlock between equally good appraisals for Agent id: {agent_id}, Commodity: '{commodity_id}', Region: {region_id}. Options: [{asset_details}]. Selecting first option.",
648649
);
649650
warn!("{warning_message}");
650651
// Select the first asset arbitrarily from the equally performing options
@@ -658,6 +659,7 @@ fn select_best_assets(
658659
mut opt_assets: Vec<AssetRef>,
659660
commodity: &Commodity,
660661
agent: &Agent,
662+
region_id: &RegionID,
661663
prices: &CommodityPrices,
662664
mut demand: DemandMap,
663665
year: u32,
@@ -752,7 +754,12 @@ fn select_best_assets(
752754
// select from all equally good assets
753755
let equally_good_assets: Vec<_> =
754756
assets_sorted_by_metric.into_iter().take(count).collect();
755-
select_from_assets_with_equal_metric(&agent.id, &commodity.id, equally_good_assets)
757+
select_from_assets_with_equal_metric(
758+
region_id,
759+
&agent.id,
760+
&commodity.id,
761+
equally_good_assets,
762+
)
756763
}
757764
// there is a single best asset by metric
758765
AppraisalComparisonMethod::Metric => {

0 commit comments

Comments
 (0)