Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some typos #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/algorithms/combinatorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ GRASP
```

```@docs
Metaheuristics.GreedyRandomizedContructor
Metaheuristics.GreedyRandomizedConstructor
```

```@docs
Expand Down
10 changes: 5 additions & 5 deletions src/algorithms/combinatorial/GRASP/GRASP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/algorithms/combinatorial/GRASP/constructor.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
GreedyRandomizedContructor(;candidates, instance, α, rng)
GreedyRandomizedConstructor(;candidates, instance, α, rng)

This structure can be used to use the Greedy Randomized Contructor.

Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/algorithms/combinatorial/LocalSearch/LocalSearchUtils.jl
Original file line number Diff line number Diff line change
@@ -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")

Expand All @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/algorithms/combinatorial/VNS/VND.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/algorithms/combinatorial/VNS/VNS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()`).


Expand Down Expand Up @@ -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))

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/combinatorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
Loading