Grasshopper

algorithmic modeling for Rhino

Hi, i am using python component to generate all combination of number which sum up to particular given number.(this works for small number with lesser variables)

INPUT x=1500
scrpit:

import rhinoscriptsyntax as rs
a=[]
b=[]
c=[]
d=[]
e=[]
f=[]
g=[]
h=[]
i=[]
for i15 in range(1,x,1):
for i14 in range(1,x,1):
for i13 in range(1,x,1):
for i12 in range(1,x,1):
for i11 in range(1,x,1):
for i10 in range(1,x,1):
for i9 in range(1,x,1):
for i8 in range(1,x,1):
for i7 in range(1,x,1):
if(i15+i14+i13+i12+i11+i10+i9+i8+i7==x):
a.append(i15)
b.append(i14)
c.append(i13)
d.append(i12)
e.append(i11)
f.append(i10)
g.append(i9)
h.append(i8)
i.append(i7)

This scrip getting stuck..what should i do get all combination?

Views: 1035

Replies to This Discussion

Yeah, it sounds like solomon needs to tell us why he needs these sequences, perhaps there's a better way to solve his problem.

Thanks for working out the maths.

Hi!

Another approach. Still too slow for your example.

As David said: there are too many combinations.

Cheers!

Attachments:

A little modification to get only sequences with exact l elements

Attachments:

Hey. Firstly, thanks for your interest..
@David Rutten : I am working on a project .where we have a site of size 1500 sq mt. and i have 9 programs(including open space) to fit in .The shape i chose is rectangle with golden ratio for L:B(i convert the area to rectangle using simple math) . What i wanted to do is to create all possible packing of elements on the site and cull the options which are not satisfying few of our conditions (Vastu(traditional Indian building principles) and relationships between elements etc..).... the above was my 1st idea and i tried it without thinking about the time taken to process it and the space it was gonna occupy..
Now i started thinking  about a different way to approach it. It will be great if you could give me any idea .

*Am just a undergraduate architecture student learning python.Any help in this topic will be very helpful for me
Thanks ,
S S Solomon

Finding solutions in search spaces that are too big to approach from a brute-force point of departure is what Galapagos was made for. It's not necessarily possible to solve any problem, you do need a measure of continuity between adjacent states, but if you can somehow map the characteristics you're looking for onto a single value then you may be able to use Galapagos.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service