pmedian

OperationsResearchModels.PMedian.pmedianFunction
pmedian(data, ncenters)

Description

The function calculates Euclidean distances between all possible rows of the matrix data. ncenters locations are then selected that minimizes the total distances to the nearest rows.

Arguments

  • data::Matrix: Coordinates of locations
  • ncenters::Int: Number of centers

Output

  • PMedianResult: PMedianResult object.

Example

data1 = rand(10, 2)

data2 = rand(10, 2) .+ 50

data3 = rand(10, 2) .+ 100

data = vcat(data1, data2, data3)

result = pmedian(data, 3);

println(result.centers)
# 3-element Vector{Int64}:
#  1
# 16
# 21

println(result.objective)
# 11.531012240599605
source

pmedian with distances

OperationsResearchModels.PMedian.pmedian_with_distancesFunction
pmedian_with_distances(distancematrix, ncenters)

Description

ncenters locations are selected that minimizes the total distances to the nearest rows.

Arguments

  • distancematrix::Matrix: n x n matrix of distances
  • ncenters::Int: Number of centers

Output

  • PMedianResult: PMedianResult object.
source