powered by
Update an existing distance matrix D_mat by adding distances of all previous candidate solutions to one new candidate solution, d_vec= d(x_i,x_new).
D_mat
d_vec= d(x_i,x_new)
distanceMatrixUpdate(distanceMat, x, distanceFunction, ...)
matrix of distances between all solutions x
original distance matrix D_mat
list of candidate solutions, last in list is the new solution
Distance function of type f(x,y)=r, where r is a scalar and x and y are candidate solutions whose distance is evaluated.
further arguments passed to distanceFunction
x <- list(5:1,c(2,4,5,1,3),c(5,4,3,1,2)) dm <- distanceMatrix(x,distancePermutationHamming) x <- append(x,list(1:5)) dmUp <- distanceMatrixUpdate(dm,x,distancePermutationHamming)
Run the code above in your browser using DataLab