pmedian
PMedianProblemWithDistances
OperationsResearchModels.PMedian.PMedianProblemWithDistances — Type
PMedianProblemWithDistancesFields
distancematrix::Matrix: n x n matrix of distancesncenters::Int: Number of centers
See also PMedianProblemWithCoordinates, solve(::PMedianProblemWithDistances)
PMedianProblemWithCoordinates
OperationsResearchModels.PMedian.PMedianProblemWithCoordinates — Type
PMedianProblemWithCoordinatesFields
coordinates::Matrix: n x d matrix of coordinatesncenters::Int: Number of centers
See also PMedianProblemWithDistances, solve(::PMedianProblemWithCoordinates)
PMedianResult
OperationsResearchModels.PMedian.PMedianResult — Type
PMedianResultFields
centers::Vector: Indices of selected centers.model::JuMP.Model: JuMP model.objective::Float64: Objective value.z::Matrix: Binary matrix of assignments. If z[i, j] = 1 then ith point is connected to the jth point.y::Vector: Binary vector. If y[i] is 1 then ith point is a depot.
See also solve(::PMedianProblemWithDistances), solve(::PMedianProblemWithCoordinates)
The Solver
OperationsResearchModels.solve — Method
solve(p::PMedianProblemWithDistances)Description
The function selects ncenters locations that minimize the total distances to the nearest rows based on the provided distance matrix.
Arguments
p::PMedianProblemWithDistances: PMedian problem with distances.
Output
PMedianResult: PMedianResult object.
OperationsResearchModels.solve — Method
solve(p::PMedianProblemWithCoordinates)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
p::PMedianProblemWithCoordinates: PMedian problem with coordinates.
Output
PMedianResult: PMedianResult object.
Example
data1 = rand(10, 2)
data2 = rand(10, 2) .+ 50
data3 = rand(10, 2) .+ 100
data = vcat(data1, data2, data3)
problem = PMedianProblemWithCoordinates(data, 3)
result = solve(problem)
println(result.centers)
# 3-element Vector{Int64}:
# 1
# 16
# 21
println(result.objective)
# 11.531012240599605