# Minimizing the distance between centers of multiple circles

Hello, I am new to optimization and Julia, and I need to minimize the distance between some circles that encircle multiple points in a 2-D plane by moving the centers of the circles. We know where all of the blue spots are, and the circles are all the same size and radius. can somebody help me with this problem?

1 Like

What does this mean? Minimize the average distance between the circle centers? Or minimize the maximum distance? Or …?

Try to write down your minimization problem as equations: minimizing a specific number (the “objective function”) subject to a set of constraints.

1 Like

Thank you for your reply, the goal is to change the center of circles to minimize the sum of the distances between all centers something like this:

model = Model()
variable(model, x[1:n] >= 0); # x coordinate
variable(model, y[1:n] >= 0); # y coordinate
constraint(model, … )
objective(model, Min, sum((x.-x’).^2 .+ (y.-y’).^2))

Isn’t the solution to that problem to set all circle centers to the same point, so that the sum of distances between each pair of centers is zero?

I don’t quite understand this problem. I don’t see what roles the circles or blue dots are playing.

Thank you John for your reply and sorry if the question is not quite clear, the roles are as follows

The position of all blue dots cannot be changed, nor can the number of dots inside each circle, so a circle can move as long as all of its blue dots remain inside it. For example, changing the center position of the red circle towards other circles reduces the sum of distances between all circles.

If you want a point `P1 : [x1, y1]` inside the circle C with center at `[xc, yc]` and radius `rc`. you can formulate it as a NLConstraint in JuMP.

``````@NLConstraint(model, (x1-xc)^2 + (y1-yc)^2 <= rc^2)
``````

Add such constraints for all the points and specify the objective as sum of all pairwise distances.

2 Likes