Combinatorial metaheuristics of Metaheuristics.jl
Source:R/optimization-metaheuristics-exports.R
metaheuristics_combinatorial.RdThe local search methods of Metaheuristics.jl that OptimizationMetaheuristics
exports, ported to R. They search the neighborhoods that the user
defines; in R a neighborhood is a function function(x, i) that returns
the i-th neighbor of x (NULL after the last one) or a random
neighbor when i is NULL, or Metaheuristics$TwoOptNeighborhood().
Usage
GRASP(
initial = NULL,
constructor = NULL,
local_search = .mh_op("BestImproveSearch"),
options = NULL,
information = NULL
)
VND(
initial = NULL,
neighborhood = NULL,
local_search = .mh_op("BestImproveSearch"),
options = NULL,
information = NULL
)
VNS(
initial = NULL,
neighborhood_shaking = NULL,
neighborhood_local = NULL,
local_search = .mh_op("FirstImproveSearch"),
neighborhood_change = .mh_op("SequentialChange"),
options = NULL,
information = NULL
)Arguments
- initial
The starting point (random in the bounds when
NULL).- constructor
The randomized greedy constructor of GRASP.
- local_search
Metaheuristics$BestImproveSearch()orMetaheuristics$FirstImproveSearch()(for GRASP with aneighborhood), or for GRASP a function of a point that returns the improved point.- options, information
As for metaheuristics_single.
- neighborhood
A list of neighborhoods of VND.
- neighborhood_shaking, neighborhood_local
Lists of neighborhoods of VNS.
- neighborhood_change
Metaheuristics$SequentialChange()orMetaheuristics$CyclicChange().
Value
An algorithm object for solve().
Details
GRASP(): greedy randomized adaptive search: each iteration builds a point withconstructor(a function of no arguments, orMetaheuristics$GreedyRandomizedConstructor()) and improves it withlocal_search.VND(): variable neighborhood descent over the listneighborhood.VNS(): variable neighborhood search: shaking inneighborhood_shaking, then a VND overneighborhood_local.
Examples
f <- function(x, p) sum((x - c(0.3, 0.7))^2)
step <- function(x, i) {
if (is.null(i)) i <- sample.int(4, 1)
if (i > 4) return(NULL)
x[(i + 1) %/% 2] <- x[(i + 1) %/% 2] + c(-0.1, 0.1)[(i - 1) %% 2 + 1]
x
}
prob <- OptimizationProblem(f, c(0, 0), lb = c(-1, -1), ub = c(1, 1))
sol <- solve(prob, VND(initial = c(0, 0), neighborhood = list(step)))
sol$u
#> [1] 0.3 0.7