Learn R Programming

CEGO (version 2.0.0)

optim2Opt: Two-Opt

Description

Implementation of a Two-Opt local search.

Usage

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 budget The limit on number of target function evaluations (stopping criterion) (default: 100) vectorized Boolean. Defines whether target function is vectorized (takes a list of solutions as argument) or

Value

  • a list: 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. (http://en.wikipedia.org/wiki/2-opt)

Examples

Run this code
seed=0
glgseed=1
#distance
dF <- distancePermutationHamming
#mutation
mF <- mutationPermutationSwap
#recombination
rF <-  recombinationPermutationCycleCrossover
#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