mirror of
https://github.com/ANL-CEEESA/RELOG.git
synced 2025-12-05 23:38:52 -06:00
Add energy to output file
This commit is contained in:
@@ -8,6 +8,8 @@ using JSON, JSONSchema
|
||||
mutable struct Product
|
||||
name::String
|
||||
transportation_cost::Array{Float64}
|
||||
transportation_energy::Array{Float64}
|
||||
transportation_emissions::Dict{String, Array{Float64}}
|
||||
end
|
||||
|
||||
|
||||
@@ -40,6 +42,8 @@ mutable struct Plant
|
||||
disposal_limit::Dict{Product, Array{Float64}}
|
||||
disposal_cost::Dict{Product, Array{Float64}}
|
||||
sizes::Array{PlantSize}
|
||||
energy::Array{Float64}
|
||||
emissions::Dict{String, Array{Float64}}
|
||||
end
|
||||
|
||||
|
||||
@@ -78,7 +82,19 @@ function load(path::String)::Instance
|
||||
|
||||
# Create products
|
||||
for (product_name, product_dict) in json["products"]
|
||||
product = Product(product_name, product_dict["transportation cost (\$/km/tonne)"])
|
||||
cost = product_dict["transportation cost (\$/km/tonne)"]
|
||||
energy = zeros(T)
|
||||
emissions = Dict()
|
||||
|
||||
if "transportation energy (J/km/tonne)" in keys(product_dict)
|
||||
energy = product_dict["transportation energy (J/km/tonne)"]
|
||||
end
|
||||
|
||||
if "transportation emissions (tonne/km/tonne)" in keys(product_dict)
|
||||
emissions = product_dict["transportation emissions (tonne/km/tonne)"]
|
||||
end
|
||||
|
||||
product = Product(product_name, cost, energy, emissions)
|
||||
push!(products, product)
|
||||
prod_name_to_product[product_name] = product
|
||||
|
||||
@@ -108,6 +124,17 @@ function load(path::String)::Instance
|
||||
if value > 0)
|
||||
end
|
||||
|
||||
energy = zeros(T)
|
||||
emissions = Dict()
|
||||
|
||||
if "energy (GJ/tonne)" in keys(plant_dict)
|
||||
energy = plant_dict["energy (GJ/tonne)"]
|
||||
end
|
||||
|
||||
if "emissions (tonne/tonne)" in keys(plant_dict)
|
||||
emissions = plant_dict["emissions (tonne/tonne)"]
|
||||
end
|
||||
|
||||
for (location_name, location_dict) in plant_dict["locations"]
|
||||
sizes = PlantSize[]
|
||||
disposal_limit = Dict(p => [0.0 for t in 1:T] for p in keys(output))
|
||||
@@ -152,7 +179,9 @@ function load(path::String)::Instance
|
||||
location_dict["longitude (deg)"],
|
||||
disposal_limit,
|
||||
disposal_cost,
|
||||
sizes)
|
||||
sizes,
|
||||
energy,
|
||||
emissions)
|
||||
|
||||
push!(plants, plant)
|
||||
end
|
||||
|
||||
20
src/model.jl
20
src/model.jl
@@ -237,6 +237,10 @@ function get_solution(model::ManufacturingModel)
|
||||
"Disposal (\$)" => zeros(T),
|
||||
"Expansion (\$)" => zeros(T),
|
||||
"Total (\$)" => zeros(T),
|
||||
),
|
||||
"Energy" => Dict(
|
||||
"Plants (GJ)" => zeros(T),
|
||||
"Transportation (GJ)" => zeros(T),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -309,12 +313,9 @@ function get_solution(model::ManufacturingModel)
|
||||
"Distance (km)" => a.values["distance"],
|
||||
"Latitude (deg)" => a.source.location.latitude,
|
||||
"Longitude (deg)" => a.source.location.longitude,
|
||||
"Transportation cost (\$)" => [a.source.product.transportation_cost[t] *
|
||||
vals[t] *
|
||||
a.values["distance"]
|
||||
for t in 1:T],
|
||||
"Variable operating cost (\$)" => [plant.sizes[1].variable_operating_cost[t] * vals[t]
|
||||
for t in 1:T],
|
||||
"Transportation cost (\$)" => a.source.product.transportation_cost .* vals .* a.values["distance"],
|
||||
"Variable operating cost (\$)" => plant.sizes[1].variable_operating_cost .* vals,
|
||||
"Energy (J)" => vals .* a.values["distance"] .* a.source.product.transportation_energy,
|
||||
)
|
||||
if a.source.location isa CollectionCenter
|
||||
plant_name = "Origin"
|
||||
@@ -331,8 +332,12 @@ function get_solution(model::ManufacturingModel)
|
||||
plant_dict["Total input (tonne)"] += vals
|
||||
output["Costs"]["Transportation (\$)"] += dict["Transportation cost (\$)"]
|
||||
output["Costs"]["Variable operating (\$)"] += dict["Variable operating cost (\$)"]
|
||||
output["Energy"]["Transportation (GJ)"] += dict["Energy (J)"] / 1e
|
||||
end
|
||||
|
||||
plant_dict["Energy (GJ)"] = plant_dict["Total input (tonne)"] .* plant.energy
|
||||
output["Energy"]["Plants (GJ)"] += plant_dict["Energy (GJ)"]
|
||||
|
||||
# Outputs
|
||||
for shipping_node in plant_to_shipping_nodes[plant]
|
||||
product_name = shipping_node.product.name
|
||||
@@ -343,7 +348,8 @@ function get_solution(model::ManufacturingModel)
|
||||
if sum(disposal_amount) > 1e-5
|
||||
skip_plant = false
|
||||
plant_dict["Output"]["Dispose"][product_name] = disposal_dict = Dict()
|
||||
disposal_dict["Amount (tonne)"] = [JuMP.value(model.vars.dispose[shipping_node, t]) for t in 1:T]
|
||||
disposal_dict["Amount (tonne)"] = [JuMP.value(model.vars.dispose[shipping_node, t])
|
||||
for t in 1:T]
|
||||
disposal_dict["Cost (\$)"] = [disposal_dict["Amount (tonne)"][t] *
|
||||
plant.disposal_cost[shipping_node.product][t]
|
||||
for t in 1:T]
|
||||
|
||||
Reference in New Issue
Block a user