Skip to content

Commit

Permalink
implement has_time_series with type and name
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Nov 29, 2024
1 parent 5510a92 commit 1e56416
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ function _add_vom_cost_to_objective!(
)
for t in get_time_steps(container)
exp =
_add_proportional_term!(container, T(), component, cost_term_normalized * multiplier, t)
_add_proportional_term!(
container,
T(),
component,
cost_term_normalized * multiplier,
t,
)
add_to_expression!(container, ProductionCostExpression, exp, component, t)
end
return
Expand Down
20 changes: 14 additions & 6 deletions src/devices_models/devices/common/range_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,10 @@ function lower_bound_range_with_parameter!(
mult = get_multiplier_array(param_container)
jump_model = get_jump_model(container)
time_steps = axes(constraint_container)[2]
ts_name = get_time_series_names(model)[P]
ts_type = get_default_time_series_type(container)
for device in devices
if !(PSY.has_time_series(device))
if !(PSY.has_time_series(device, ts_type, ts_name))
continue
end
name = PSY.get_name(device)
Expand All @@ -733,7 +735,9 @@ function _add_parameterized_lower_bound_range_constraints_impl!(
W <: AbstractDeviceFormulation,
}
time_steps = get_time_steps(container)
names = [PSY.get_name(d) for d in devices if PSY.has_time_series(d)]
ts_name = get_time_series_names(model)[U]
ts_type = get_default_time_series_type(container)
names = [PSY.get_name(d) for d in devices if PSY.has_time_series(d, ts_type, ts_name)]
if isempty(names)
@debug "There are no $V devices with time series data"
return
Expand Down Expand Up @@ -840,15 +844,17 @@ function upper_bound_range_with_parameter!(
lhs_array,
param::P,
devices::IS.FlattenIteratorWrapper{V},
::DeviceModel{V, W},
model::DeviceModel{V, W},
) where {P <: TimeSeriesParameter, V <: PSY.Component, W <: AbstractDeviceFormulation}
param_container = get_parameter(container, param, V)
mult = get_multiplier_array(param_container)
jump_model = get_jump_model(container)
time_steps = axes(constraint_container)[2]
ts_name = get_time_series_names(model)[P]
ts_type = get_default_time_series_type(container)
for device in devices
name = PSY.get_name(device)
if !(PSY.has_time_series(device))
if !(PSY.has_time_series(device, ts_type, ts_name))
continue
end
param = get_parameter_column_refs(param_container, name)
Expand All @@ -874,9 +880,11 @@ function _add_parameterized_upper_bound_range_constraints_impl!(
W <: AbstractDeviceFormulation,
}
time_steps = get_time_steps(container)
names = [PSY.get_name(d) for d in devices if PSY.has_time_series(d)]
ts_name = get_time_series_names(model)[P]
ts_type = get_default_time_series_type(container)
names = [PSY.get_name(d) for d in devices if PSY.has_time_series(d, ts_type, ts_name)]
if isempty(names)
@debug "There are no $V devices with time series data"
@debug "There are no $V devices with time series data $ts_type, $ts_name"
return
end

Expand Down
3 changes: 2 additions & 1 deletion src/operation/decision_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ function DecisionModel{M}(
elseif name isa String
name = Symbol(name)
end
ts_type = get_deterministic_time_series_type(sys)
internal = IS.Optimization.ModelInternal(
OptimizationContainer(sys, settings, jump_model, PSY.Deterministic),
OptimizationContainer(sys, settings, jump_model, ts_type),
)

template_ = deepcopy(template)
Expand Down
5 changes: 3 additions & 2 deletions src/parameters/add_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ function _add_time_series_parameters!(
device_names = String[]
initial_values = Dict{String, AbstractArray}()
for device in devices
if !PSY.has_time_series(device)
if !PSY.has_time_series(device, ts_type, ts_name)
@debug "skipped time series for $D, $(PSY.get_name(device))"
continue
end
push!(device_names, PSY.get_name(device))
Expand Down Expand Up @@ -229,7 +230,7 @@ function _add_time_series_parameters!(
end

for device in devices
if !PSY.has_time_series(device)
if !PSY.has_time_series(device, ts_type, ts_name)
continue
end
name = PSY.get_name(device)
Expand Down
2 changes: 1 addition & 1 deletion src/parameters/update_container_parameter_values.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function _update_parameter_values!(
components = get_available_components(device_model, get_system(model))
ts_uuids = Set{String}()
for component in components
if !PSY.has_time_series(component)
if !PSY.has_time_series(component, U, ts_name)
continue
end
ts_uuid = _get_ts_uuid(attributes, PSY.get_name(component))
Expand Down

0 comments on commit 1e56416

Please sign in to comment.