Every Possible Combination of Indices - Grasshopper2024-03-29T13:36:04Zhttps://www.grasshopper3d.com/forum/topics/every-possible-combination-of-indices?commentId=2985220%3AComment%3A1657321&feed=yes&xn_auth=noYou can say I have all variat…tag:www.grasshopper3d.com,2016-12-14:2985220:Comment:16577352016-12-14T14:47:29.378ZMohamed Naeimhttps://www.grasshopper3d.com/profile/MohamedNaeimAbdelgalilIbrahim
<p>You can say I have all variations of (a,b,c) like a, ab, abc</p>
<p></p>
<p>but I guess when you use the word combination you say all possible unique combinations in two places ([][])out of 3 elements (a,b,c)</p>
<p>(ab = ba)</p>
<p></p>
<p>but for permutations, you say all possible permutations for two places ([][]) from a pool of 3 elements (a,b,c)</p>
<p>(ab != ba)</p>
<p>You can say I have all variations of (a,b,c) like a, ab, abc</p>
<p></p>
<p>but I guess when you use the word combination you say all possible unique combinations in two places ([][])out of 3 elements (a,b,c)</p>
<p>(ab = ba)</p>
<p></p>
<p>but for permutations, you say all possible permutations for two places ([][]) from a pool of 3 elements (a,b,c)</p>
<p>(ab != ba)</p> There is also something calle…tag:www.grasshopper3d.com,2016-12-14:2985220:Comment:16578142016-12-14T12:36:03.930ZMohamed Naeimhttps://www.grasshopper3d.com/profile/MohamedNaeimAbdelgalilIbrahim
<p>There is also something called Variation</p>
<p>repeating elements the same length as the places like this (c,c,c,b,b,b,c,c,c) give as result like (cat, cat, cat) or zero as an option</p>
<p>adding empty value to variations elements (" ", "a", "b", "c") give us values like (cat) or (cat, cat)</p>
<p>There is also something called Variation</p>
<p>repeating elements the same length as the places like this (c,c,c,b,b,b,c,c,c) give as result like (cat, cat, cat) or zero as an option</p>
<p>adding empty value to variations elements (" ", "a", "b", "c") give us values like (cat) or (cat, cat)</p> A simple/terse solution to th…tag:www.grasshopper3d.com,2016-12-14:2985220:Comment:16576542016-12-14T12:31:31.798ZAnders Holden Deleuranhttps://www.grasshopper3d.com/profile/AndersHoldenDeleuran
<p>A simple/terse solution to this class of problem, might be to use the permutations function found in the standard <a href="https://docs.python.org/2/library/itertools.html" target="_blank">itertools module</a> in Python. Note that it might not scale super well with large input sets, due to <a href="http://www.grasshopper3d.com/forum/topics/ghpython-some-bottlenecks-bugs" target="_blank">the cost of outputting large amount of data</a> from the GHPython component. Attached this…</p>
<p>A simple/terse solution to this class of problem, might be to use the permutations function found in the standard <a href="https://docs.python.org/2/library/itertools.html" target="_blank">itertools module</a> in Python. Note that it might not scale super well with large input sets, due to <a href="http://www.grasshopper3d.com/forum/topics/ghpython-some-bottlenecks-bugs" target="_blank">the cost of outputting large amount of data</a> from the GHPython component. Attached this example: <br/><br/><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769224676?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769224676?profile=RESIZE_1024x1024" width="721" class="align-full"/></a><br/>Edit: Mohamed beat me to it :)<br/><br/></p> http://www.grasshopper3d.com/…tag:www.grasshopper3d.com,2016-12-14:2985220:Comment:16575562016-12-14T12:23:47.651ZMohamed Naeimhttps://www.grasshopper3d.com/profile/MohamedNaeimAbdelgalilIbrahim
<p style="text-align: left;"><a href="http://www.grasshopper3d.com/forum/topics/permutations-vs-combinations" rel="nofollow" target="_blank">http://www.grasshopper3d.com/forum/topics/permutations-vs-combinations</a></p>
<p style="text-align: left;"></p>
<p style="text-align: left;">my 5th virsion (latest post) is the fastest as it uses anemone fast loop </p>
<p style="text-align: left;">but Anders version with python is very good</p>
<p style="text-align: left;">but its good example because in…</p>
<p style="text-align: left;"><a rel="nofollow" href="http://www.grasshopper3d.com/forum/topics/permutations-vs-combinations" target="_blank">http://www.grasshopper3d.com/forum/topics/permutations-vs-combinations</a></p>
<p style="text-align: left;"></p>
<p style="text-align: left;">my 5th virsion (latest post) is the fastest as it uses anemone fast loop </p>
<p style="text-align: left;">but Anders version with python is very good</p>
<p style="text-align: left;">but its good example because in the beginning it also show you how many possible permutations/combinations even for higher values without producing the results</p> Maybe this then?
tag:www.grasshopper3d.com,2016-12-14:2985220:Comment:16575152016-12-14T08:05:51.887Zpeter fotiadishttps://www.grasshopper3d.com/profile/peterfotiadis
<p>Maybe this then?</p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769225627?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769225627?profile=RESIZE_1024x1024" class="align-full" width="721"/></a></p>
<p>Maybe this then?</p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769225627?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769225627?profile=RESIZE_1024x1024" class="align-full" width="721"/></a></p> The basic idea is that you st…tag:www.grasshopper3d.com,2016-12-13:2985220:Comment:16571662016-12-13T23:05:49.626ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>The basic idea is that you start with a complete pattern containing all elements, then you recursively remove elements from that pattern, generating all the patterns that are one item shorter. Then you recursively remove individual elements from this new list of shorter patterns to create shorter patterns still. Repeat until the pattern length drops below 1.</p>
<p></p>
<p>The problem is that if you first remove 'B' from 'A,B,C,D' and then remove 'D', you end up with the same pattern as when…</p>
<p>The basic idea is that you start with a complete pattern containing all elements, then you recursively remove elements from that pattern, generating all the patterns that are one item shorter. Then you recursively remove individual elements from this new list of shorter patterns to create shorter patterns still. Repeat until the pattern length drops below 1.</p>
<p></p>
<p>The problem is that if you first remove 'B' from 'A,B,C,D' and then remove 'D', you end up with the same pattern as when you first remove 'D' and then 'B'. So these cases need to be tested. I'm sure there's some clever looping that just does the right thing, but I couldn't think of it.</p> It is fun thinking about this…tag:www.grasshopper3d.com,2016-12-13:2985220:Comment:16572852016-12-13T23:02:13.695ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>It is fun thinking about this. I came up with an algorithm which is reasonably efficient, though not particularly elegant. It sometimes generates duplicate entries so it must deal with those which costs additional processor cycles.</p>
<p></p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769225402?profile=original" target="_self"><img class="align-center" src="http://storage.ning.com/topology/rest/1.0/file/get/2769225402?profile=RESIZE_1024x1024" width="500"></img></a></p>
<p></p>
<p>It generates an index map which can then be used to retrieve the actual items. Code is heavily annotated, but…</p>
<p>It is fun thinking about this. I came up with an algorithm which is reasonably efficient, though not particularly elegant. It sometimes generates duplicate entries so it must deal with those which costs additional processor cycles.</p>
<p></p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769225402?profile=original" target="_self"><img width="500" src="http://storage.ning.com/topology/rest/1.0/file/get/2769225402?profile=RESIZE_1024x1024" width="500" class="align-center"/></a></p>
<p></p>
<p>It generates an index map which can then be used to retrieve the actual items. Code is heavily annotated, but pretty thorny nonetheless.</p> Yup, it blows up pretty damn…tag:www.grasshopper3d.com,2016-12-13:2985220:Comment:16573532016-12-13T22:18:10.378ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>Yup, it blows up pretty damn quick.</p>
<p>Yup, it blows up pretty damn quick.</p> Thanks Peter this definitely…tag:www.grasshopper3d.com,2016-12-13:2985220:Comment:16574422016-12-13T22:00:05.601ZRyan Whitbyhttps://www.grasshopper3d.com/profile/RyanWhitby
<p>Thanks Peter this definitely works except for one minor thing. In my specific case order does not matter. It seems your script has the added bonus of finding the permutations when order does matter which, in my case, results in duplicate branches.</p>
<p>Thanks Peter this definitely works except for one minor thing. In my specific case order does not matter. It seems your script has the added bonus of finding the permutations when order does matter which, in my case, results in duplicate branches.</p> Yes I can see now how this ca…tag:www.grasshopper3d.com,2016-12-13:2985220:Comment:16574412016-12-13T21:58:00.050ZRyan Whitbyhttps://www.grasshopper3d.com/profile/RyanWhitby
<p>Yes I can see now how this can be a inefficient way to solve this problem. It seems like when dealing with 12 source words the number of possible permutations is too high for grasshopper to handle.</p>
<p>Yes I can see now how this can be a inefficient way to solve this problem. It seems like when dealing with 12 source words the number of possible permutations is too high for grasshopper to handle.</p>