From 0ae29692e6bf513d7e147c5755ff8a17b846fb9f Mon Sep 17 00:00:00 2001 From: Manuel Date: Wed, 28 Jun 2023 10:20:00 +0200 Subject: [PATCH] Fix computation of benders master problem temporal structure We were excluding all time slices that went beyond the end of the rolling window, but that's too much. Instead, now we cut the time slices to fit within the window so it's more consistent. --- src/data_structure/temporal_structure.jl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/data_structure/temporal_structure.jl b/src/data_structure/temporal_structure.jl index c1e5c5c9ba..e94bfeb6df 100644 --- a/src/data_structure/temporal_structure.jl +++ b/src/data_structure/temporal_structure.jl @@ -405,13 +405,15 @@ function generate_master_temporal_structure!(m::Model, m_mp::Model) k = 1 dur_unit = _model_duration_unit(m.ext[:spineopt].instance) while true + blocks_by_interval = Dict() + for t in time_slice(m) + t_start, t_end = start(t), min(end_(t), end_(current_window(m))) + t_start < t_end || continue + union!(get!(blocks_by_interval, (t_start, t_end), Set()), blocks(t)) + end append!( mp_time_slices, - ( - TimeSlice(start(t), end_(t), blocks(t)...; duration_unit=dur_unit) - for t in time_slice(m) - if end_(t) <= end_(current_window(m)) - ) + (TimeSlice(interval..., blocks...; duration_unit=dur_unit) for (interval, blocks) in blocks_by_interval) ) roll_temporal_structure!(m, k) || break k += 1