Grasshopper

algorithmic modeling for Rhino

Hi all,

 

Can anybody advise on how the Galapagos component in Grasshopper is triggered to “read” a fitness value (i.e., how does the Galapagos component know that a given genome has run its course through the script and produced a result)?

 

I have a fitness function that is based on analysis results from a program outside of Grasshopper, which is run and read via Grasshopper components (through the use of Geometry Gym). Sometimes, the analysis takes multiple iterations to converge on the fitness function for a specific genome. Through the use of a VB script and an external file, I have created (I hope) a setup where the component referenced by the fitness function is only updated once the analytic iterations have converged, however, Galapagos seems to be reading the fitness function for a given genome from the results two runs previous. The genome run time output by Galapagos during the optimization process seems to mesh with the time allowed for the analysis to complete its iterations and produce a new fitness function, so I'm not sure why it's not reading the associated fitness function result.

 

The snapshot below shows my fitness function setup. The VB script writes the ObjFunction.txt file only when the iterations of the external program are complete. Note the panel attached to the record component shows that the “file” component is only producing an output when the fitness function is updated (as evidenced by the lack of duplicate values). 

 

Apologies for the long post. Any thoughts are appreciated.

 

Thanks!

Views: 1964

Attachments:

Replies to This Discussion

The Galapagos object isn't part of the solution, it sort of sits on top of Grasshopper. It knows which sliders are relevant and it knows which number to watch, so it sets the sliders to whatever values it wants, then triggers a new solution, waits until the solution is finished, then reads out the number. After processing the number, it sets up the next solution, and the next, and the next.

It doesn't matter if the number parameter is expired due to the changes in sliders, all that matters is that a solution was started and ended.

--

David Rutten

david@mcneel.com

Thank you for the quick response.

It seems that my understanding of how grasshopper recognizes a "solution" is a little off. I thought that by using a VB script to sort of "break the chain" of updating to allow some iteration within grasshopper, I was keeping the program from reaching a "solution" until the iterations were complete. However, based on your response, a "solution" in grasshopper is reached when all of the components have had the potential to be run; so when the VB script component runs and doesn't pass an updated value along to a group of following components (which contain the fitness function), the following components have still had the "potential" to run, and therefore the lack of update is still considered a solution. 

Please excuse the crude description (Grasshopper is relatively new to me), and please let me know if my interpretation is totally off.

Thanks.

-Mark Hendel

Hi Mark,

you can make Galapagos wait for a solution, but that involves blocking the thread Grasshopper (and Rhino) run on. Basically, in your script component you have to lock the executing thread until you can harvest the data from your external process. The best way to achieve this probably requires nothing more advanced than a do loop which calls Thread.Sleep over and over again, probably with increasing delays:

Dim delay As Int32 = 50

Do

  If (ExternalProcessComplete()) Then

    Exit Do

  End If

  System.Threading.Thread.Sleep(delay)

  delay = Math.Min(delay + 50, 1000)

Loop

If you know that your external process always takes at least 5 seconds you can of course start by sleeping for 5 seconds.

--

David Rutten

david@mcneel.com

Hi David,

When you say it waits until the solution is finished, then reads out the number... it also means that it waits for a results which comes fairly slow due complex stuff, Karamba and Anemone components involved? My particular question is that Galapagos knows when an Anemone loop is finished and reads out only the finial result? So doesn't take any number when Anemone (or other circular reference loop solvers) is still on the "move"?

All of my loops to be run takes about 2 seconds in my computer, including the Anemone loop. (this later runs 6 iteration and it is triggered by one of the slider which is connected to Galapagos.)

Should I implement an additional component to be sure that all the loops are run properly and the real results will be read by Galapagos? Is there a kind of "delay" component?

Thank you,

Best regards,

Balazs

Hi Balazs, did you find a solution to this problem?

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service