From 3237aba703f80d0177d764605319e64e39c30c78 Mon Sep 17 00:00:00 2001 From: datejada Date: Fri, 17 Jan 2025 16:06:34 +0100 Subject: [PATCH 1/3] Use align_variable_duration_unit function instead of convert_to_days --- src/constraints/constraint_common.jl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/constraints/constraint_common.jl b/src/constraints/constraint_common.jl index 3c86ada62e..05c653ad59 100644 --- a/src/constraints/constraint_common.jl +++ b/src/constraints/constraint_common.jl @@ -71,15 +71,11 @@ past_units_on_indices(m, param, u, s_path, t) = _past_indices(m, units_on_indice function _past_indices(m, indices, param, s_path, t; kwargs...) look_behind = maximum(maximum_parameter_value(param(; kwargs..., stochastic_scenario=s, t=t)) for s in s_path) - convert_to_days(duration::Year) = Day(Dates.value(duration) * 366) - convert_to_days(duration::Month) = Day(Dates.value(duration) * 31) - convert_to_days(duration) = duration - ( (; ind..., weight=ifelse( - end_(t) - end_(ind.t) < convert_to_days(param(m; kwargs..., stochastic_scenario=ind.stochastic_scenario, t=t)), 1, 0 + end_(t) - end_(ind.t) < align_variable_duration_unit(param(m; kwargs..., stochastic_scenario=ind.stochastic_scenario, t=t), end_(t)), 1, 0 ), ) for ind in indices( From cc722a709327ccb9dd4dfac4ba8259e6e7f30f2b Mon Sep 17 00:00:00 2001 From: datejada Date: Fri, 17 Jan 2025 17:11:27 +0100 Subject: [PATCH 2/3] Use start to align durations --- src/constraints/constraint_common.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constraints/constraint_common.jl b/src/constraints/constraint_common.jl index 05c653ad59..90936868bc 100644 --- a/src/constraints/constraint_common.jl +++ b/src/constraints/constraint_common.jl @@ -75,7 +75,7 @@ function _past_indices(m, indices, param, s_path, t; kwargs...) (; ind..., weight=ifelse( - end_(t) - end_(ind.t) < align_variable_duration_unit(param(m; kwargs..., stochastic_scenario=ind.stochastic_scenario, t=t), end_(t)), 1, 0 + end_(t) - end_(ind.t) < align_variable_duration_unit(param(m; kwargs..., stochastic_scenario=ind.stochastic_scenario, t=t), start(t)), 1, 0 ), ) for ind in indices( From d68fe915db1468614c589f844d8fcd36fc389092 Mon Sep 17 00:00:00 2001 From: datejada Date: Fri, 17 Jan 2025 17:45:25 +0100 Subject: [PATCH 3/3] Fix param call to work with the align function --- src/constraints/constraint_common.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constraints/constraint_common.jl b/src/constraints/constraint_common.jl index 90936868bc..6555b20fe9 100644 --- a/src/constraints/constraint_common.jl +++ b/src/constraints/constraint_common.jl @@ -75,7 +75,7 @@ function _past_indices(m, indices, param, s_path, t; kwargs...) (; ind..., weight=ifelse( - end_(t) - end_(ind.t) < align_variable_duration_unit(param(m; kwargs..., stochastic_scenario=ind.stochastic_scenario, t=t), start(t)), 1, 0 + end_(t) - end_(ind.t) < align_variable_duration_unit(param(; kwargs..., stochastic_scenario=ind.stochastic_scenario, t=t), start(t)), 1, 0 ), ) for ind in indices(