Skip to content

Commit

Permalink
Fix default capacity in unit cap cons
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelma committed Nov 2, 2023
1 parent c7fbd07 commit 9ab21f9
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/constraints/constraint_unit_flow_capacity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function add_constraint_unit_flow_capacity!(m::Model)
)
end

function _nt(u, ng, d, s, t0, t, default=Inf)
function _nt(u, ng, d, s, t0, t, default=nothing)
(unit=u, node=ng, direction=d, stochastic_scenario=s, analysis_time=t0, t=t, _default=default)
end

Expand All @@ -81,32 +81,30 @@ function _flow_upper_bound(u, ng, d, s, t0, t_flow)
end

function _max_startup_ramp(u, ng, d, s, t0, t_on)
max_shutdown_ramp[_nt(u, ng, d, s, t0, t_on)]
max_shutdown_ramp[_nt(u, ng, d, s, t0, t_on, Inf)]
end

function _max_shutdown_ramp(u, ng, d, s, t0, t_on)
max_shutdown_ramp[_nt(u, ng, d, s, t0, t_on)]
max_shutdown_ramp[_nt(u, ng, d, s, t0, t_on, Inf)]
end

_max_finite(args...) = max((a for a in args if isfinite(a))...)

function _shutdown_margin(u, ng, d, s, t0, t_flow, t_on, case, part)
if part == 1
# (F - SD)
_max_finite(_flow_upper_bound(u, ng, d, s, t0, t_flow) - _max_shutdown_ramp(u, ng, d, s, t0, t_on), 0)
max(_flow_upper_bound(u, ng, d, s, t0, t_flow) - _max_shutdown_ramp(u, ng, d, s, t0, t_on), 0)
else
# max(SU - SD, 0)
_max_finite(_max_startup_ramp(u, ng, d, s, t0, t_on) - _max_shutdown_ramp(u, ng, d, s, t0, t_on), 0)
max(_max_startup_ramp(u, ng, d, s, t0, t_on) - _max_shutdown_ramp(u, ng, d, s, t0, t_on), 0)
end
end

function _startup_margin(u, ng, d, s, t0, t_flow, t_on, case, part)
if case == 2 && part == 1
# max(SD - SU, 0)
_max_finite(_max_shutdown_ramp(u, ng, d, s, t0, t_on) - _max_startup_ramp(u, ng, d, s, t0, t_on), 0)
max(_max_shutdown_ramp(u, ng, d, s, t0, t_on) - _max_startup_ramp(u, ng, d, s, t0, t_on), 0)
else
# (F - SU)
_max_finite(_flow_upper_bound(u, ng, d, s, t0, t_flow) - _max_startup_ramp(u, ng, d, s, t0, t_on), 0)
max(_flow_upper_bound(u, ng, d, s, t0, t_flow) - _max_startup_ramp(u, ng, d, s, t0, t_on), 0)
end
end

Expand Down

0 comments on commit 9ab21f9

Please sign in to comment.