Genetics algorithm

Hello,
I am trying to calculate the best rotation of the tower that has better views. To every floor plan I draw a line that intersect with the next building. the length of the line views change if we rotate the tower more or less.
To determine the fittest rotation we need to try many rotations and then get the rotation that gives us the longest line view sum.
I tried Optimo but I am not happy about. I am trying now with a simple code, but unfortunately I have no experience with programming and I can not solve it. Maybe someone with better knowledge in Code blocks could help me out. :slight_smile:
So far i defined a definition that creates random values for the rotation values, and I need now another definition that take the sum values of the “viewlines” and get the longest and related it to the value of the rotation. With an amount of iterations we will be close to the fittest rotation :).Turm_genetics algorithms.dyn (46.1 KB)

1 Like

You may want to try using project fractal for this exercise instead of trying to look at all rotations yourself and looking at the ‘best viewing distance’ as the best viewing distance may not be the best tower (best view but worst form or too much unusable space). It will also likely be much faster to run as it uses the cloud rather than your CPU (you’re doing something like 4010**4360 tests here, if not more).

https://home.fractal.live

1 Like

Thanks Jacob, I already contacted the Fractal group, but the fact it is that I want to learn to code myself. Yes, the best rotation might not be the one that offers better usable spaces, but if I learn to code, I will add this variable, and many others too. Anyhow, I am giving a try to Fractal, cause it looks really cool! :slight_smile:

That’s a hell of a challenge if you’ve never done any programming! You might want to try something a little less complicated for now. You’re asking for some pretty heavy computational lifting.

You could try to adapt the course on ThinkParametric –
https://thinkparametric.com/courses/view-optimization-using-galapagos-for-grasshopper – to Dynamo and Optimo.

2 Likes

Thaks Greg!! Yes I know the example of Galapagos, pretty much is the same example that I copied with the intention of learning programming in Dynamo ;). But thanks for the website, I might visit some courses there :).

I tried assembling a little Optimo script for you. It seems to work on my part. Haven’t gone through in detail, and should probably be washed so that it doesn’t create all the geometry each run, but it didn’t consume my computer at all…
Anyway:

To use the results, you will have to pick a value from the last codeblock. List [0] contains the rotations, List[1] contains the Fitness. Optimo sorts so that the best fitness is at the top of the list. (as long as the population size/ number of loops is enough for not hitting a local optimum)

The “custom node” aka your script:

Mind that Optimo, unlike Galapagos, can ONLY minimize values, that means that in your case you have to add a negative to the Fitness.

8 Likes

oh great!! I tried with Optimo but i didn’t succeed. Thanks a lot!! :slight_smile: :slight_smile: