Grasshopper

algorithmic modeling for Rhino

# Optimization with a Loop

Hi. 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.

Any ideas?

Views: 382

### Replies to This Discussion

This is the example below

Attachments:

This looks like something Topologic can easily solve. If I understood correctly you want to know which "cubes" don't have anything on top, so another approach would be to model each of the stacks as lists of objects. The repeated operation would be to "pop" or remove the last box in the list.

HI Filipe! Yes, the process is something like that: First of all I verify which of the cubes has nothing on the top. Then I have something like 8 cubes that can be removed. Galapagos choose one. Then we back to the begging and verify again which are the new cubes that can be removed and galapagos choose one again. We repeat that process until we have removed 8 modules and have the less perimeter as possible.

I already did all the algorithm (verify, choose one of them, remove...) but my point is that I couldn't understand how can I put galapagos (or other solver) inside a loop.

See the attachment below and you may understand it better

Attachments:

The short answer is: you can't! Galapagos only works from its interface (unless you want to dive into coding, but then you don't need Hoopsnake). You either use Galapagos to cycle through some values or you use Hoopsnake to loop (a while or for loop) and compute your objective function to select the one that minimizes.

I don't understand your objective function. What do you mean by perimeter? You are working with volumes, do you mean perimetral or surface area? If it is perimetral area you don't need to do any optimization because the solution with least area is the one that keeps the volume compact, i.e, closest to a cube. Any other solution will increase the surface area of the volume, think fractals...

• View All