Optimizing circle packing based on type-specific distances

Hi!

This is my problem:
There are two types of circles (A and B) generated on a surface. Half of the circles are type A and the other half type B.
- If the same type is near each other (A-A or B-B) → Distance between the two circles is = 7,5
- If different types (A-B) → Distance between the two circles is = 10
The goal is to maximize the number of circles on the surface.
I’ve thought it’s quite simple but somehow cannot manage to solve it. I’ve tried circle packing but it works well for same radius of circles and with this problem i end up in a loop.
I have also tried galapagos and delaunay triangulation to check distances betwen the circles but then I am not sure how to correct the distances (with an attractor or else?).
Please let me know if you have a good idea how to solve this.
I have attached an attempt to solve this in my message.
blue and red packing.gh (21.2 KB)

A screenshot:

It keeps me awake at night… If someone find the answer - thanks!

I don’t thing delaunay edges are the way to go, because the relation between points changes depending on where a point is located over time: given the starting situation you depict, there need to be a number of iterations where the points are being rearranged, pushed away by a different color, and the original edges are not those anymore

I thought a double Kangaroo collider would do the job:
first collider with standard distance (as if they all were of same color)
second overlapped collider ignores all pair of spheres of same color, and just pushes away the ones with different color:

to check if it works, you make the radii very small and increase it slowly:


blue and red packing_inno.gh (21.9 KB)

2 Likes

Thank you so much inno, your definition works well!!

However, my final objective is not only to generate the dots but also to find out what is the optimal configuration and how many of the circles i can maximally pack within the surface.
So, i tried to add a wallacei to the definition. The problem is that the button of the solver needs to be clicked automatically to be able to check the different options. See the updated definition attached:
blue and red packing_md.gh (25.4 KB)

I tried Heteroptera to automatically click the button - but the process crashes with the error Error: “object expired during a solution”

"The problem is that the button of the solver needs to be clicked automatically to be able to check the different options. "

You can use galapagos for that.

1 Like

Wallacei probably has you covered for the “optimal configuration” part but I doubt it can adjust the circle count in the current setup to match your other criterium?
I think this is a project that possibly requires some good old coding. :slight_smile:

1 Like

Hi!
Thanks for the feedback, I have used kangoroo zombie to be able to run the optimisation with galapagos and wallacei. See proposition attached.
The two optimisation processes give some results but are lengthy and not optimal. I find that having multiple goals (1- keeping the circles on the mesh, 2- keeping distances between the dots) make it difficult to get to a “valid” solution because the goals may be conflicting and it pushes away the points from the surface or place the dots too close to each other. I try to play with different strength of the goals, but it is very uneffective since these goals are actually conditions and need to be met…

Do you maybe know a better way to go around this?
blue and red packing_forum.gh (1.5 MB)