Permutations vs Combinations - Grasshopper2024-03-29T10:00:38Zhttps://www.grasshopper3d.com/forum/topics/permutations-vs-combinations?commentId=2985220%3AComment%3A1630496&feed=yes&xn_auth=noAccording to references
Per…tag:www.grasshopper3d.com,2016-11-04:2985220:Comment:16328792016-11-04T03:01:13.432ZMohamed Naeimhttps://www.grasshopper3d.com/profile/MohamedNaeimAbdelgalilIbrahim
<p></p>
<p>According to references</p>
<p></p>
<p>Permutation means arranging members of a set(a,b,c etc) into sequences (i.e. 3 keys each time), that means the order is important(ABC *= CBA).</p>
<p></p>
<p>But Combination means selection of <span style="text-decoration: underline;">unique</span> possible sets in sequences(ABC = CBA), with order ignored.</p>
<p></p>
<p>this why it was possible to extract combinations from permutations without iterations, by only eliminating similar characters…</p>
<p></p>
<p>According to references</p>
<p></p>
<p>Permutation means arranging members of a set(a,b,c etc) into sequences (i.e. 3 keys each time), that means the order is important(ABC *= CBA).</p>
<p></p>
<p>But Combination means selection of <span style="text-decoration: underline;">unique</span> possible sets in sequences(ABC = CBA), with order ignored.</p>
<p></p>
<p>this why it was possible to extract combinations from permutations without iterations, by only eliminating similar characters with matching characters. </p>
<p></p>
<p>That brings the question, whether it's possible to generate the combinations (56) without generating the whole possible (336) permutations, which already took around 8000 iterations</p>
<p></p>
<p></p>
<p></p> Afraid I don't quite follow,…tag:www.grasshopper3d.com,2016-11-03:2985220:Comment:16320942016-11-03T09:52:32.620ZAnders Holden Deleuranhttps://www.grasshopper3d.com/profile/AndersHoldenDeleuran
<p>Afraid I don't quite follow, forgot to add what/where? The <a href="https://docs.python.org/2/library/itertools.html#itertools.combinations" rel="nofollow" target="_blank">combinations</a> function takes an integer as its second argument, that determines how many elements from the input to list to combine. The permutation functions returns all possible <a href="https://docs.python.org/2/library/itertools.html#itertools.permutations" rel="nofollow" target="_blank">permutations</a>. Anywho,…</p>
<p>Afraid I don't quite follow, forgot to add what/where? The <a rel="nofollow" href="https://docs.python.org/2/library/itertools.html#itertools.combinations" target="_blank">combinations</a> function takes an integer as its second argument, that determines how many elements from the input to list to combine. The permutation functions returns all possible <a rel="nofollow" href="https://docs.python.org/2/library/itertools.html#itertools.permutations" target="_blank">permutations</a>. Anywho, it's been awhile since I used these, so might be remembering this wrong.<br/><br/>Edit: Oh wait, got it, you mean I didn't also use the CombinationLength as the second argument when calling the permutations function right? Didn't forget, just implemented the minimal working calls (i.e. permutations does not require a second argument and combinations do). Hope that makes sense :)</p> Update:
This option is super…tag:www.grasshopper3d.com,2016-11-03:2985220:Comment:16317252016-11-03T03:43:23.821ZMohamed Naeimhttps://www.grasshopper3d.com/profile/MohamedNaeimAbdelgalilIbrahim
<p>Update:</p>
<p>This option is super fast (unbelievably fast) just like Python speed, using Anemone (Fast Loop)</p>
<p></p>
<p>Update:</p>
<p>This option is super fast (unbelievably fast) just like Python speed, using Anemone (Fast Loop)</p>
<p></p> found it, I guess Its the com…tag:www.grasshopper3d.com,2016-11-02:2985220:Comment:16312892016-11-02T22:05:48.910ZMohamed Naeimhttps://www.grasshopper3d.com/profile/MohamedNaeimAbdelgalilIbrahim
<p>found it, I guess Its the combination length you forget to add</p>
<p>It works fine now</p>
<p></p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769210367?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769210367?profile=RESIZE_1024x1024" width="721" class="align-full"/></a></p>
<p>found it, I guess Its the combination length you forget to add</p>
<p>It works fine now</p>
<p></p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769210367?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769210367?profile=RESIZE_1024x1024" width="721" class="align-full"/></a></p> Hi again Anders, I tested you…tag:www.grasshopper3d.com,2016-11-02:2985220:Comment:16314702016-11-02T22:01:09.264ZMohamed Naeimhttps://www.grasshopper3d.com/profile/MohamedNaeimAbdelgalilIbrahim
<p>Hi again Anders, I tested your algorithm, </p>
<p>The combination engine looks fine, </p>
<p>But it seems like the permutation engine has got an error</p>
<p>First, it supposes to generate branches of 3 items each time</p>
<p>Second, it's supposed to generate 336 items, not the whole 40k iterations </p>
<p>Am I right? What do you think is the problem?…</p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769210513?profile=original" target="_self"><img class="align-full" src="http://storage.ning.com/topology/rest/1.0/file/get/2769210513?profile=RESIZE_1024x1024" width="721"></img></a></p>
<p>Hi again Anders, I tested your algorithm, </p>
<p>The combination engine looks fine, </p>
<p>But it seems like the permutation engine has got an error</p>
<p>First, it supposes to generate branches of 3 items each time</p>
<p>Second, it's supposed to generate 336 items, not the whole 40k iterations </p>
<p>Am I right? What do you think is the problem?</p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769210513?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769210513?profile=RESIZE_1024x1024" width="721" class="align-full"/></a></p> Hi Anders, thank you for the…tag:www.grasshopper3d.com,2016-11-02:2985220:Comment:16313852016-11-02T21:40:25.023ZMohamed Naeimhttps://www.grasshopper3d.com/profile/MohamedNaeimAbdelgalilIbrahim
<p>Hi Anders, thank you for the contribution, I was really looking for that option (Python) as it is super fast</p>
<p>but with the grasshopper-Anemone option, I can easily implement it within graphical and geometrical iterations easily(as you saw in last option I was able to extract the combination letters)</p>
<p></p>
<p>I just enhanced speed a bit by the Anemone's option (output after the last) in Loop-End</p>
<p>I will be working on developing it further </p>
<p>I am interested in…</p>
<p>Hi Anders, thank you for the contribution, I was really looking for that option (Python) as it is super fast</p>
<p>but with the grasshopper-Anemone option, I can easily implement it within graphical and geometrical iterations easily(as you saw in last option I was able to extract the combination letters)</p>
<p></p>
<p>I just enhanced speed a bit by the Anemone's option (output after the last) in Loop-End</p>
<p>I will be working on developing it further </p>
<p>I am interested in implementing it on graphical and topological iterations now </p>
<p>something like the examples of finding possible plans configurations or finding colour similarities in random coloured panels, etc. </p>
<p></p> Here's a quick example. Notic…tag:www.grasshopper3d.com,2016-11-02:2985220:Comment:16307682016-11-02T12:42:42.403ZAnders Holden Deleuranhttps://www.grasshopper3d.com/profile/AndersHoldenDeleuran
<p>Here's a quick example. Notice how the solve time is super quick, but outputting the results is the actual heavy bit, just FYI.</p>
<p>Here's a quick example. Notice how the solve time is super quick, but outputting the results is the actual heavy bit, just FYI.</p> I've previously used the iter…tag:www.grasshopper3d.com,2016-11-02:2985220:Comment:16310132016-11-02T12:31:31.129ZAnders Holden Deleuranhttps://www.grasshopper3d.com/profile/AndersHoldenDeleuran
<p>I've previously used <a href="https://docs.python.org/2/library/itertools.html" target="_blank">the itertools module</a> in Python for this type of combinatorial generation. It's pretty neat and has both <a href="https://docs.python.org/2/library/itertools.html#itertools.permutations" target="_blank">permutations</a><span>, <a href="https://docs.python.org/2/library/itertools.html#itertools.combinations" target="_blank">combinations</a> and …</span></p>
<p>I've previously used <a href="https://docs.python.org/2/library/itertools.html" target="_blank">the itertools module</a> in Python for this type of combinatorial generation. It's pretty neat and has both <a href="https://docs.python.org/2/library/itertools.html#itertools.permutations" target="_blank">permutations</a><span>, <a href="https://docs.python.org/2/library/itertools.html#itertools.combinations" target="_blank">combinations</a> and <a href="https://docs.python.org/2/library/itertools.html#itertools.combinations_with_replacement" target="_blank">combinations with replacement</a>. Might be helpful if you need to implement such functions in C#/VB.</span></p> successful iteration (enhance…tag:www.grasshopper3d.com,2016-11-02:2985220:Comment:16308682016-11-02T12:20:48.577ZMohamed Naeimhttps://www.grasshopper3d.com/profile/MohamedNaeimAbdelgalilIbrahim
<p>successful iteration (enhanced)</p>
<p>it took 8000 iterations(about 5 min) to find this;</p>
<p></p>
<p>for a pool of 8 characters(a,b,c,d,e,f,g,h), with 3 spaces each time([][][])</p>
<p>336 possible permutations </p>
<p>56 possible combinations</p>
<p></p>
<p>successful iteration (enhanced)</p>
<p>it took 8000 iterations(about 5 min) to find this;</p>
<p></p>
<p>for a pool of 8 characters(a,b,c,d,e,f,g,h), with 3 spaces each time([][][])</p>
<p>336 possible permutations </p>
<p>56 possible combinations</p>
<p></p> i also created the combinatio…tag:www.grasshopper3d.com,2016-11-02:2985220:Comment:16305722016-11-02T04:43:17.739ZMohamed Naeimhttps://www.grasshopper3d.com/profile/MohamedNaeimAbdelgalilIbrahim
<p>i also created the combinations finder</p>
<p>where the order is not important </p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769209849?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769209849?profile=RESIZE_1024x1024" width="721" class="align-full"/></a></p>
<p>i also created the combinations finder</p>
<p>where the order is not important </p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769209849?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769209849?profile=RESIZE_1024x1024" width="721" class="align-full"/></a></p>