Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use align_variable_duration_unit function instead of convert_to_days #1154

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(; kwargs..., stochastic_scenario=ind.stochastic_scenario, t=t), start(t)), 1, 0
),
)
for ind in indices(
Expand Down
Loading