Optimo package issue in fitness function

Hi everyone,

I these days I tried to learn how to use Optimo but without great success.

I read the publications about Optimo and the GitHub page but something is still missing. I also gave a detailed look at the examples Dynamo files in the Optimo folder and these files worked on my laptop. So it should be an error on how I define the fitness function.

An error occurs and it is from the “NSGA_II.AssignFitnessFuncResults” node and it shows the following error “Warning: NSGA_II.AssignFitnessFuncResults operation failed.”

Cattura

At first, with my main fitness function, I thought it was a clash between packages as I am loading data from excel and an osm file. Then I made simar and smaller version of the fitness function using only nodes from dynamo but the result was the same.

For information I am using:

Dynamo 1.3.3.4651 (I tried both Sandbox and Revit)
Revit 2018.3 (Revit units in meters)
Optimo 0.1.2

For the main fitness function, I am using also
Elk 1.1.0 to import osm files.
and Read from Excell file node

This is the custom node I made for the fitness function:

And this is the optimisation problem:

The aim of this fitness function is to obtain the minimised value of the volume shape factor (Surface/Volume) by moving on X and Y one point (for now) of the building footprint. Later I would like to give X and Y parameters to every point the volume footprint.

As I can’t upload an .osm file on the forum, I’ll share the files through DROPBOX

Please, update the two nodes “File Path” to your directory.

I really hope you can give me some help to go further with my work.

I am really looking forward to hearing from you soon,

Best wishes.

PS. The custom node works outside the optimisation loop and I have already contacted the developer but without any answer.

I’ve used the optimo package with great success (especially in dyn 2.x) but also 1.3.2, I’ll have a look on Monday when I am at a computer :slight_smile:
Please copy paste your custom node into a normal workspace, enable all previews and feed it two values imitating your population list :slight_smile:
And post the result of course :wink:

Hi @Jonathan.Olesen

I followed your tip and the error in the optimisation loop changed as you can see from the image :sweat_smile:.

second%20error

The mistake was that I was using a single value as an input and not a list of values. Thank you for getting me there.

Anyway, this error reports an issue related probably to the range of the lower and upper limits?

As the error changed, I gave a try also at the second fitness function. This one aims to maximise the direct sunlight hours on the overall surface of the building using ladybug (0.2.1) and honeybee (0.1.9) packages.
As I want this value to be maximised, I multiplied the analysis result by -1. Is this correct?

Once in the optimisation file, it gave me the same error but with a longer computational time probably because of the analysis.

Are you aware of any clash between any ladybug analysis and Optimo optimisation loop?

Do you thing it will be possible to give X and Y parameters to each point (12 points) of the building footprint?

I’ll attach both fitness functions and the optimisation file.

TestOptimization.dyn (18.2 KB)
Fitness Function Shape Factor.dyn (53.8 KB)
Fitness Function Solar Access.dyn (101.7 KB)

Do you suggest me to use the 2.0.1 dynamo version instead of 1.3.2?

I am glad it got you somewhere :wink:
I have not tested either honeybee or ladybug my investigations have been within Robot :slight_smile:
And the issue i had was with the interaction between robot and dynamo 1.x :wink: ill have a go on your problem on Monday anyway :slight_smile:
Can you share your geometry etc files?

The only external files I used is an Excel file for the UV voronoi generation and an .OSM file from OpenStreetMaps to create context and site boundaries.
I did not used any revit file as I am using Dynamo Sandbox. If you prefer to use Dynamo within Revit, just set the units to meters.

Here is the excel file

CaseStudy1-UVCoordinates.xlsx (8.3 KB)

As the forum is not allowing me to upload a .osm file, I’ll share it via Dropbox
i hope it will work :sweat_smile:

Thank you for your help! :smiley:

I think this is your problem exactly, you want non-negative results but as you do not want the lowest but the highest value the solution would be to use 1/x where x is the result, thus the bigger the result the “better” the fitness score :slight_smile:

If you include the two “.dyf” files as well you’ll save me the trouble of making the custom nodes for:
CaseStudy Navigatori - SF FF
CaseStudy Navigatori - SA FF

(Remember to include a description of which packages are needed to execute your graph (if any) :slight_smile:
e.g. where are these nodes from :wink:
image

Here there are the two .dyf files for the two fitness functions. I misunderstood the previous posts :sweat_smile:

CaseStudy Navigatori - SA FF.dyf (98.1 KB)

CaseStudy Navigatori - SF FF.dyf (50.3 KB)

The packages I am using are:

Optimo: 0.1.2
Ladybug: 0.2.1
Honeybee: 0.1.9
Elk: 1.1.0

I am using as well other two packages but I think there are no used in the two .dyf files.

Clockwork for Dynamo 1.x: 1.30.0
Archi-lab_Mandrill: 2018.2.1

Thank you for the tip about the correct syntax on how to maximise the fitness value of Optimo.

Fact is I am getting the same error also on the fitness function to minimise (Shape Factor fitness function “SF FF”) :sweat_smile:

Have a look at what I’m doing here (i added an extra “layer” to your optimization :slight_smile: )

TestOptimization.dyn (18.5 KB)
CaseStudy Navigatori - SF FF.dyf (54.2 KB)
Case-StudyNavi-SF-FF.dyf (5.7 KB)

(Remember to update the location of .xlsl and .osm files) these locations should preferably be inputs in the “.dyn” file and not inside the .dyf files.

Thank you so much for helping me on facing this problem.

I didn’t quite understand why there was the need to nest the fitness function into another custom node. :sweat_smile:

I noticed that increasing the initial population size, some null values appeared in the Function.Apply node. This was due to the fact that the point I selected to move was too close to the nearby ones and with a certain set of coordinates results in an overlapped polycurve.

I decided then to create a new VoronoiDiagram where the minimum distance between points is more than 10 meters because of the range of X and Y coordinates from -5 to 5 meters.
I think this should solve the null values problem and allow the optimisation problem to run with a bigger population. Thank you so much for the help :smiley:

Then, I tried to the other fitness function with Ladybug and Honeybee packages.

This time a quite strange error occurred. The fitness function seemed to work but the honeybee analysis was not able to reiterate the analysis the times stated in the population size. As you can see in the image, some values were calculated but 2 out or 5 results as a null value. I tried to increase the population to 10 but this time tree null values appeared.

I tried to place the X and Y values on index 1 and 4 in the fitness function outside the optimisation problem and it worked fine

It seems that Honeybee is not able to run the required times. I counted as well the times the honeybee analysis window appeared and it was less than the iteration required.

Maybe this could be of interest also to @Mostapha.

To allow Honeybee to work in Dynamo you need to install Radiance on the C:\radiance on your computer.

Here you will find the two .dyf files and Optimsation .dyn

CaseStudyNavi-SolarAccess FF.dyf (5.6 KB)
CaseStudyNavi-SolarAccessFF NESTED.dyf (103.1 KB)
TestOptimizationSolarAccess.dyn (17.0 KB)

I do have a hunch why you get null values… (which breaks the NSGA)… either it is a timing issue (the analysis does not have time to finish before your graph continues, you could try using “waitfor” nodes or python scripts for delaying the process) or it is caused by a division by e.g. 0 (as you’re working with very small numbers).

You could introduce a “replace null” node in the end of your inner-most graph and put in a clearly too high value (e.g. 10000) so that you can identify at what stage your issue occurs without crashing the loop…

As I’m a structural engineer my understanding of the solar/energy/MEP analysis is limited :wink:

The reason for nesting it into another custom node is that you have multiple upper/lower limits, this means that you need to apply each “set” individually, that is done with “list.combine” if you had only one upper/lower limit you could avoid the one level of nesting :slight_smile:

Out of curiosity it is not your dynamo that is crashing? (big crash windows displays on large populations/iterations)

I tried to run the analysis with 3, 4, 5 and 10 population size and Dynamo never crashed (I know it’s not really a good number for an optimisation problem :sweat_smile:)

I tried to change the final part of the fitness function to maximise the fitness value. I changed the division 1/x to a multiplication x * -1. The result of the analysis is still the same with some null values and some negative values. I will give a try with this as some results are coming up. If this will not work, I will go back again to 1/x.

About the waitfor nodes, I found “Passthrough” in Clockwork for Dynamo 1.x (1.32.0).
Fact is I do not have any clue on how and where this node should be placed as the Optimo problem is getting more and more complicated :sweat_smile:

It would be great to have again your help!

Passthrough is similair to my suggestion, I would simply write “{waitfor,pass}[1]” in a codeblock…
This helps the graph wait for the output from one process “waitfor” before it “passes” the output from another process :slight_smile: I’ve found that running your graph identifying a specific population that causes null values and manually feeding these values to the fitness function in a separate graph helps identify such errors :slight_smile:

Here it is what tried to do. I don’t know if I am using correctly the node you suggested and if it is in the right place.

I tried to populate manually the fitness function in a separate graph and it worked fine with the values that resulted in a null value :sweat_smile:

Hello.
Im running into the same problem you had ind the end with the Warning: Null value cannot be cast to Double.
This problems Occours in Dynamo 2.x

Did you find a solution?