Skip to content

Commit

Permalink
Use align_variable_duration_unit function instead of convert_to_days
Browse files Browse the repository at this point in the history
  • Loading branch information
datejada committed Jan 17, 2025
1 parent f6bf05a commit 3237aba
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/constraints/constraint_common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 3237aba

Please sign in to comment.