From 4055f06e016e5112d699e0c520db0f8e69f5d55b Mon Sep 17 00:00:00 2001 From: fonsecadeline Date: Tue, 20 Jan 2026 11:50:58 +0100 Subject: [PATCH 1/6] edit find eligible That would ensure those eligible will never be vaccinated over the year period of study, and avoid the replacing procedure (I think ?). --- src/select.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/select.jl b/src/select.jl index a990e06..9c2c843 100644 --- a/src/select.jl +++ b/src/select.jl @@ -54,6 +54,7 @@ function create_subgroups( agenda = init_agenda(), )::Dict{Date,DataFrame} pool = get_pool_from(group_id) + last_period_day = these_mondays.last + 1 for this_monday in ALL_MONDAYS if this_monday in these_mondays subgroup = group[this_monday] @@ -68,6 +69,7 @@ function create_subgroups( this_monday, vaccinated_count, agenda, + last_period_day ) end replace_unvaccinated!( @@ -111,9 +113,10 @@ function process_first_unvaccinated!( this_monday::Date, vaccinated_count::Int, agenda::Dict{Date,Dict{Date,Vector{Int}}}, + last_period_day::Date )::Nothing if vaccinated_count != 0 - eligible = get_eligible(pool, this_monday) + eligible = get_eligible(pool, last_period_day) if length(eligible) < vaccinated_count error("$this_monday: fewer unvaccinated than vaccinated individuals. The select_subgroups function will reduce the number of weeks considered in this group.") else @@ -232,7 +235,7 @@ end function get_eligible( pool::DataFrame, - this_monday::Date, + last_period_day::Date, )::Vector{Int} findall( row -> @@ -240,7 +243,7 @@ function get_eligible( ## les vivants: this_monday <= row.death_week && # INFO: peuvent mourir la semaine courante de this_monday. ## non-vaccinés: - this_monday < row.dose1_week && # INFO: doivent être non-vaccinés la semaine courante + row.dose1_week > last_period_day && # INFO: doivent être non-vaccinés la semaine courante ## qui ne sont pas encore dans un autre subgroup: row.availability_week <= this_monday, # INFO: était auparavant `<`. Pourtant, plus bas: `pool[i, :availability_week] = exit + Week(1)`, ce qui signifie ces non-vaccinés sont disponibles un peu plus tôt, à partir de la semaine 54 et non 55. Mais est-ce que cela pose problème pour la toute première semaine, où la vaccination commence le dimanche 27 décembre 2020? En principe, non, car cela fait un décalage de 6 + 1.24 jours seulement. Il faut peut-être éclaircir le code au sujet des décalages des jours, car une année fait 52 semaines + 1.24 jours, et les vaccinations sont réputées commencer en milieu de semaines ou en fin en ce qui concerne la toute première semaine. eachrow(pool), From 4f6e925b4dfa114d77c15d55544b53f7003316de Mon Sep 17 00:00:00 2001 From: fonsecadeline Date: Tue, 20 Jan 2026 11:52:29 +0100 Subject: [PATCH 2/6] some interrogations --- src/select.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/select.jl b/src/select.jl index 9c2c843..0931309 100644 --- a/src/select.jl +++ b/src/select.jl @@ -63,6 +63,10 @@ function create_subgroups( subgroup, this_monday, ) + + # this function edits subgroup + # but are we sure group[this_monday] is edited in the exact same way ? + # because in the end what we are returning is group, so we need to ensure it changed process_first_unvaccinated!( pool, subgroup, @@ -71,6 +75,7 @@ function create_subgroups( agenda, last_period_day ) + # same coment here end replace_unvaccinated!( this_monday, From 628f56551699a2ef3eea6f8a017514755fd2cb1e Mon Sep 17 00:00:00 2001 From: fonsecadeline Date: Mon, 26 Jan 2026 09:27:47 +0100 Subject: [PATCH 3/6] Remove part of edits after discussion --- src/select.jl | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/select.jl b/src/select.jl index 0931309..62643e4 100644 --- a/src/select.jl +++ b/src/select.jl @@ -54,7 +54,6 @@ function create_subgroups( agenda = init_agenda(), )::Dict{Date,DataFrame} pool = get_pool_from(group_id) - last_period_day = these_mondays.last + 1 for this_monday in ALL_MONDAYS if this_monday in these_mondays subgroup = group[this_monday] @@ -73,7 +72,6 @@ function create_subgroups( this_monday, vaccinated_count, agenda, - last_period_day ) # same coment here end @@ -118,10 +116,9 @@ function process_first_unvaccinated!( this_monday::Date, vaccinated_count::Int, agenda::Dict{Date,Dict{Date,Vector{Int}}}, - last_period_day::Date )::Nothing if vaccinated_count != 0 - eligible = get_eligible(pool, last_period_day) + eligible = get_eligible(pool, this_monday) if length(eligible) < vaccinated_count error("$this_monday: fewer unvaccinated than vaccinated individuals. The select_subgroups function will reduce the number of weeks considered in this group.") else @@ -240,7 +237,7 @@ end function get_eligible( pool::DataFrame, - last_period_day::Date, + this_monday::Date, )::Vector{Int} findall( row -> @@ -248,8 +245,7 @@ function get_eligible( ## les vivants: this_monday <= row.death_week && # INFO: peuvent mourir la semaine courante de this_monday. ## non-vaccinés: - row.dose1_week > last_period_day && # INFO: doivent être non-vaccinés la semaine courante - ## qui ne sont pas encore dans un autre subgroup: + this_monday < row.dose1_week && # INFO: doivent être non-vaccinés la semaine courante ## qui ne sont pas encore dans un autre subgroup: row.availability_week <= this_monday, # INFO: était auparavant `<`. Pourtant, plus bas: `pool[i, :availability_week] = exit + Week(1)`, ce qui signifie ces non-vaccinés sont disponibles un peu plus tôt, à partir de la semaine 54 et non 55. Mais est-ce que cela pose problème pour la toute première semaine, où la vaccination commence le dimanche 27 décembre 2020? En principe, non, car cela fait un décalage de 6 + 1.24 jours seulement. Il faut peut-être éclaircir le code au sujet des décalages des jours, car une année fait 52 semaines + 1.24 jours, et les vaccinations sont réputées commencer en milieu de semaines ou en fin en ce qui concerne la toute première semaine. eachrow(pool), ) From c22c635ce25f4494916548f82b8cf27e991a4ad1 Mon Sep 17 00:00:00 2001 From: fonsecadeline Date: Mon, 26 Jan 2026 09:28:42 +0100 Subject: [PATCH 4/6] same --- src/select.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/select.jl b/src/select.jl index 62643e4..56870f0 100644 --- a/src/select.jl +++ b/src/select.jl @@ -245,7 +245,8 @@ function get_eligible( ## les vivants: this_monday <= row.death_week && # INFO: peuvent mourir la semaine courante de this_monday. ## non-vaccinés: - this_monday < row.dose1_week && # INFO: doivent être non-vaccinés la semaine courante ## qui ne sont pas encore dans un autre subgroup: + this_monday < row.dose1_week && # INFO: doivent être non-vaccinés la semaine courante + ## qui ne sont pas encore dans un autre subgroup: row.availability_week <= this_monday, # INFO: était auparavant `<`. Pourtant, plus bas: `pool[i, :availability_week] = exit + Week(1)`, ce qui signifie ces non-vaccinés sont disponibles un peu plus tôt, à partir de la semaine 54 et non 55. Mais est-ce que cela pose problème pour la toute première semaine, où la vaccination commence le dimanche 27 décembre 2020? En principe, non, car cela fait un décalage de 6 + 1.24 jours seulement. Il faut peut-être éclaircir le code au sujet des décalages des jours, car une année fait 52 semaines + 1.24 jours, et les vaccinations sont réputées commencer en milieu de semaines ou en fin en ce qui concerne la toute première semaine. eachrow(pool), ) From 58d8e226a531df8c0f7338af853d44854e3cd55a Mon Sep 17 00:00:00 2001 From: fonsecadeline Date: Mon, 26 Jan 2026 10:15:39 +0100 Subject: [PATCH 5/6] Simplification suggestion If this_monday in ALL_MONDAYS but not in these_mondays then we are either before this group's Mondays, so agenda should be empty and nothing happens in replace_unvaccinated, or we are after these_mondays, and whatever we change on unvaccinated, or the pool itself, is unecessary because groups are already created. --- src/select.jl | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/select.jl b/src/select.jl index 56870f0..ad5c6f2 100644 --- a/src/select.jl +++ b/src/select.jl @@ -54,27 +54,25 @@ function create_subgroups( agenda = init_agenda(), )::Dict{Date,DataFrame} pool = get_pool_from(group_id) - for this_monday in ALL_MONDAYS - if this_monday in these_mondays - subgroup = group[this_monday] - vaccinated_count = process_vaccinated!( - pool, - subgroup, - this_monday, - ) + for this_monday in these_mondays + subgroup = group[this_monday] + vaccinated_count = process_vaccinated!( + pool, + subgroup, + this_monday, + ) - # this function edits subgroup - # but are we sure group[this_monday] is edited in the exact same way ? - # because in the end what we are returning is group, so we need to ensure it changed - process_first_unvaccinated!( - pool, - subgroup, - this_monday, - vaccinated_count, - agenda, - ) - # same coment here - end + # this function edits subgroup + # but are we sure group[this_monday] is edited in the exact same way ? + # because in the end what we are returning is group, so we need to ensure it changed + process_first_unvaccinated!( + pool, + subgroup, + this_monday, + vaccinated_count, + agenda, + ) + # same coment here replace_unvaccinated!( this_monday, pool, From 5495a8c7027d159bdab4850587e741293e4de0f9 Mon Sep 17 00:00:00 2001 From: fonsecadeline Date: Mon, 26 Jan 2026 10:24:44 +0100 Subject: [PATCH 6/6] Interrogation to simplify code --- src/select.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/select.jl b/src/select.jl index ad5c6f2..d40054d 100644 --- a/src/select.jl +++ b/src/select.jl @@ -24,6 +24,10 @@ function select_subgroups( @info "group_id = $group_id\nsubgroups total selection: [1:131]" return group else + # are you sure this else case is needed ? + # I feel the only way to get here would be that we got an error when callin create_sbugroups + # since we have a catch, I guess we never arrive here ? + for next = get_next_first_interval_iterator(group_id) try group = create_subgroups(group_id, try_these_mondays(next))