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.

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)

# Genetics algorithm

**igpema**#1

**JacobSmall**#2

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 40*10**4*360 tests here, if not more).

**igpema**#3

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!

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.

**igpema**#5

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.