Skip to content

Commit

Permalink
set subs systems ids
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Feb 28, 2024
1 parent cdb1f6e commit f1c8bd4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
33 changes: 22 additions & 11 deletions src/multiproblem_template.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function PSI.set_network_model!(
model::PSI.NetworkModel{<:PM.AbstractPowerModel},
)
PSI.set_network_model!(template.base_template, model)
for sub_template in get_sub_templates(template)
for (id, sub_template) in get_sub_templates(template)
PSI.set_subsystem!(model, id)
PSI.set_network_model!(sub_template, model)
end
return
Expand All @@ -69,8 +70,10 @@ function PSI.set_device_model!(
template.base_template,
PSI.DeviceModel(component_type, formulation),
)
for (_, sub_template) in get_sub_templates(template)
PSI.set_device_model!(sub_template, PSI.DeviceModel(component_type, formulation))
for (id, sub_template) in get_sub_templates(template)
network_model = PSI.DeviceModel(component_type, formulation)
PSI.set_subsystem!(network_model, id)
PSI.set_device_model!(sub_template, network_model)
end
return
end
Expand All @@ -83,7 +86,8 @@ function PSI.set_device_model!(
model::PSI.DeviceModel{<:PSY.Device, <:PSI.AbstractDeviceFormulation},
)
PSI.set_device_model!(template.base_template, model)
for sub_template in get_sub_templates(template)
for (id, sub_template) in get_sub_templates(template)
PSI.set_subsystem!(model, id)
PSI.set_device_model!(sub_template, model)
end
return
Expand All @@ -94,7 +98,8 @@ function PSI.set_device_model!(
model::PSI.DeviceModel{<:PSY.Branch, <:PSI.AbstractDeviceFormulation},
)
PSI.set_device_model!(template.base_template, model)
for sub_template in get_sub_templates(template)
for (id, sub_template) in get_sub_templates(template)
PSI.set_subsystem!(model, id)
PSI.set_device_model!(sub_template, PSI.DeviceModel(component_type, formulation))
end
return
Expand All @@ -115,11 +120,13 @@ function PSI.set_service_model!(
service_name,
ServiceModel(service_type, formulation; use_service_name=true),
)
for sub_template in get_sub_templates(template)
for (id, sub_template) in get_sub_templates(template)
service_model = ServiceModel(service_type, formulation; use_service_name=true)
PSI.set_subsystem!(service_model, id)
PSI.set_service_model!(
sub_template,
service_name,
ServiceModel(service_type, formulation; use_service_name=true),
service_model,
)
end
return
Expand All @@ -137,11 +144,13 @@ function PSI.set_service_model!(
template.base_template,
PSI.ServiceModel(service_type, formulation),
)
for sub_template in get_sub_templates(template)
for (id, sub_template) in get_sub_templates(template)
service_model = ServiceModel(service_type, formulation)
PSI.set_subsystem!(service_model, id)
PSI.set_service_model!(
sub_template,
service_name,
PSI.ServiceModel(service_type, formulation),
service_model,
)
end
return
Expand All @@ -153,7 +162,8 @@ function PSI.set_service_model!(
model::PSI.ServiceModel{<:PSY.Service, <:PSI.AbstractServiceFormulation},
)
PSI.set_service_model!(template.base_template, service_name, model)
for sub_template in get_sub_templates(template)
for (id, sub_template) in get_sub_templates(template)
PSI.set_subsystem!(model, id)
PSI.set_service_model!(sub_template, service_name, deepcopy(model))
end
return
Expand All @@ -164,7 +174,8 @@ function PSI.set_service_model!(
model::PSI.ServiceModel{<:PSY.Service, <:PSI.AbstractServiceFormulation},
)
PSI.set_service_model!(template.base_template, model)
for (_, sub_template) in get_sub_templates(template)
for (id, sub_template) in get_sub_templates(template)
PSI.set_subsystem!(model, id)
PSI.set_service_model!(sub_template, deepcopy(model))
end
return
Expand Down
5 changes: 3 additions & 2 deletions src/problems/multi_region_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function PSI.build_impl!(model::PSI.DecisionModel{MultiRegionProblem})
handle_initial_conditions!(model)
PSI.build_model!(model)
# Might need custom implementation for this container type
#serialize_metadata!(get_optimization_container(model), get_output_dir(model))
# serialize_metadata!(get_optimization_container(model), get_output_dir(model))
PSI.log_values(PSI.get_settings(model))
return
end
Expand All @@ -61,8 +61,9 @@ function handle_initial_conditions!(model::PSI.DecisionModel{MultiRegionProblem}

function instantiate_network_model(model::PSI.DecisionModel{MultiRegionProblem})
template = PSI.get_template(model)
for (_, sub_template) in get_sub_templates(template)
for (id, sub_template) in get_sub_templates(template)
network_model = PSI.get_network_model(sub_template)
PSI.set_subsystem!(network_model, id)
PSI.instantiate_network_model(network_model, PSI.get_system(model))
end
return
Expand Down

0 comments on commit f1c8bd4

Please sign in to comment.