I have an optimization problem with the dat frame as below:
Loc Lattitude Longtitude Car Distance
1 34.30 -36.30 A 23
2 36.06 -67.32 B 32
3 41.35 -22.04 C 12
4 30.49 -14.25 A 41
5 42.60 -36.60 C 11
The Car column is the variable I try to optimize - each location is assigned with a car, the objective is to minimize the total number of cars, i.e. the unique value of the Car variable.
The constraint is that the max value in the Distance column has to be <=40. The values in the distance column is the distance from the corresponding location to the centroid point of all the locations assigned with the same car. To simplify the code:
df['Distance'] = df.groupby('Car').centroid_distance(['Lattitude','Longtitude'])
How can I do the optimization with cvxopt or cxvpy, please? All I could find from online are simple/linear functions of variable x. I cannot figure how to optimize a variable that involves group by function. I tried to assign the variable(x) as a column of the data frame but it doesn't work.