Skip to content

Commit

Permalink
Built-in data and solver (#15)
Browse files Browse the repository at this point in the history
* Format all code and add Aqua tests

* Compat at Julia 1.9

* Remove compat in docs

* Register datadeps

* Add imports

* added datadeps to download files, extract and run

* Rm main from src

* Generic optimizer

* Operatoinal HiGHS

* Bypass datadeps download check

* replaced data links with Zenodo and added plots to the tests

* Fix formatting

---------

Co-authored-by: LouisBouvier <[email protected]>
  • Loading branch information
gdalle and LouisBouvier authored Jul 24, 2023
1 parent 797cbe5 commit 9a1f4b8
Show file tree
Hide file tree
Showing 19 changed files with 365 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*.jl.mem
# /Manifest.toml
/docs/build/
/data/
*.pdf
4 changes: 2 additions & 2 deletions CITATION.bib
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ @misc{InventoryRoutingLNS.jl
title = {InventoryRoutingLNS.jl},
url = {https://github.com/LouisBouvier/InventoryRoutingLNS.jl},
version = {v0.1.0},
year = {2022},
month = {10}
year = {2023},
month = {07}
}
30 changes: 27 additions & 3 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.2"
manifest_format = "2.0"
project_hash = "bb8f6fd40d313643da984b9ae34b18cc958e8e36"
project_hash = "1e512397e466c7decef8ad90e0cb5f3541b1a6f7"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down Expand Up @@ -150,6 +150,12 @@ git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.15.0"

[[deps.DataDeps]]
deps = ["HTTP", "Libdl", "Reexport", "SHA", "p7zip_jll"]
git-tree-sha1 = "6e8d74545d34528c30ccd3fa0f3c00f8ed49584c"
uuid = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
version = "0.7.11"

[[deps.DataFrames]]
deps = ["Compat", "DataAPI", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "REPL", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "089d29c0fc00a190661517e4f3cba5dcb3fd0c08"
Expand Down Expand Up @@ -299,6 +305,12 @@ git-tree-sha1 = "f61f768bf090d97c532d24b64e07b237e9bb7b6b"
uuid = "d2c73de3-f751-5644-a686-071e5b155ba9"
version = "0.72.9+0"

[[deps.GZip]]
deps = ["Libdl"]
git-tree-sha1 = "039be665faf0b8ae36e089cd694233f5dee3f7d6"
uuid = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
version = "0.5.1"

[[deps.Gettext_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "XML2_jll"]
git-tree-sha1 = "9b02998aba7bf074d14de89f9d37ca24a1a0b046"
Expand Down Expand Up @@ -346,6 +358,18 @@ git-tree-sha1 = "129acf094d168394e80ee1dc4bc06ec835e510a3"
uuid = "2e76f6c2-a576-52d4-95c1-20adfe4de566"
version = "2.8.1+1"

[[deps.HiGHS]]
deps = ["HiGHS_jll", "MathOptInterface", "PrecompileTools", "SparseArrays"]
git-tree-sha1 = "bbd4ab443dfac4c9d5c5b40dd45f598dfad2e26a"
uuid = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
version = "1.5.2"

[[deps.HiGHS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"]
git-tree-sha1 = "216e7198aeb256e7c7921ef2937d7e1e589ba6fd"
uuid = "8fd58aa0-07eb-5a78-9b36-339c94fd15ea"
version = "1.5.3+0"

[[deps.Inflate]]
git-tree-sha1 = "5cd07aab533df5170988219191dfad0519391428"
uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
Expand Down Expand Up @@ -900,9 +924,9 @@ version = "2.3.0"

[[deps.StaticArrays]]
deps = ["LinearAlgebra", "Random", "StaticArraysCore"]
git-tree-sha1 = "fffc14c695c17bfdbfa92a2a01836cdc542a1e46"
git-tree-sha1 = "9cabadf6e7cd2349b6cf49f1915ad2028d65e881"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.6.1"
version = "1.6.2"
weakdeps = ["Statistics"]

[deps.StaticArrays.extensions]
Expand Down
9 changes: 9 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ version = "0.1.0"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Clp = "e2554f3b-3117-50c0-817c-e040a3ddf72d"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Expand All @@ -20,24 +23,30 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"

[compat]
CSV = "0.10"
Clp = "1.0"
Combinatorics = "1.0"
DataDeps = "0.7"
DataFrames = "1.6"
DataStructures = "0.18"
GZip = "0.5"
Graphs = "1.8"
Gurobi = "1.0"
HiGHS = "1.5"
IterTools = "1.8"
JSON = "0.21"
JuMP = "1.12"
Plots = "1.38"
ProgressMeter = "1.7"
Tar = "1.10"
julia = "1.9"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
58 changes: 43 additions & 15 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ version = "200.1100.600+0"

[[deps.ColorSchemes]]
deps = ["ColorTypes", "ColorVectorSpace", "Colors", "FixedPointNumbers", "PrecompileTools", "Random"]
git-tree-sha1 = "be6ab11021cd29f0344d5c4357b163af05a48cba"
git-tree-sha1 = "dd3000d954d483c1aad05fe1eb9e6a715c97013e"
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
version = "3.21.0"
version = "3.22.0"

[[deps.ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
Expand All @@ -97,10 +97,14 @@ uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
version = "0.11.4"

[[deps.ColorVectorSpace]]
deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "SpecialFunctions", "Statistics", "TensorCore"]
git-tree-sha1 = "600cc5508d66b78aae350f7accdb58763ac18589"
deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "Requires", "Statistics", "TensorCore"]
git-tree-sha1 = "a1f44953f2382ebb937d60dafbe2deea4bd23249"
uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4"
version = "0.9.10"
version = "0.10.0"
weakdeps = ["SpecialFunctions"]

[deps.ColorVectorSpace.extensions]
SpecialFunctionsExt = "SpecialFunctions"

[[deps.Colors]]
deps = ["ColorTypes", "FixedPointNumbers", "Reexport"]
Expand Down Expand Up @@ -155,6 +159,12 @@ git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.15.0"

[[deps.DataDeps]]
deps = ["HTTP", "Libdl", "Reexport", "SHA", "p7zip_jll"]
git-tree-sha1 = "6e8d74545d34528c30ccd3fa0f3c00f8ed49584c"
uuid = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
version = "0.7.11"

[[deps.DataFrames]]
deps = ["Compat", "DataAPI", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "REPL", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "089d29c0fc00a190661517e4f3cba5dcb3fd0c08"
Expand Down Expand Up @@ -206,9 +216,9 @@ version = "0.9.3"

[[deps.Documenter]]
deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "58fea7c536acd71f3eef6be3b21c0df5f3df88fd"
git-tree-sha1 = "39fd748a73dce4c05a9655475e437170d8fb1b67"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.27.24"
version = "0.27.25"

[[deps.Downloads]]
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
Expand Down Expand Up @@ -310,6 +320,12 @@ git-tree-sha1 = "f61f768bf090d97c532d24b64e07b237e9bb7b6b"
uuid = "d2c73de3-f751-5644-a686-071e5b155ba9"
version = "0.72.9+0"

[[deps.GZip]]
deps = ["Libdl"]
git-tree-sha1 = "039be665faf0b8ae36e089cd694233f5dee3f7d6"
uuid = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
version = "0.5.1"

[[deps.Gettext_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "XML2_jll"]
git-tree-sha1 = "9b02998aba7bf074d14de89f9d37ca24a1a0b046"
Expand Down Expand Up @@ -357,11 +373,23 @@ git-tree-sha1 = "129acf094d168394e80ee1dc4bc06ec835e510a3"
uuid = "2e76f6c2-a576-52d4-95c1-20adfe4de566"
version = "2.8.1+1"

[[deps.HiGHS]]
deps = ["HiGHS_jll", "MathOptInterface", "PrecompileTools", "SparseArrays"]
git-tree-sha1 = "bbd4ab443dfac4c9d5c5b40dd45f598dfad2e26a"
uuid = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
version = "1.5.2"

[[deps.HiGHS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"]
git-tree-sha1 = "216e7198aeb256e7c7921ef2937d7e1e589ba6fd"
uuid = "8fd58aa0-07eb-5a78-9b36-339c94fd15ea"
version = "1.5.3+0"

[[deps.IOCapture]]
deps = ["Logging", "Random"]
git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a"
git-tree-sha1 = "d75853a0bdbfb1ac815478bacd89cd27b550ace6"
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
version = "0.2.2"
version = "0.2.3"

[[deps.Inflate]]
git-tree-sha1 = "5cd07aab533df5170988219191dfad0519391428"
Expand All @@ -379,7 +407,7 @@ deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[deps.InventoryRoutingLNS]]
deps = ["CSV", "Clp", "Combinatorics", "DataFrames", "DataStructures", "Distributed", "Graphs", "Gurobi", "IterTools", "JSON", "JuMP", "LinearAlgebra", "Plots", "ProgressMeter", "Random", "SparseArrays"]
deps = ["CSV", "Clp", "Combinatorics", "DataDeps", "DataFrames", "DataStructures", "Distributed", "GZip", "Graphs", "Gurobi", "HiGHS", "IterTools", "JSON", "JuMP", "LinearAlgebra", "Plots", "ProgressMeter", "Random", "SparseArrays", "Tar"]
path = ".."
uuid = "9bd57249-2adc-458a-9ed8-13930b6156fb"
version = "0.1.0"
Expand Down Expand Up @@ -722,10 +750,10 @@ uuid = "efcefdf7-47ab-520b-bdef-62a2eaa19f15"
version = "10.42.0+0"

[[deps.Parsers]]
deps = ["Dates", "SnoopPrecompile"]
git-tree-sha1 = "478ac6c952fddd4399e71d4779797c538d0ff2bf"
deps = ["Dates", "PrecompileTools", "UUIDs"]
git-tree-sha1 = "4b2e829ee66d4218e0cef22c0a64ee37cf258c29"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.5.8"
version = "2.7.1"

[[deps.Pipe]]
git-tree-sha1 = "6842804e7867b115ca9de748a0cf6b364523c16d"
Expand Down Expand Up @@ -929,9 +957,9 @@ version = "2.3.0"

[[deps.StaticArrays]]
deps = ["LinearAlgebra", "Random", "StaticArraysCore"]
git-tree-sha1 = "fffc14c695c17bfdbfa92a2a01836cdc542a1e46"
git-tree-sha1 = "9cabadf6e7cd2349b6cf49f1915ad2028d65e881"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.6.1"
version = "1.6.2"
weakdeps = ["Statistics"]

[deps.StaticArrays.extensions]
Expand Down
57 changes: 56 additions & 1 deletion src/InventoryRoutingLNS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ module InventoryRoutingLNS
using Combinatorics
using Clp
using CSV
using DataDeps
using DataFrames
using Distributed
using Graphs
using Gurobi
using GZip
using HiGHS
using IterTools
using JSON
using JuMP
using Graphs
using LinearAlgebra
using Plots
using ProgressMeter
using Random
using SparseArrays
using Tar

using DataStructures: OrderedDict

Expand Down Expand Up @@ -63,9 +67,60 @@ include("analysis/analyze_solutions.jl")
include("analysis/analyze_instances.jl")

## Matheuristic
export decompress_dataset
export read_instance_CSV, read_solution
export paper_matheuristic!, route_based_matheuristic!
export modified_capa_initialization_plus_ls!, multi_depot_local_search!
export analyze_solution, analyze_instance

# Data dependencies
function __init__()
DataDeps.register(
DataDep(
"IRP-instances",
"""
This dataset of inventory routing instances is a fruit of our partnership
between Renault Group and the CERMICS laboratory at Ecole des Ponts.
Those instances are continent-scale with hundreds of customers, 21 days horizon,
and 15 depots on average. Routes can last several days (continuous-time),
and 30 types of commodities are involved, leading to bin packing problems
when filling trucks. In our paper "Solving a Continent-Scale Inventory Routing
Problem at Renault" we introduce a new large neighborhood search to solve
those instances. We hope that sharing them publicly will motivate research on
real-world and large-scale inventory routing. Environmental and economical
impacts at stake are substantial.
To cite this dataset: 10.5281/zenodo.8177237.
Louis Bouvier, Guillaume Dalle, Axel Parmentier, Thibaut Vidal.
""",
"https://zenodo.org/record/8177237/files/instances.tar.gz?download=1";
post_fetch_method=(file -> decompress_dataset(file, "instances")),
),
)
DataDeps.register(
DataDep(
"IRP-solutions",
"""
This dataset of inventory routing solutions is a fruit of our partnership
between Renault Group and the CERMICS laboratory at Ecole des Ponts.
The related instances (also publicly available) are continent-scale with
hundreds of customers, 21 days horizon, and 15 depots on average.
Routes can last several days (continuous-time), and 30 types of commodities
are involved, leading to bin packing problems when filling trucks.
In our paper "Solving a Continent-Scale Inventory Routing Problem at Renault"
we introduce a new large neighborhood search to solve those instances.
This dataset contains the solutions provided both by our algorithm and
by a benchmark we implement, as shown in the computational experiments section
of our paper. We hope that sharing them publicly will motivate research
on real-world and large-scale inventory routing. Environmental and economical
impacts at stake are substantial.
To cite this dataset: 10.5281/zenodo.8177271.
Louis Bouvier, Guillaume Dalle, Axel Parmentier, Thibaut Vidal.
""",
"https://zenodo.org/record/8177271/files/solutions.tar.gz?download=1";
post_fetch_method=(file -> decompress_dataset(file, "solutions")),
),
)
return nothing
end

end
8 changes: 5 additions & 3 deletions src/heuristics/bin_packing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ function first_fit_decreasing(
end

"""
bin_packing_milp(items::Vector{IT}, weights::Vector{<:Real}, W::Real) where {IT}
bin_packing_milp(items::Vector{IT}, weights::Vector{<:Real}, W::Real; optimizer) where {IT}
Apply exact bin-packing to (`items`, `weights`) within a container of capacity `W`.
Solve a MILP.
"""
function bin_packing_milp(items::Vector{IT}, weights::Vector{<:Real}, W::Real) where {IT}
function bin_packing_milp(
items::Vector{IT}, weights::Vector{<:Real}, W::Real; optimizer
) where {IT}
n = length(items)
B = length(first_fit_decreasing(items, weights, W))

model = Model(Gurobi.Optimizer)
model = Model(optimizer)
@variable(model, x[1:n, 1:B], Bin)
@variable(model, y[1:B], Bin)

Expand Down
Loading

0 comments on commit 9a1f4b8

Please sign in to comment.