Create component like Galapagos using Python

Hello :grinning:,

I would like to create a component like Galapagos using python. The idea is to create component to be able realize specific optimization. I’m not interested in the GUI part of Galapagos when you double-click. However, I’m more than interested to learn how to modify sliders and I’d like to be able to create genome and fitness input just like Galapagos :smiley:.

Unfortunately, I don’t have any clue on how to do such thing. I was wondering if anyone had an idea on how to realize this ?

Thank you in advance.

This is a good place to start:

Edit: And here’s an example of how to get/set genepool values:


Hi @alexandre.flamant,

I wouldn’t think of it as replicating Galapagos in GHPython, but rather look into how to code genetic algorithms and evolutionary solvers. The principals of the algorithm might stay the same or at least remain similar for many tasks, but in my opinion it’s better to integrate and customise it for each individual task.

Here’s a Python example I did a while back for finding optimised solutions to the travelling salesman problem with an evolutionary approach.
It’s not perfect, but it shows at least two things:

  1. How to structure/set up an animated GHPython component (which by the way I learned from Anders)
  2. How to structure/set up the algorithm (populations, fitness, mutations, etc.)

Thank you @AndersDeleuran. These are really good examples :smiley: ! I now see how to interact with sliders and other input sources. It’s actually easy, but I feel that finding the way to the information through the API can be sometimes quite laborious. :smile:

Hello @diff-arch,
You’re right, I may have misspoke. I use the comparison to Galapagos because the way it works is well known. I’m planning to create several components for specific optimization operation on structural design. But I didn’t know how to interact with the sliders used to make the structure vary.
That being said, thank you for sharing your work. It really is pedagogic.

Now, I’d like to look into the subject of graphics. Do you guys have an idea an how to change component color and how to create this bottom input position ?

No idea, but my guess would be that you can’t change the colour of the GHPython component, because it would change the colour for all GHPython components.
@DavidRutten might be able to answer these questions for you!

Probably not a problem as I will compile theses components :grin: !