How to include Galapagos in a loop


I am looking for a way to include Galapagos (or any other evolutionary solver) in a loop.

In my script I am trying to approximate nurbs curves by 3 consecutive arcs segments without discontinuity between the arcs (no kinks).
Hereby Galapagos decides where to split the nurbs curves and creates arcs from these segments in order to build a series of arcs that has least deviation from the original nurbs curve.

Unfortunately I have not just one or two curves but like 200. And each curve has very different genes (values for genomes) for the optimal solution. So it’s not possible to run Galapagos once over a list of all curves.
I don’t want to copy my script 200 times into my canvas an run it manually each time.

What I would like to do is to use a loop plugin. In each iteration the programm should pick a different curve and run an individual optimization process (Galapagos) for that curve. What I need is a way to start Galapagos automatically in that loop process (new iteration → pick new curve → expire solution → start Galapagos…sth like this) and stop the optimization process after a certain time (I know roughly how long it takes to find a good solution).

Anybody out there with an idea how to make this work without professional c# skills?


I don’t know about professional but you do need to use C# or Python or VB in order to get this done.

Another thing to consider is…how can you be sure the solution picked by galapagos is correct before moving on to the next curve. Galapagos tends to go to the closest extremum and if that is not the one you are after, all the waiting for these 200 curves might be wasted time.

If you need more help you’ll have to provide more information on the case. A file a screenshot, something.

I think by choosing a good fitness function (with enough fitness pressure) it is possible to get what I want. At least it never happened so far that the solver produced nonsense…but a data record function that saves all approximated curves with the corresponding genes should be implemented in the loop. After iterating over all curves it is easy to find bad ones and have a seperate look at them.

Attachted you find an example file. Here I first ran Galapagos over both curves at once and then over each one seperately. If you compare the genes you can see that treating each curve seperately results in different genes and a better approximation.

I have some very basic knowledge about C# (loops, if-statements,…) but nothing special about RhinoCommon stuff unfortunately :confused:


example (69.1 KB)

Hi! I think i have the same problem as you. Take a look in my question : [Optimization with looping]

I’m working in a project which I have 16 modules ( 4 pavements of 16 modules, as the image bellow) and I need to remove 8 of them. My objective is to remove 8 modules in a way that I have the less perimeter as possible. The problem (that I think can be solved with a loop, I just don’t know how) Is that I only can choose the modules that are in the top. I thought I should use galapagos to choose which module I should remove. But the problem is that the list of modules that I can choose change everytime I remove one. I’ve tested hoopsnake and octopus loop but I couldn’t make it happen.

try using anemone

thanks for the answer!
I’ve tried with anemone but the point is that my galapagos (slider) are inside my looping (anemone). This way, while galapagos run my loop has no trigger to start over again

perhaps rethink the logic. or a different approach, for example, instead of using galapagos, compute, say, 10 permutations, take the one with the smallest perimeter, then run the loop again.