algorithmic modeling for Rhino

Can I make galapagos wait for new fitness from extern file?

Hi Everyone

I'm optimizing an office facade using Diva and Viper for the light and solar calculation and afterwards sending the hourly results to MatLab for simulating the annual energy use and performance of the indoor climate and ventilation system. From Matlab I send the reults back to Grasshopper and generate a fitness from the MatLab result. All this works fine, but I would like to optimiza the parametrics of the facade in loop, but Galapagos is not waiting for the fitness result to update from MatLab.

So can I make Galapagos change parametric and then WAIT for the NEW fitness before changing the parametrics in the next loop?

I've tried the 'delay'-component, but it is not working :(

Hope someone can help me! and thank you very much!

Views: 1700

Replies to This Discussion


recently created a version of Octopus which has its internal functionality (and therefore code) laid out in separate components, so, a.o., you are able to track exactly what the algorithm is doing in the big picture. I coupled it with Anemone for looping, so you can also force it to wait for an external result in whatever manner.

I ll release it soon, but if you want you can have the set of protoype components [called 'Octopus Explicit'].



Thank you very much for the tip!

I look into to the plug-in durring last day and have some questions about it:

- How/where do I change the algoritm to minimize instead of maximize?

- how do I secure that the program only reads updated objectives/fitness? or did you mean that this only were possible in your new furture release?

Hi Pil,

I have the same question with yours. Is there a way to maximize the values? And did you successfully make the evaluation to wait for the loops to finish?

Hope to hear from you soon :)

Hi  Lezhi


I found my way through it, but it wasn't simple.

First I decided to use Galapagos - which makes it easy to choose between minimization and maximization.

Afterwards I needed to make Rhino wait for MATLAB-calculation to finish. This was a bit complicated. I used a python-script running in a “micro”-loop inside the python-component while blocking grasshopper. Inside the python-micro-loop the script is first checking for the MATLAB-result-csv-file to exist and if not: I script “wait(1)” to make grasshopper wait one second before checking for MATLAB-result again. When the MATLAB-result exist the python-component will open the result, end the python-script and return the macro-loop in Grasshopper.  

This is the principle (sorry can’t remember the correct scripting. It has been a while. use google to find the correct scripting):

Result=0                                                     (defining result to 0)

while result=0                                              (Loop while result=0)

   result=result+check.exist.MATLABresult.csv   (If file exist: result=1 and loop ends)

   Wait(1)                                                    (to wait one second)


result=Read.csv.MATLABresult.csv                    (open MATLAB result)


To make this work, the MATLAB-code needs to delete the old result before calculating the new one. Otherwise Grasshopper believes that a result exists, doesn’t wait for the new result and just uses the old (and wrong) result.

Hope this answers a bit for you. My result worked, but it wasn’t simple, easy to use or beautiful. However this was the idea of the principle. Now I'm working with integrating the MATLAB code into Grasshopper - then the problem doesn't exist anymore :)

Good luck!


Hello Robert,

I am facing the same problem as Pil. Is there any example that demonstrates how to do this waiting for a trigger - as I am very new to octopus and especially octopus.e

Thank you


Basically it does not matter if you use Galapagos, Octopus, or OctopusE with the abovementioned problem with Matlab.

What happens is:

- you trigger a matlab procedure from a GH component; this component apparently just triggers matlab to start and does not wait for any results; therefore the GH definition just continues

- another component has to stop the definition until the result is written to a file by matlab

- the definition continues and reads the new results from a file

I dont have any examples but with a new research program at my University there is a chance we set up matlab processes.

Until then I guess you have to search for examples, a lot of people actually use that workflow.



Is this still the only hack to this particular problem? 


Can you please explain where can I find that Delay component and where can I attach regarding Galapagos?

I have only internal calculations, but it seems I should wait for "answer", approx. 2 seconds, before Galapagos goes to the next value on the slider. I also have an Anemone loop in my definition, which is triggered by the one of the slider connected to Galapagos.

Thank you.

BR, Balazs

Hi Balazs, 

Did you find a solution yet? I am facing the same problem.



Hi Thomas,
My definition is working fine now but I'm using Anemone loop for recursive looping.
It seems Galapagos runs with it properly.
What solution are you looking for exactly?
Br, Balazs

My problem is that Galapagos doesn't wait long enough with changing the sliders. The internal loop has not calculated the optimal new value when Galapagos is already changing the sliders again. Did you manage to make galapagos wait or something like that?

I can really recommend Robert's OctopusE components. It detaches the solvers and makes explicit all of the outputs, and allows you to iterate using a looping mechanism like Anemone or OctopusLoop.






  • Add Photos
  • View All

© 2020   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service