Skip to content

Commit

Permalink
Fix in LNS/GVNS: Termination condition has not been considered after …
Browse files Browse the repository at this point in the history
…initial construction
  • Loading branch information
graidl committed Dec 8, 2023
1 parent 283cfc6 commit c2f5a37
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 28 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ Major changes in releases:

## Upcoming

## Version 0.1.12
- Fix in `GVNS` and `LNS`: The termination condition has not been considered directly after
performing the initial construction method(s).

## Version 0.1.11
- Fix in ``GVNS`: Empty local search method list led to an infinite loop
- Fix in `GVNS`: Empty local search method list led to an infinite loop
[issue #5](/../../issues/5)

## Version 0.1.10
Expand Down
10 changes: 5 additions & 5 deletions MHLibDemos/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ version = "1.3.5"

[[deps.Compat]]
deps = ["UUIDs"]
git-tree-sha1 = "8a62af3e248a8c4bad6b32cbbe663ae02275e32c"
git-tree-sha1 = "886826d76ea9e72b35fcd000e535588f7b60f21d"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "4.10.0"
version = "4.10.1"
weakdeps = ["Dates", "LinearAlgebra"]

[deps.Compat.extensions]
Expand Down Expand Up @@ -153,15 +153,15 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[deps.LoweredCodeUtils]]
deps = ["JuliaInterpreter"]
git-tree-sha1 = "c165f205e030208760ebd75b5e1f7706761d9218"
git-tree-sha1 = "0b8cf121228f7dae022700c1c11ac1f04122f384"
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
version = "2.3.1"
version = "2.3.2"

[[deps.MHLib]]
deps = ["ArgParse", "DataStructures", "Logging", "Printf", "Random", "Reexport", "StatsBase"]
path = ".."
uuid = "0f3a0e6e-e0e7-4894-bd64-856f0ae3b635"
version = "0.1.10"
version = "0.1.12"

[[deps.MacroTools]]
deps = ["Markdown", "Random"]
Expand Down
4 changes: 2 additions & 2 deletions MHLibDemos/bin/demo_graph_coloring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ using MHLibDemos

# Command line arguments are parsed and used to set global parameters
# use `@<filename>` to read parameters from configuration file `<filename>`
# alternatively, they may also be provided here to the call as vector of strings
solve_graph_coloring()
# alternatively, they may also be provided here in a string
solve_graph_coloring("--gcp_colors=3")
4 changes: 2 additions & 2 deletions MHLibDemos/bin/demo_maxsat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ using MHLibDemos

# Command line arguments are parsed and used to set global parameters
# use `@<filename>` to read parameters from configuration file `<filename>`
# alternatively, they may also be provided here to the call as vector of strings
solve_maxsat()
# alternatively, they may also be provided here as a string
solve_maxsat("--seed=8 --mh_ttime=3")
2 changes: 1 addition & 1 deletion MHLibDemos/bin/demo_misp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ using MHLibDemos
# solve_misp()

# for testing on a small random graph
solve_misp(["--seed", "3", "--ifile", "gnm-10-13"])
solve_misp("--seed=3 --ifile=gnm-10-13")
2 changes: 1 addition & 1 deletion MHLibDemos/bin/demo_mkp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ using MHLibDemos

# Command line arguments are parsed and used to set global parameters
# use `@<filename>` to read parameters from configuration file `<filename>`
# alternatively, they may also be provided here to the call as vector of strings
# alternatively, they may also be provided here in a string
solve_mkp()
4 changes: 2 additions & 2 deletions MHLibDemos/bin/demo_onemax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ using MHLibDemos

# Command line arguments are parsed and used to set global parameters
# use `@<filename>` to read parameters from configuration file `<filename>`
# alternatively, they may also be provided here to the call as vector of strings
solve_onemax()
# alternatively, they may also be provided here in a string
solve_onemax("--onemax_n=90")
2 changes: 1 addition & 1 deletion MHLibDemos/bin/demo_tsp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ using MHLibDemos
# Command line arguments are parsed and used to set global parameters
# use `@<filename>` to read parameters from configuration file `<filename>`
# alternatively, they may also be provided here to the call as vector of strings
solve_tsp()
solve_tsp("--mh_titer=1000")
6 changes: 3 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.4"
manifest_format = "2.0"
project_hash = "120b5576b04f4d26ef6670cecf1c2071e4f8ef62"
project_hash = "173a5d24d7b4bfc564ba26748cb660b12b7a8032"

[[deps.ArgParse]]
deps = ["Logging", "TextWrap"]
Expand All @@ -22,9 +22,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.Compat]]
deps = ["UUIDs"]
git-tree-sha1 = "8a62af3e248a8c4bad6b32cbbe663ae02275e32c"
git-tree-sha1 = "886826d76ea9e72b35fcd000e535588f7b60f21d"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "4.10.0"
version = "4.10.1"
weakdeps = ["Dates", "LinearAlgebra"]

[deps.Compat.extensions]
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MHLib"
uuid = "0f3a0e6e-e0e7-4894-bd64-856f0ae3b635"
authors = ["Guenther Raidl <[email protected]> and others"]
version = "0.1.11"
version = "0.1.12"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down
3 changes: 2 additions & 1 deletion src/GVNSs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ Actually performs the construction heuristics followed by the GVNS.
function MHLib.run!(gvns::GVNS)
sol = copy(gvns.scheduler.incumbent)
@assert gvns.scheduler.incumbent_valid || !isempty(gvns.meths_ch)
perform_sequentially!(gvns.scheduler, sol, gvns.meths_ch)
terminate = perform_sequentially!(gvns.scheduler, sol, gvns.meths_ch)
terminate && return
gvns!(gvns, sol)
end

Expand Down
3 changes: 2 additions & 1 deletion src/LNSs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ Perform the construction heuristics followed by a LNS.
function MHLib.run!(lns::LNS)
sol = copy(lns.scheduler.incumbent)
@assert lns.scheduler.incumbent_valid || !isempty(lns.meths_ch)
perform_sequentially!(lns.scheduler, sol, lns.meths_ch)
terminate = perform_sequentially!(lns.scheduler, sol, lns.meths_ch)
terminate && return
lns!(lns, sol)
end

Expand Down
7 changes: 4 additions & 3 deletions src/Schedulers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,16 @@ end
perform_sequentially!(scheduler, solution, methods)
Applies the given methods sequentially, finally keeping the best solution as incumbent.
Returns true if the termination condition has been fulfilled, else false.
"""
function perform_sequentially!(s::Scheduler, sol::Solution, meths::Vector{MHMethod})
for m in next_method(meths)
res = perform_method!(s, m, sol)
if res.terminate
break
end
update_incumbent!(s, sol, time() - s.time_start)
res.terminate && return true
end
return false
end


Expand Down
8 changes: 4 additions & 4 deletions test/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ version = "1.3.5"

[[deps.Compat]]
deps = ["UUIDs"]
git-tree-sha1 = "8a62af3e248a8c4bad6b32cbbe663ae02275e32c"
git-tree-sha1 = "886826d76ea9e72b35fcd000e535588f7b60f21d"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "4.10.0"
version = "4.10.1"
weakdeps = ["Dates", "LinearAlgebra"]

[deps.Compat.extensions]
Expand Down Expand Up @@ -153,9 +153,9 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[deps.LoweredCodeUtils]]
deps = ["JuliaInterpreter"]
git-tree-sha1 = "c165f205e030208760ebd75b5e1f7706761d9218"
git-tree-sha1 = "0b8cf121228f7dae022700c1c11ac1f04122f384"
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
version = "2.3.1"
version = "2.3.2"

[[deps.MacroTools]]
deps = ["Markdown", "Random"]
Expand Down

2 comments on commit c2f5a37

@graidl
Copy link
Collaborator Author

@graidl graidl commented on c2f5a37 Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/96746

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.12 -m "<description of version>" c2f5a377623f832b851f3f1b57f7ceebba822057
git push origin v0.1.12

Please sign in to comment.