Grasshopper

algorithmic modeling for Rhino

# The best way to find a combination of input

Hi everyone, I'd need your help for a combination issue that I would solve inside grasshopper (if possible). Maybe there's a plugin that makes this task easier...or maybe not.

*short version*

starting from a list of 12 items I would find all the combinations taking just 4 at time.

I'd use a Stream gate that takes the indexes of the items and pass them to a list item in order to select just the items of the combination. Doing so I can choose a single combination of index at time to pass to the list item.

In this moment all the data come out from the first gate, all the others are empty.

If I pass these index to the list item it gives me an error (probably because of the data structure).

*long version*

I start from a list of 12 segments, all of them with the starting point in common and the ending point distributed regularly in the space. It's a quite simple starting point.

What I'm trying to achieve is to find all the possible spatial configurations made of 2, 3, 4 segments. I started with 2 segments so I've 12^2=144 possible configurations but just 4 different configurations that can intuitivelly be recognized (60°, 90°, 120°, 180°).

Doing the same with 3 segments generates 12^3=1728 configurations and I don't know how many different ones. With 4 segments I've got 12^4=20736 possible configurations.

As you can imagine many configurations are identical but just with a different orientation so at the end I'll have to parse geometrically the output to delete duplicates (I'll address this later on).

Please could you help me to figure out how to mix these segments in different configurations?

Views: 408

Attachments:

### Replies to This Discussion

Thank you for your explanation, it's quite clear but there are a few things that I still don't grasp.

The difference between combination and permutation relies on the order of the samples: combination doesn't consider the order of the samples but permutation does. That said once I pick a combination with the path_index slider it shouldn't change moving the permutation slider...but it changes instead. On what does it depend?

Because of the central symmetry of the structure even after filtering duplicates in the same position we still have duplicates in different positions. Try to think about the possible configuration with all the segments coplanar.

We can have different permutations on the same combination (changes just the order of the same samples) or different combinations (so different samples) that makes the same geometric configuration, for example another coplanar configuration (no matter what order it takes the segments) but rotated in the space (so it takes other segments of course).

Maybe solving this broader order of geometric identity will help us to get rid of permutations too.

I was thinking about the area given by the ending points because it's analogue to the middle point but it can be oriented, but I'm quite sure there are better solutions to do so.

That said I'm trying to "print" all the combinations/permutations using Anemone to iterate through the index but the cluster seems not likes recursive data and I don't know why.

1. Cyclical data stream detected, parameter Branch is recursive.

Anyone knows a better way to cycle a slider and bake every output in different positions? I'm quite sure I'm doing it the hard (dumb) way.

Thanks for all the support received.

Attachments:

once I pick a combination with the path_index slider it shouldn't change moving the permutation slider...but it changes instead. On what does it depend?

It does behave that way when 'path_index' (renamed as 'Combination') is set to zero or 1.  I spent some time trying to make that work for all combinations but decided I had better things to do.  I'm done with this one, have fun.

Editing my last post:

We can have different permutations on the same combination (changes just the order of the same samples) or different combinations (so different samples) that makes the same geometric configuration, for example another coplanar configuration (no matter what order it takes the segments) but rotated in the space (so it takes other segments of course).

Simple stated, among all the possible combinations there are identical shapes, both coincident or not. In any case all the combinations shares the central point. I'm aiming to obtain a list of different shapes (actually a sort of pipe joints to 3d print).

When I've red my own words I've realized that the concept can be stated in a more simple way.

I've tried to move on to produce the different shapes to compare, so I've played around a little bit with the definition.

I've used Anemone with two data strams, one for the geometries so every istance can be visualized properly and not overlapped, and one for the index to cycle through the slider that sets the path_index input of the cluster adding 0.001 for each cycle.

I must admit that I'm not expert with data trees and branches so I barely understand what goes on in the cluster; intuitively I'd connect the index counter to the path_index input but it doesn't work.

Another thing I've noticed is that nothing comes out from the D1 data strem while I'd expect a series of crescent values. Maybe I could try a sort of hard coding with a grafted series from 0 to 1 with 0.001 steps.

Attached you can find the last version.
Thank you in advance for the support.

Attachments:

Remember the accidental discovery earlier of only 133 "unique ID" results?  That lead to the "sequence of lengths" variant that yielded 495 unique IDs (combinations).  Would be amusing if those 133 combinations are significant somehow, after all?  Like regardless of their orientation?  I dunno...  This code has a switch to use either assumption:

Attachments:

A slight code simplification, removing a column of four 'List Item' components:

Attachments:

Cosmetic "re-factor" - rearranging components for legibility and comprehension:

Attachments:

Simplified further - same result:

Attachments:

Again, same code, simplified and clarified:

Attachments:

• View All