Skip to content

Commit e48c9aa

Browse files
committed
Add back ironing out loop
1 parent 39768aa commit e48c9aa

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/model/parameters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ define_unit_param_default!(default_candidate_asset_capacity, Capacity, 0.0001);
4747
define_unit_param_default!(default_capacity_limit_factor, Dimensionless, 0.1);
4848
define_unit_param_default!(default_value_of_lost_load, MoneyPerFlow, 1e9);
4949
define_unit_param_default!(default_price_tolerance, Dimensionless, 1e-6);
50-
define_param_default!(default_max_ironing_out_iterations, u32, 1);
50+
define_param_default!(default_max_ironing_out_iterations, u32, 10);
5151

5252
/// Model parameters as defined in the `model.toml` file.
5353
///

src/simulation/investment.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,14 @@ fn select_assets_for_cycle(
300300
previously_selected_assets: &[AssetRef],
301301
writer: &mut DataWriter,
302302
) -> Result<Vec<AssetRef>> {
303-
// Get markets to balance: all seen so far plus all in loop
303+
// Get markets to balance: all seen so far plus all in the cycle
304304
let mut markets_to_balance = seen_markets.to_vec();
305305
markets_to_balance.extend_from_slice(markets);
306306

307-
// Initialise list of unbalanced markets: start with all markets in the cycle
307+
// Initialise queue of unbalanced markets: start with all markets in the cycle
308308
let mut unbalanced_markets = VecDeque::from(markets.to_vec());
309309

310-
// Iterate while there are markets in the unbalanced list
310+
// Iterate while there are still markets in the queue, or until max iterations reached
311311
let mut current_demand = demand.clone();
312312
let mut selected_assets = HashMap::new();
313313
let mut loop_iter = 0;
@@ -321,11 +321,11 @@ fn select_assets_for_cycle(
321321
break;
322322
}
323323

324-
// Pop off the first market
324+
// Pop off the first market from the queue
325325
// If there are no markets with unmet demand, we're done
326326
let Some(current_market) = unbalanced_markets.pop_front() else {
327327
debug!(
328-
"Cycle investment for '{}' converged after {} iterations",
328+
"Investment for cycle '({})' converged after {} iterations",
329329
markets.iter().join(", "),
330330
loop_iter
331331
);
@@ -365,24 +365,21 @@ fn select_assets_for_cycle(
365365
.with_unmet_demand_vars(&markets_with_unmet_demand)
366366
.run(
367367
&format!(
368-
"cycle ({}) iteration {}",
368+
"cycle ({}) post {} investment (iteration {})",
369369
markets.iter().join(", "),
370+
&current_market,
370371
loop_iter
371372
),
372373
writer,
373374
)?;
374375

375-
// Find markets with unmet demand and add these to the unbalanced list if not already present
376+
// Find markets with unmet demand and add these to the queue if not already present
376377
let coms = solution.get_markets_with_unmet_demand();
377378
for market in coms {
378379
if !unbalanced_markets.contains(&market) {
379380
unbalanced_markets.push_back(market);
380381
}
381382
}
382-
println!(
383-
"Unbalanced markets: {}",
384-
unbalanced_markets.iter().join(", ")
385-
);
386383

387384
// Calculate a new demand map for the next iteration
388385
current_demand.clone_from(demand);

0 commit comments

Comments
 (0)