Hello everyone. I am fairly new to GH and I am trying to figure out a way of automatically populating a parametric roof I created with PV panels.
I have more or less the idea of what I have to do, but not the knowledge of how to implement it. So I have a roof (surface) with some kind of obstacle (any geometry I add on the surface - HVAC or exhausters) and what I would like to happen is that the script automatically creates the biggest rectangle possible on the roof avoiding the obstacle(s), and within that rectangle, add the maximum number of smaller geometries representing the PV panels.

That’s more or less a diagram of what I would like to happen:

The Galapagos evolutionary solver that comes with Grasshopper can for instance be used to optimize stuff like this. What you should know though is that with an evolutionary approach like this the optimal solution is never guaranteed, much like in nature.

In my example definition, I simply maximize the PV-panel area, while penalizing it going over the roof border and it colliding with the exhaust and/or HVAC unit.

Maximizing happens from 0 to 1, where 1 is the maximum or optimum fitness value.
The area of the PV-array thus gets remapped between 0 and 1.
The collision and inclusion values are either 0 or 1.
These three values are divided by 3, because all three values are weighted equally (different weights could also be possible), and added together to form a fitness value between 0 to 1.0 that Galapagos maximizes towards.

The Galapagos solver is the pink component with the googly eyes icon. A dialogue should open when double-clicking it, in which you can start a simulation.

That is exactly what I was looking for. Thank you so much for taking your time to write this script.
I’m quite familiar with Galapagos because of energy loads/daylighting optimization scripts but I didn’t think about utilizing it for this kind of task.