Using CurveCollide with Galapagos

Hi all,

I’m trying to use the goal CurveCollide in conjunction with Galapagos. To be more specific, I have multiple curves (circles and rectangles (polylines) with a center point) on a plane and I want to minimize the distance of certain pairs of center points without any overlap between the curves.

To better illustrate the problem, I have attached a file which is split into two parts. The first is labeled “Kangaroo Solver and Grab”. Any of the curves can be grabbed and moved around. I use the output of the Kangaroo Solver to get the center points of all the curves, create lines between the ones I’m interested in and calculate the total length. I want to use this value as the fitness parameter for Galapagos.

The second part is labelled “Kangaroo Zombie Solver and Galapagos”. It consists of the same curves (two circles and two rectangles). The genes are the X and Y coordinates of the center points and additionally the rectangles can also be rotated. The idea is that the curves, which are created based on the genes, are altered using CurveCollide so there is no overlap between them and using the altered curves to calculate the fitness parameter as described above.

Unfortunately, the implementation of Kangaroo doesn’t work as intended and a lot of the solutions are still infeasible, i.e. the curves overlap. Furthermore, I was struggling to obtain the output curves which are being used to calculate the fitness parameter. I ended up putting together a C# component based on the CustomIteration file on Daniel Piker’s GitHub repository.

The main question for me is, if the approach using Kangaroo can even work and if so, how? I also tried penalizing the fitness parameter if there is any overlap. This worked to some extent but created a lot of infeasible solutions. (35.7 KB)

Hi @haoliver

Just looking at the Kangaroo part - here’s an example showing how you can get the transformed output curves: (7.8 KB)

1 Like

Hi @DanielPiker

Thanks a lot for the fast response! Now it almost works as I intended. The only issue is that there are gaps between some of the curves which were overlapping before. Is that because of the order in which the curves are received by the solver? To better understand what I mean I indicated the gaps in the file you sent with yellow arrows and the area with no gap in green.

CurveCollide stops curves from overlapping by pushing them apart.
This is not the same thing as making them touch.
A bit more context on what you are trying to do would probably help here.

Here a couple of ways for if you want to actually make the curves touch, instead of just preventing overlaps.
One is to include an attraction between all the curve centres: (9.5 KB)

Another is to use a custom goal which attracts closest pairs of points between all curves: (14.4 KB)
For most shapes I think with more than 3 it will usually be impossible to have them all touching every other curve in the set, and trying to make them could cause some strange behaviour.

Thanks again for the many inputs! I’m trying to minimize the distance between certain pairs of center points of the curves. The ones I’m looking for are connected with a line. I adapted the file I uploaded originally with your first input of how to extract the curves from the Zombie solver and grabbed some screenshots of that to hopefully better explain my problem.

Picture 1) shows the configuration at the start. Then the top, left rectangle is moved in -Y direction. Picture 2) shows the curves touching for the first time. Picture 3) shows the configuration after further movement in -Y direction with the gap indicated with a yellow arrow. Picture 4) shows the configuration I was expecting (red rectangle). Meaning that the two curves stay in contact during this movement, similar to when I’m using grab and the normal solver. (28.5 KB)