Grasshopper

algorithmic modeling for Rhino

These two algorithms is a trial to create a system for permutations and combinations 

it depends on a mathematical operation called factorial 

I wish if David can add the operation to the expression editor 

N! = 5! = 5 * 4 * 3 * 2 * 1

credit to this video series

https://www.youtube.com/watch?v=hJRXKq2GEo8&index=5&list=LL...

It helps find how many variations you can generate per group from a pool of selectable items. 

I had my own version also 

Views: 4491

Attachments:

Replies to This Discussion

Version 02 

In case N = n

Attachments:

Mathematical Permutation 

This is my own version

It's an implementation with letters or numbers

Surprisingly its very accurate

Credit to a previous post by David Rutten 

Attached

Implementation with letters for Permutations Only 

Attachments:

i also created the combinations finder

where the order is not important 

Attachments:

successful iteration (enhanced)

it took 8000 iterations(about 5 min)  to find this;

for a pool of 8 characters(a,b,c,d,e,f,g,h), with 3 spaces each time([][][])

336 possible permutations 

56 possible combinations

I've previously used the itertools module in Python for this type of combinatorial generation. It's pretty neat and has both permutationscombinations and combinations with replacement. Might be helpful if you need to implement such functions in C#/VB.

Here's a quick example. Notice how the solve time is super quick, but outputting the results is the actual heavy bit, just FYI.

Attachments:

Hi Anders, thank you for the contribution, I was really looking for that option (Python) as it is super fast

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)

I just enhanced speed a bit by the Anemone's option (output after the last) in Loop-End

I will be working on developing it further 

I am interested in implementing it on graphical and topological iterations now 

something like the examples of finding possible plans configurations or finding colour similarities in random coloured panels, etc. 

Hi again Anders, I tested your algorithm, 

The combination engine looks fine, 

But it seems like the permutation engine has got an error

First, it supposes to generate branches of 3 items each time

Second, it's supposed to generate 336 items, not the whole 40k iterations 

Am I right? What do you think is the problem?

found it, I guess Its the combination length you forget to add

It works fine now

Afraid I don't quite follow, forgot to add what/where? The combinations 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 permutations. Anywho, it's been awhile since I used these, so might be remembering this wrong.

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 :)

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service