diff --git a/docs/src/algorithms/combinatorial.md b/docs/src/algorithms/combinatorial.md index e2405d6..cb78743 100644 --- a/docs/src/algorithms/combinatorial.md +++ b/docs/src/algorithms/combinatorial.md @@ -19,7 +19,7 @@ GRASP ``` ```@docs -Metaheuristics.GreedyRandomizedContructor +Metaheuristics.GreedyRandomizedConstructor ``` ```@docs diff --git a/src/algorithms/combinatorial/GRASP/GRASP.jl b/src/algorithms/combinatorial/GRASP/GRASP.jl index 26adf95..f2ceb31 100644 --- a/src/algorithms/combinatorial/GRASP/GRASP.jl +++ b/src/algorithms/combinatorial/GRASP/GRASP.jl @@ -23,9 +23,9 @@ Greedy Randomized Adaptive Search Procedure. - `initial`: an initial solution if necessary. - `constructor` parameters for the greedy constructor. -- `local_search` the local search strategy `BestImprovingSearch()` (default) and `FirstImprovingSearch()`. +- `local_search` the local search strategy `BestImproveSearch()` (default) and `FirstImproveSearch()`. -See [`GreedyRandomizedContructor`](@ref) +See [`GreedyRandomizedConstructor`](@ref) # Example: Knapsack Problem @@ -59,8 +59,8 @@ function main() candidates = rand(search_space) # define each GRASP component - constructor = MH.GreedyRandomizedContructor(;candidates, instance, α = 0.95) - local_search = MH.BestImprovingSearch() + constructor = MH.GreedyRandomizedConstructor(;candidates, instance, α = 0.95) + local_search = MH.BestImproveSearch() neighborhood = MH.TwoOptNeighborhood() grasp = MH.GRASP(;constructor, local_search) @@ -76,7 +76,7 @@ end main() ``` """ -function GRASP(;initial=nothing, constructor=nothing, local_search=BestImprovingSearch(), +function GRASP(;initial=nothing, constructor=nothing, local_search=BestImproveSearch(), options = Options(), information=Information()) # TODO if isnothing(constructor) diff --git a/src/algorithms/combinatorial/GRASP/constructor.jl b/src/algorithms/combinatorial/GRASP/constructor.jl index aab2203..1f8051f 100644 --- a/src/algorithms/combinatorial/GRASP/constructor.jl +++ b/src/algorithms/combinatorial/GRASP/constructor.jl @@ -1,5 +1,5 @@ """ - GreedyRandomizedContructor(;candidates, instance, α, rng) + GreedyRandomizedConstructor(;candidates, instance, α, rng) This structure can be used to use the Greedy Randomized Contructor. @@ -20,7 +20,7 @@ end See also [`compute_cost`](@ref) and [`GRASP`](@ref) """ -Base.@kwdef struct GreedyRandomizedContructor +Base.@kwdef struct GreedyRandomizedConstructor candidates instance = nothing α::Float64 = 0.6 @@ -33,7 +33,7 @@ end Compute the cost for each candidate in `candidates`, for given `constructor` and provided `instance`. -See also [`GreedyRandomizedContructor`](@ref) and [`GRASP`](@ref) +See also [`GreedyRandomizedConstructor`](@ref) and [`GRASP`](@ref) """ function compute_cost(candidates, constructor, instance) @warn "Define compute_cost for\nconstructor=$constructor\ninstance=$instance" @@ -45,9 +45,9 @@ end Constructor procedure for GRASP. -See also [`GreedyRandomizedContructor`](@ref), [`compute_cost`](@ref) and [`GRASP`](@ref) +See also [`GreedyRandomizedConstructor`](@ref), [`compute_cost`](@ref) and [`GRASP`](@ref) """ -function construct(constructor::GreedyRandomizedContructor) +function construct(constructor::GreedyRandomizedConstructor) candidates = constructor.candidates |> copy α = constructor.α # create empty solution S diff --git a/src/algorithms/combinatorial/LocalSearch/LocalSearchUtils.jl b/src/algorithms/combinatorial/LocalSearch/LocalSearchUtils.jl index d01610e..80af414 100644 --- a/src/algorithms/combinatorial/LocalSearch/LocalSearchUtils.jl +++ b/src/algorithms/combinatorial/LocalSearch/LocalSearchUtils.jl @@ -1,6 +1,6 @@ abstract type AbstractLocalSearch end -struct BestImprovingSearch <: AbstractLocalSearch end -struct FirstImprovingSearch <: AbstractLocalSearch end +struct BestImproveSearch <: AbstractLocalSearch end +struct FirstImproveSearch <: AbstractLocalSearch end include("neighborhood.jl") @@ -10,7 +10,7 @@ function local_search(x, neighbourhood::Neighborhood, ls::AbstractLocalSearch, p local_search(x, iter, ls, problem) end -function local_search(x, neighbourhood::InternalNeighborhood, ::BestImprovingSearch, problem) +function local_search(x, neighbourhood::InternalNeighborhood, ::BestImproveSearch, problem) best = create_solution(copy(x), problem) for xnew in neighbourhood sol = create_solution(xnew, problem) @@ -21,7 +21,7 @@ function local_search(x, neighbourhood::InternalNeighborhood, ::BestImprovingSea best end -function local_search(x, neighbourhood::InternalNeighborhood, ::FirstImprovingSearch, problem) +function local_search(x, neighbourhood::InternalNeighborhood, ::FirstImproveSearch, problem) initial = create_solution(copy(x), problem) for xnew in neighbourhood sol = create_solution(xnew, problem) diff --git a/src/algorithms/combinatorial/VNS/VND.jl b/src/algorithms/combinatorial/VNS/VND.jl index 726f336..ebb6e1f 100644 --- a/src/algorithms/combinatorial/VNS/VND.jl +++ b/src/algorithms/combinatorial/VNS/VND.jl @@ -16,7 +16,7 @@ Variable Neighborhood Descent. - `initial`: Use this parameter to provide an initial solution (optional). - `neighborhood`: Neighborhood structure. -- `local_search` the local search strategy `BestImprovingSearch()` (default) and `FirstImprovingSearch()`. +- `local_search` the local search strategy `BestImproveSearch()` (default) and `FirstImproveSearch()`. # Example: Knapsack Problem @@ -46,7 +46,7 @@ function main() # list the neighborhood structures neighborhood = [MyKPNeighborhood(1), MyKPNeighborhood(2), MyKPNeighborhood(3)] - local_search = MH.BestImprovingSearch() + local_search = MH.BestImproveSearch() # instantiate VNS vnd = MH.VND(;neighborhood, local_search) @@ -57,7 +57,7 @@ end main() ``` """ -function VND(;initial = nothing, neighborhood = nothing, local_search = BestImprovingSearch(), +function VND(;initial = nothing, neighborhood = nothing, local_search = BestImproveSearch(), options=Options(), information=Information()) parameters = VND(initial, neighborhood, local_search) diff --git a/src/algorithms/combinatorial/VNS/VNS.jl b/src/algorithms/combinatorial/VNS/VNS.jl index 9c8be00..11a5503 100644 --- a/src/algorithms/combinatorial/VNS/VNS.jl +++ b/src/algorithms/combinatorial/VNS/VNS.jl @@ -22,7 +22,7 @@ General Variational Neighborhood Search. - `initial`: Use this parameter to provide an initial solution (optional). - `neighborhood_shaking`: Neighborhood structure for the shaking step. - `neighborhood_local`: Neighborhood structure for the local search. -- `local_search`: the local search strategy `BestImprovingSearch()` (default) and `FirstImprovingSearch()`. +- `local_search`: the local search strategy `BestImproveSearch()` (default) and `FirstImproveSearch()`. - `neighborhood_change`: The procedure for changing among neighborhood structures (default `SequentialChange()`). @@ -62,7 +62,7 @@ function main() # list the neighborhood structures neighborhood_shaking = [MyKPNeighborhood(6), MyKPNeighborhood(5), MyKPNeighborhood(4)] neighborhood_local = [MyKPNeighborhood(3), MyKPNeighborhood(2), MyKPNeighborhood(1)] - local_search = MH.BestImprovingSearch() + local_search = MH.BestImproveSearch() # instantiate VNS vnd = MH.VNS(;neighborhood_shaking, neighborhood_local, local_search, options=MH.Options(verbose=true)) @@ -74,7 +74,7 @@ main() ``` """ function VNS(;initial=nothing,neighborhood_shaking=nothing, neighborhood_local=nothing, - local_search=FirstImprovingSearch(), neighborhood_change=SequentialChange(), + local_search=FirstImproveSearch(), neighborhood_change=SequentialChange(), options=Options(), information=Information()) # TODO diff --git a/test/combinatorial.jl b/test/combinatorial.jl index e8e45fa..a48e6fe 100644 --- a/test/combinatorial.jl +++ b/test/combinatorial.jl @@ -153,7 +153,7 @@ end # list the neighborhood structures neighborhood_shaking = [MyKPNeighborhood(6), MyKPNeighborhood(5), MyKPNeighborhood(4)] neighborhood_local = [MyKPNeighborhood(3), MyKPNeighborhood(2), MyKPNeighborhood(1)] - local_search = Metaheuristics.FirstImprovingSearch() + local_search = Metaheuristics.FirstImproveSearch() # instantiate VNS vnd = Metaheuristics.VNS(;neighborhood_shaking, neighborhood_local, local_search, options) @@ -166,8 +166,8 @@ end ########################################### candidates = rand(search_space) instance = KPInstance(profit, weight, capacity) - constructor = Metaheuristics.GreedyRandomizedContructor(;candidates, instance, α = 0.95) - local_search = Metaheuristics.BestImprovingSearch() + constructor = Metaheuristics.GreedyRandomizedConstructor(;candidates, instance, α = 0.95) + local_search = Metaheuristics.BestImproveSearch() neighborhood = Metaheuristics.TwoOptNeighborhood() grasp = GRASP(;constructor, local_search)