From 7d4a76391004c58a296c682ed59f88a500e53497 Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Fri, 10 Mar 2023 14:20:21 -0600 Subject: [PATCH] Fix issue with collection disposal; increase precision in CSV reports --- src/model/build.jl | 4 ++-- src/reports/plant_emissions.jl | 2 +- src/reports/plant_outputs.jl | 8 ++++---- src/reports/plants.jl | 24 ++++++++++++------------ src/reports/products.jl | 2 +- src/reports/tr.jl | 10 +++++----- src/reports/tr_emissions.jl | 8 ++++---- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/model/build.jl b/src/model/build.jl index 0f7ada4..357f73e 100644 --- a/src/model/build.jl +++ b/src/model/build.jl @@ -184,8 +184,8 @@ function create_shipping_node_constraints!(model::JuMP.Model) for n in graph.collection_shipping_nodes model[:eq_balance][n, t] = @constraint( model, - sum(model[:flow][a, t] for a in n.outgoing_arcs) == - n.location.amount[t] + model[:collection_dispose][n, t] + sum(model[:flow][a, t] for a in n.outgoing_arcs) + + model[:collection_dispose][n, t] == n.location.amount[t] ) end for prod in model[:instance].products diff --git a/src/reports/plant_emissions.jl b/src/reports/plant_emissions.jl index cc420a0..8323637 100644 --- a/src/reports/plant_emissions.jl +++ b/src/reports/plant_emissions.jl @@ -24,7 +24,7 @@ function plant_emissions_report(solution)::DataFrame location_name, year, emission_name, - round(emission_amount[year], digits = 2), + round(emission_amount[year], digits = 6), ], ) end diff --git a/src/reports/plant_outputs.jl b/src/reports/plant_outputs.jl index 053f5ab..c72ccd0 100644 --- a/src/reports/plant_outputs.jl +++ b/src/reports/plant_outputs.jl @@ -30,7 +30,7 @@ function plant_outputs_report(solution)::DataFrame end end end - sent = round.(sent, digits = 2) + sent = round.(sent, digits = 6) disposal_amount = zeros(T) disposal_cost = zeros(T) @@ -38,8 +38,8 @@ function plant_outputs_report(solution)::DataFrame disposal_amount += disposal_dict[product_name]["Amount (tonne)"] disposal_cost += disposal_dict[product_name]["Cost (\$)"] end - disposal_amount = round.(disposal_amount, digits = 2) - disposal_cost = round.(disposal_cost, digits = 2) + disposal_amount = round.(disposal_amount, digits = 6) + disposal_cost = round.(disposal_cost, digits = 6) for year = 1:T push!( @@ -49,7 +49,7 @@ function plant_outputs_report(solution)::DataFrame location_name, year, product_name, - round(amount_produced[year], digits = 2), + round(amount_produced[year], digits = 6), sent[year], disposal_amount[year], disposal_cost[year], diff --git a/src/reports/plants.jl b/src/reports/plants.jl index 4d1a943..996621c 100644 --- a/src/reports/plants.jl +++ b/src/reports/plants.jl @@ -28,25 +28,25 @@ function plants_report(solution)::DataFrame for (plant_name, plant_dict) in solution["Plants"] for (location_name, location_dict) in plant_dict for year = 1:T - capacity = round(location_dict["Capacity (tonne)"][year], digits = 2) - received = round(location_dict["Total input (tonne)"][year], digits = 2) - processed = round(location_dict["Process (tonne)"][year], digits = 2) - in_storage = round(location_dict["Storage (tonne)"][year], digits = 2) - utilization_factor = round(processed / capacity * 100.0, digits = 2) - energy = round(location_dict["Energy (GJ)"][year], digits = 2) + capacity = round(location_dict["Capacity (tonne)"][year], digits = 6) + received = round(location_dict["Total input (tonne)"][year], digits = 6) + processed = round(location_dict["Process (tonne)"][year], digits = 6) + in_storage = round(location_dict["Storage (tonne)"][year], digits = 6) + utilization_factor = round(processed / capacity * 100.0, digits = 6) + energy = round(location_dict["Energy (GJ)"][year], digits = 6) latitude = round(location_dict["Latitude (deg)"], digits = 6) longitude = round(location_dict["Longitude (deg)"], digits = 6) - opening_cost = round(location_dict["Opening cost (\$)"][year], digits = 2) + opening_cost = round(location_dict["Opening cost (\$)"][year], digits = 6) expansion_cost = - round(location_dict["Expansion cost (\$)"][year], digits = 2) + round(location_dict["Expansion cost (\$)"][year], digits = 6) fixed_cost = - round(location_dict["Fixed operating cost (\$)"][year], digits = 2) + round(location_dict["Fixed operating cost (\$)"][year], digits = 6) var_cost = - round(location_dict["Variable operating cost (\$)"][year], digits = 2) - storage_cost = round(location_dict["Storage cost (\$)"][year], digits = 2) + round(location_dict["Variable operating cost (\$)"][year], digits = 6) + storage_cost = round(location_dict["Storage cost (\$)"][year], digits = 6) total_cost = round( opening_cost + expansion_cost + fixed_cost + var_cost + storage_cost, - digits = 2, + digits = 6, ) push!( df, diff --git a/src/reports/products.jl b/src/reports/products.jl index 68def0e..75c8bc3 100644 --- a/src/reports/products.jl +++ b/src/reports/products.jl @@ -37,8 +37,8 @@ function products_report(solution; marginal_costs = true)::DataFrame longitude, year, amount, - marginal_cost, amount_disposed, + marginal_cost, acquisition_cost, disposal_cost, ], diff --git a/src/reports/tr.jl b/src/reports/tr.jl index 5519a70..8973c43 100644 --- a/src/reports/tr.jl +++ b/src/reports/tr.jl @@ -42,24 +42,24 @@ function transportation_report(solution)::DataFrame round(dst_location_dict["Longitude (deg)"], digits = 6), dst_location_dict["Input product"], year, - round(src_location_dict["Distance (km)"], digits = 2), + round(src_location_dict["Distance (km)"], digits = 6), round( src_location_dict["Amount (tonne)"][year], - digits = 2, + digits = 6, ), round( src_location_dict["Amount (tonne)"][year] * src_location_dict["Distance (km)"], - digits = 2, + digits = 6, ), round( src_location_dict["Transportation cost (\$)"][year], - digits = 2, + digits = 6, ), round( src_location_dict["Transportation energy (J)"][year] / 1e9, - digits = 2, + digits = 6, ), ], ) diff --git a/src/reports/tr_emissions.jl b/src/reports/tr_emissions.jl index 5f1cd47..8b5025e 100644 --- a/src/reports/tr_emissions.jl +++ b/src/reports/tr_emissions.jl @@ -44,18 +44,18 @@ function transportation_emissions_report(solution)::DataFrame round(dst_location_dict["Longitude (deg)"], digits = 6), dst_location_dict["Input product"], year, - round(src_location_dict["Distance (km)"], digits = 2), + round(src_location_dict["Distance (km)"], digits = 6), round( src_location_dict["Amount (tonne)"][year], - digits = 2, + digits = 6, ), round( src_location_dict["Amount (tonne)"][year] * src_location_dict["Distance (km)"], - digits = 2, + digits = 6, ), emission_name, - round(emission_amount[year], digits = 2), + round(emission_amount[year], digits = 6), ], ) end