1

Trying to form an LP-based clustering problem in R with binary variables.

sample dataset:

set.seed(123)
id<- seq(1:50)
lon <- rnorm(50, 88.5, 0.125)
lat <- rnorm(50, 22.4, 0.15)
demand <- round(runif(50, min=20, max=40))

df<- data.frame(id, lon, lat, demand)

The problem statement: The problem

Where yij takes binary values. (It is 1 if i belong to cluster j, 0 otherwise) ai is the position of individual points. x¯j is the centroid of the clusters. Qj is the maximum load of cluster j and qi is the demand of each point.

I have used lpSolve in R for optimization problems but I can't find a way to model this problem. Especially the main issue is x¯j. How to incorporate a variable such as that in the objective function?

Shibaprasadb
  • 1,307
  • 1
  • 7
  • 22
  • 1
    lpSolve is for linear problems only. Your formulation is nonlinear. The problem can be reformulated as a convex MIQP (solvers -- other than lpSolve -- are available for this problem class). Clustering using medoids can be formulated as a linear MIP. See http://yetanothermathprogrammingconsultant.blogspot.com/2021/05/clustering-models.html. – Erwin Kalvelagen May 31 '21 at 19:36

0 Answers0