optim2Opt: Two-Opt

Description Usage Arguments Value References See Also Examples

View source: R/optim2opt.R

Description

Implementation of a Two-Opt local search.

Usage

1
optim2Opt(x = NULL, fun, control = list())

Arguments

x

start solution of the local search

fun

function that determines cost or length of a route/permutation

control

(list), with the options:

archive

Whether to keep all candidate solutions and their fitness in an archive (TRUE) or not (FALSE). Default is TRUE.

budget

The limit on number of target function evaluations (stopping criterion) (default: 100)

creationFunction

Function to create individuals/solutions in search space. Default is a function that creates random permutations of length 6

vectorized

Boolean. Defines whether target function is vectorized (takes a list of solutions as argument) or not (takes single solution as argument). Default: FALSE

Value

a list with:

xbest

best solution found

ybest

fitness of the best solution

count

number of performed target function evaluations

References

Wikipedia contributors. "2-opt." Wikipedia, The Free Encyclopedia. Wikipedia, The Free Encyclopedia, 13 Jun. 2014. Web. 21 Oct. 2014.

See Also

optimCEGO, optimEA, optimRS, optimMaxMinDist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
seed=0
#distance
dF <- distancePermutationHamming
#creation
cF <- function()sample(5)
#objective function
lF <- landscapeGeneratorUNI(1:5,dF)
#start optimization
set.seed(seed)
res <- optim2Opt(,lF,list(creationFunction=cF,budget=100,
   vectorized=TRUE)) ##target function is "vectorized", expects list of solutions as input
res

CEGO documentation built on May 14, 2021, 1:08 a.m.