Learn R Programming

CEGO (version 2.4.3)

optim2Opt: Two-Opt

Description

Implementation of a Two-Opt local search.

Usage

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

Value

a list with:

xbest

best solution found

ybest

fitness of the best solution

count

number of performed target function evaluations

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

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

Run this code
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

Run the code above in your browser using DataLab