Hello Guys,

I’m working on a project where I need to repack a set of randomly generated plots on a given surface while adhering to certain constraints. Specifically, I have the following requirements:

- Input: A general surface (Bloc) and a set of randomly generated plots (polygons) on this surface, where the total area of the plots equals the area of the surface.
- Output: A repacked configuration of the plots on the Bloc, meeting the following criteria:

- Each new repacked plot should have the same area as its corresponding original plot.
- The new plots should be as close as possible to the original plot locations.
- The new plots should have a polygonal shape with the minimum number of edges/vertices possible (favoring simpler shapes).
- All the repacked plots must lie entirely within the boundaries of the original surface.

**Additional Constraints**:

- The edges of the repacked plots should align/connect as much as possible with the edges/boundaries of the original surface.
- If any leftover surface area remains after repacking, it should be minimized and distributed evenly around the perimeter.

My goal is to create a Grasshopper definition that can automate this repacking process by taking the original surface and random plots as inputs and generating an optimized repacked configuration adhering to the mentioned criteria.

I’ve tried using Galapagos for the optimization, but I’m struggling to formulate the appropriate fitness functions and gene representations to handle all the required constraints simultaneously.

I would greatly appreciate any guidance, suggestions, or sample definitions from experienced Grasshopper users on how to approach and solve this multi-objective optimization problem effectively.

I think this should work with a loop definition using anemone or python, but i dont actually know how to implement these with galapagos.

Please let me know if you need any additional details or clarification on the problem statement. Thank you in advance for your help!