I have been spinning my wheels for a little more than I was hopping. My goal is to find a group of rectangles where the area is equal or bigger than a given area. The goal is to generate a list of rectangles.
For instance given an area of 20 in2
Some rectangles that satisfy this problem:
2 in x 10 in
4 in x 5 in
3 in x 7 in
3 in x 8 in
…
The list can go on. Ideally I would set up a maximum limit where the new area can exceed. Lets say no more that a 20% of increase of the original area.
Any advice how can approach the problem? Please if anyone can point me in the right direction on how to start it will be awesome.
Hello
it seems to be basic Math, if I understand you want integer data
so let say
Surface * 0.8 < Width *Length < Surface * 1.2
Min Width = 1
Min Length = 1
Max Length = Math.Floor (Surface *1.2)
so generate all width/length pair from 1 to Math.Floor (Surface *1.2) and calculate the area and keep the value that meets your criteria.
Hi @laurent_delrieu , thanks for your reply. In this case the math part is not the problem. I am looking for a way to get a list of rectangles in Grasshopper that meet the area criteria. I was looking for a way to use Galapagos or Kangaroo. In my script below I show a small minimization that partially solves the problem. I get the minimum x and y that approximates the area but I am also interested in the other possible solutions. I think this is more like a design space exploration problem. Rectangle Options.gh (7.5 KB)
BTW: That has nothing to do with Kangaroo/Galapagos: it’s an elementary soft Clustering task (soft means that an item may belong to more than one Cluster).
Let’s say that you have the numbers on the blue list (i.e. the demo). You want to find all Clusters where the sum of numbers is within a given search Interval (minSum, naxSum) - min may equal to max. The unique bool shown below just finds all nums NOT in any Cluster):
So … for your case one needs simply a Class that “relates” Rectangles to Areas (or 3d Items [Breps/Meshes] to Volumes) and solve dealing with Areas. Obviously any post solution “further filtering” imaginable … is very easily achievable.
Notify if you need an indicative C# (useless/a black box to you if you are not familiar with coding)
(*) in fact Permutations.
Warning: This is a nasty thing: see the upper limit with regard the N of Permutations:
OK I’ll modify the above maybe tomorrow (define a Class, Cluster by the suitabe Property [a double for the Area] etc) since I have ready only classic stuff related with numbers.
Or you want the above as it is in order to do the mods yourself? (would be a nice little challenge for the brave).
BTW: O [2^N] Permutations (where N is the amount of items/numbers [areas]) means that you’ll - in 99.9999 % of cases - end up with lot’s of combos. Meaning: MANY branches (i.e. valid solutions) containing the indices of the Clustered items. For more, say, than 20 items … well … see line 17 above.
BTW: You’ll need a Class because you may have Curves (in general) with the same Area (within some rational tol). In this case … obviously just a Clustered number means rather nothing.