model-3: solve: accept filename and optimizer

feature/composition
Alinson S. Xavier 1 year ago
parent 18f963836d
commit 72e49313c9

@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised # This file is machine-generated - editing it directly is not advised
julia_version = "1.9.0" julia_version = "1.10.1"
manifest_format = "2.0" manifest_format = "2.0"
project_hash = "6050446040717864eaea84cf3a5f066d959d36dd" project_hash = "4170463ca454c6921d0f3b304e50e00eea5e30ba"
[[deps.ArgTools]] [[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
@ -74,7 +74,7 @@ weakdeps = ["Dates", "LinearAlgebra"]
[[deps.CompilerSupportLibraries_jll]] [[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.0.2+0" version = "1.1.0+0"
[[deps.CoordinateTransformations]] [[deps.CoordinateTransformations]]
deps = ["LinearAlgebra", "StaticArrays"] deps = ["LinearAlgebra", "StaticArrays"]
@ -189,6 +189,18 @@ git-tree-sha1 = "5995b72d385235f3fe55f8f0c4ad61049f867814"
uuid = "2e9cd046-0924-5485-92f1-d5272153d98b" uuid = "2e9cd046-0924-5485-92f1-d5272153d98b"
version = "1.2.1" version = "1.2.1"
[[deps.HiGHS]]
deps = ["HiGHS_jll", "MathOptInterface", "PrecompileTools", "SparseArrays"]
git-tree-sha1 = "a216e32299172b83abfe699604584f413ffbb045"
uuid = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
version = "1.9.0"
[[deps.HiGHS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Zlib_jll"]
git-tree-sha1 = "9a550d55c49334beb538c5ad9504f07fc29a13dc"
uuid = "8fd58aa0-07eb-5a78-9b36-339c94fd15ea"
version = "1.7.0+0"
[[deps.InlineStrings]] [[deps.InlineStrings]]
deps = ["Parsers"] deps = ["Parsers"]
git-tree-sha1 = "9cc2baf75c6d09f9da536ddf58eb2f29dedaf461" git-tree-sha1 = "9cc2baf75c6d09f9da536ddf58eb2f29dedaf461"
@ -256,21 +268,26 @@ uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
[[deps.LibCURL]] [[deps.LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"] deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
version = "0.6.3" version = "0.6.4"
[[deps.LibCURL_jll]] [[deps.LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
version = "7.84.0+0" version = "8.4.0+0"
[[deps.LibGit2]] [[deps.LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"] deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
[[deps.LibGit2_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"]
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
version = "1.6.4+0"
[[deps.LibSSH2_jll]] [[deps.LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"] deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
version = "1.10.2+0" version = "1.11.0+1"
[[deps.Libdl]] [[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
@ -323,7 +340,7 @@ version = "1.26.0"
[[deps.MbedTLS_jll]] [[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.2+0" version = "2.28.2+1"
[[deps.Missings]] [[deps.Missings]]
deps = ["DataAPI"] deps = ["DataAPI"]
@ -336,7 +353,7 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[deps.MozillaCACerts_jll]] [[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159" uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2022.10.11" version = "2023.1.10"
[[deps.MutableArithmetics]] [[deps.MutableArithmetics]]
deps = ["LinearAlgebra", "SparseArrays", "Test"] deps = ["LinearAlgebra", "SparseArrays", "Test"]
@ -363,12 +380,12 @@ version = "1.2.0"
[[deps.OpenBLAS_jll]] [[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.21+4" version = "0.3.23+4"
[[deps.OpenLibm_jll]] [[deps.OpenLibm_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "05823500-19ac-5b8b-9628-191a04bc5112" uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
version = "0.8.1+0" version = "0.8.1+2"
[[deps.OpenSpecFun_jll]] [[deps.OpenSpecFun_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
@ -390,7 +407,7 @@ version = "2.8.1"
[[deps.Pkg]] [[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.9.0" version = "1.10.0"
[[deps.PooledArrays]] [[deps.PooledArrays]]
deps = ["DataAPI", "Future"] deps = ["DataAPI", "Future"]
@ -429,7 +446,7 @@ deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
[[deps.Random]] [[deps.Random]]
deps = ["SHA", "Serialization"] deps = ["SHA"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[deps.Reexport]] [[deps.Reexport]]
@ -474,6 +491,7 @@ version = "1.2.1"
[[deps.SparseArrays]] [[deps.SparseArrays]]
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
version = "1.10.0"
[[deps.SpecialFunctions]] [[deps.SpecialFunctions]]
deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
@ -509,7 +527,7 @@ version = "1.4.2"
[[deps.Statistics]] [[deps.Statistics]]
deps = ["LinearAlgebra", "SparseArrays"] deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
version = "1.9.0" version = "1.10.0"
[[deps.StatsAPI]] [[deps.StatsAPI]]
deps = ["LinearAlgebra"] deps = ["LinearAlgebra"]
@ -524,9 +542,9 @@ uuid = "892a3eda-7b42-436c-8928-eab12a02cf0e"
version = "0.3.4" version = "0.3.4"
[[deps.SuiteSparse_jll]] [[deps.SuiteSparse_jll]]
deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"] deps = ["Artifacts", "Libdl", "libblastrampoline_jll"]
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
version = "5.10.1+6" version = "7.2.1+1"
[[deps.TOML]] [[deps.TOML]]
deps = ["Dates"] deps = ["Dates"]
@ -590,19 +608,19 @@ version = "0.10.1"
[[deps.Zlib_jll]] [[deps.Zlib_jll]]
deps = ["Libdl"] deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a" uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
version = "1.2.13+0" version = "1.2.13+1"
[[deps.libblastrampoline_jll]] [[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.7.0+0" version = "5.8.0+1"
[[deps.nghttp2_jll]] [[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
version = "1.48.0+0" version = "1.52.0+1"
[[deps.p7zip_jll]] [[deps.p7zip_jll]]
deps = ["Artifacts", "Libdl"] deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
version = "17.4.0+0" version = "17.4.0+2"

@ -4,6 +4,7 @@ CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Geodesy = "0ef565a4-170c-5f04-8de2-149903a85f3d" Geodesy = "0ef565a4-170c-5f04-8de2-149903a85f3d"
Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b" Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572" JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce" NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"

@ -4,7 +4,6 @@
using CSV using CSV
using DataFrames using DataFrames
using Gurobi
using JSON using JSON
using JuMP using JuMP
using OrderedCollections using OrderedCollections
@ -603,9 +602,9 @@ function generate_json()
write_json(data, "output-3/case.json") write_json(data, "output-3/case.json")
end end
function solve() function solve(filename, optimizer)
@info "Reading JSON file" @info "Reading JSON file"
data = read_json("output-3/case.json") data = read_json(filename)
T = data.T T = data.T
centers = data.centers centers = data.centers
@ -613,7 +612,7 @@ function solve()
products = data.products products = data.products
emissions = data.emissions emissions = data.emissions
model = Model(Gurobi.Optimizer) model = Model(optimizer)
# Graph # Graph
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@ -1012,6 +1011,7 @@ function solve()
# Report: Transportation # Report: Transportation
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
output_dir = dirname(filename)
df = DataFrame() df = DataFrame()
df."source" = String[] df."source" = String[]
df."destination" = String[] df."destination" = String[]
@ -1041,7 +1041,7 @@ function solve()
] ]
) )
end end
CSV.write("output-3/transp.csv", df) CSV.write("$output_dir/transp.csv", df)
# Report: Centers # Report: Centers
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@ -1079,7 +1079,7 @@ function solve()
] ]
) )
end end
CSV.write("output-3/centers.csv", df) CSV.write("$output_dir/centers.csv", df)
# Report: Plants # Report: Plants
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@ -1101,7 +1101,7 @@ function solve()
] ]
) )
end end
CSV.write("output-3/plants.csv", df) CSV.write("$output_dir/plants.csv", df)
# Report: Plant Outputs # Report: Plant Outputs
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@ -1137,7 +1137,7 @@ function solve()
] ]
) )
end end
CSV.write("output-3/plant-outputs.csv", df) CSV.write("$output_dir/plant-outputs.csv", df)
# Report: Plant Emissions # Report: Plant Emissions
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@ -1159,7 +1159,7 @@ function solve()
] ]
) )
end end
CSV.write("output-3/plant-emissions.csv", df) CSV.write("$output_dir/plant-emissions.csv", df)
# Report: Transportation Emissions # Report: Transportation Emissions
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
@ -1192,6 +1192,8 @@ function solve()
] ]
) )
end end
CSV.write("output-3/transp-emissions.csv", df) CSV.write("$output_dir/transp-emissions.csv", df)
return
end end

Loading…
Cancel
Save