mirror of
https://github.com/ANL-CEEESA/RELOG.git
synced 2025-12-05 23:38:52 -06:00
Reformat source code
This commit is contained in:
@@ -21,7 +21,10 @@ function resolve(model_old, instance::Instance; optimizer = nothing)::OrderedDic
|
||||
selected_pairs = Set()
|
||||
for ((node_old, t), var_old) in model_old[:is_open]
|
||||
if JuMP.value(var_old) > 0.1
|
||||
push!(selected_pairs, (node_old.location.plant_name, node_old.location.location_name))
|
||||
push!(
|
||||
selected_pairs,
|
||||
(node_old.location.plant_name, node_old.location.location_name),
|
||||
)
|
||||
end
|
||||
end
|
||||
filtered_plants = []
|
||||
@@ -63,10 +66,7 @@ function _fix_plants!(model_old, model_new)::Nothing
|
||||
# Fix open_plant variables
|
||||
for ((node_old, t), var_old) in model_old[:open_plant]
|
||||
value_old = JuMP.value(var_old)
|
||||
key = (
|
||||
node_old.location.plant_name,
|
||||
node_old.location.location_name,
|
||||
)
|
||||
key = (node_old.location.plant_name, node_old.location.location_name)
|
||||
key ∈ keys(model_new[:graph].name_to_process_node_map) || continue
|
||||
node_new = model_new[:graph].name_to_process_node_map[key]
|
||||
var_new = model_new[:open_plant][node_new, t]
|
||||
@@ -78,10 +78,7 @@ function _fix_plants!(model_old, model_new)::Nothing
|
||||
for ((node_old, t), var_old) in model_old[:is_open]
|
||||
t > 0 || continue
|
||||
value_old = JuMP.value(var_old)
|
||||
key = (
|
||||
node_old.location.plant_name,
|
||||
node_old.location.location_name,
|
||||
)
|
||||
key = (node_old.location.plant_name, node_old.location.location_name)
|
||||
key ∈ keys(model_new[:graph].name_to_process_node_map) || continue
|
||||
node_new = model_new[:graph].name_to_process_node_map[key]
|
||||
var_new = model_new[:is_open][node_new, t]
|
||||
@@ -92,10 +89,7 @@ function _fix_plants!(model_old, model_new)::Nothing
|
||||
# Fix plant capacities
|
||||
for ((node_old, t), var_old) in model_old[:capacity]
|
||||
value_old = JuMP.value(var_old)
|
||||
key = (
|
||||
node_old.location.plant_name,
|
||||
node_old.location.location_name,
|
||||
)
|
||||
key = (node_old.location.plant_name, node_old.location.location_name)
|
||||
key ∈ keys(model_new[:graph].name_to_process_node_map) || continue
|
||||
node_new = model_new[:graph].name_to_process_node_map[key]
|
||||
var_new = model_new[:capacity][node_new, t]
|
||||
@@ -108,10 +102,7 @@ function _fix_plants!(model_old, model_new)::Nothing
|
||||
for ((node_old, t), var_old) in model_old[:expansion]
|
||||
t > 0 || continue
|
||||
value_old = JuMP.value(var_old)
|
||||
key = (
|
||||
node_old.location.plant_name,
|
||||
node_old.location.location_name,
|
||||
)
|
||||
key = (node_old.location.plant_name, node_old.location.location_name)
|
||||
key ∈ keys(model_new[:graph].name_to_process_node_map) || continue
|
||||
node_new = model_new[:graph].name_to_process_node_map[key]
|
||||
var_new = model_new[:expansion][node_new, t]
|
||||
|
||||
@@ -53,4 +53,5 @@ function products_report(solution; marginal_costs)::DataFrame
|
||||
return df
|
||||
end
|
||||
|
||||
write_products_report(solution, filename; marginal_costs = true) = CSV.write(filename, products_report(solution; marginal_costs))
|
||||
write_products_report(solution, filename; marginal_costs = true) =
|
||||
CSV.write(filename, products_report(solution; marginal_costs))
|
||||
|
||||
@@ -13,7 +13,11 @@ function write(solution::AbstractDict, filename::AbstractString)
|
||||
end
|
||||
end
|
||||
|
||||
function write_reports(solution::AbstractDict, basename::AbstractString; marginal_costs = true)
|
||||
function write_reports(
|
||||
solution::AbstractDict,
|
||||
basename::AbstractString;
|
||||
marginal_costs = true,
|
||||
)
|
||||
RELOG.write_products_report(solution, "$(basename)_products.csv"; marginal_costs)
|
||||
RELOG.write_plants_report(solution, "$(basename)_plants.csv")
|
||||
RELOG.write_plant_outputs_report(solution, "$(basename)_plant_outputs.csv")
|
||||
|
||||
@@ -14,7 +14,8 @@ function model_resolve_test()
|
||||
@testset "Resolve (heuristic)" begin
|
||||
# Shoud not crash
|
||||
filename = fixture("s1.json")
|
||||
solution_old, model_old = RELOG.solve(filename, return_model = true, heuristic = true)
|
||||
solution_old, model_old =
|
||||
RELOG.solve(filename, return_model = true, heuristic = true)
|
||||
solution_new = RELOG.resolve(model_old, filename)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user