mtsp_ga: Runs the MTSP solver

Description Usage Arguments Value Examples

View source: R/RcppExports.R

Description

Runs the MTSP solver

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
mtsp_ga(
  xy,
  dmat,
  nSalesmen,
  minTour,
  CostType,
  popSize,
  numIter,
  Epsilon = 1e-10,
  return_all = FALSE
)

Arguments

xy

A n by 2 matrix of coordinate positions. Each row has the x and y position of the n sites to be visited.

dmat

A n by n matrix with the distances between the positions xy.

nSalesmen

An integer giving the number of salespersons (must be >= 2).

minTour

An integer giving the minimum tour length for any of the salesmen.

CostType

Possible values are the integers 1 or 2; 1 minimises the total distance travelled and 2 minimises the maximum distance travelled across the salepersons.

popSize

The population size / search space of the GA (should be divisible by 8 but this is corrected within program).

numIter

is the desired number of iterations for the algorithm to run.

Epsilon

A double giving a multiplier on blancing the costs beteen total distance and minmax (only used for costType 2).

return_all

Logical on whether ro return full ouput. Defaults to FALSE.

Value

Returns the solution to the MTSP. Depending on return_all may return the inputs and best_tour: returns a list where each element gives the sites visited by each salesperson, minDist: is the best cost found by the algorithm, minDistTotal gives tht total distance travelled for all salespersons, and minMaxTotal gives the maximum distance travelled by any one salesperson.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
set.seed(1)
n = 25
nSalesmen = 5
xy = matrix(rnorm(n*2), ncol=2)
dmat = as.matrix(dist(xy))
minTour = 3
numIter = 10
popSize = 8
CostType = 2
res = mtsp_ga(xy, dmat, nSalesmen, minTour, CostType, popSize, numIter, return_all = TRUE)

daffp/mtsp documentation built on Sept. 23, 2020, 2:39 p.m.