Delaying Excel Read / Write Components to allow Optimizers to work?

Hello All,

I have a couple components that write data into a fairly complex internal excel spreadsheet, and then I have a couple components that read the result of those internal Excel computations. This works great if I have a static variable, or even if I just want to show that the Excel reader is dynamic and can read a changing slider (with some delay).

The problem is when I try and hook up this script to an optimizer (Octopus, Galapagos, DSE), the internal delay between the changing of the input sliders and the updated result from the Excel reader make the optimizer disassociate specific inputs with their outputs.

In other words, my well behaved optimization model suddenly becomes a computational nightmare for Octopus because there is no feedback loop, and the benchmarks that define one combination of variables as superior to another cannot be trusted.

I can replicate the logic from the Excel spreadsheet in a huge Grasshopper script, but that would take forever and it doesn’t make sense to double the work. For background information, I am using some pretty old plugins to read and write to Excel (GHExcel).

Is there a way to break up this script such that an optimizer plugin can ‘wait’ for the internal excel calculations to complete and then use the specific result in the optimization feedback loop?

Thank you



It seems that the MIT DSE plugin doesn’t have this problem after a very surface level study.


After further study, the MIT DSE has the same problem.


how is that possible, the change in parameter results in subsequent change in fitness, time between one and other input should not matter. isnt it always that parameter change comes before fitness change no matter time delay ?


My (incomplete) understanding of Grasshopper is that if the logic stream from the parameter slider to the fitness function is unbroken, there will be no problems in associating the specific parameter choices to their fitness function.

What was unique about my script was that the logic stream WAS broken when I decided to send information to Excel. After I had studied this for a while, I realized that the optimization components must change the parameter sliders and read the fitness function that is present at that instant. Because it took time for the GH script to push data to Excel and pull it down, the fitness functions were one step behind the parameter sliders changing, and therefore the Optimization components had no feedback loop and didn’t work.

Here’s an example:

If A+B=C, D+E=F, and H+I=J and (A,B,D,E,H,I) are parameters and (C,F,J) are fitness functions…

Optimization Run #1:
The optimizer sees that parameters (A and B) result in a fitness function equal to ( C ). This is the first Optimization Run, so the time lag effect is not present here. The parameters (A and B) have already made their way to the Excel Spreadsheet, and then the parameters (A and B) came into the GH script to result in a fitness function equal to ( C ).

Optimization Run #2:
The Optimizer changes the parameters to (D and E). As a result, these new parameters are now just being pushed to the Excel Spreadsheet. This takes time, and in the same manner that the Optimizer saw that (A and B) result in ( C ), the Optimizer now sees that (D and E) also result in ( C ).

Optimization Run #3:
The Optimizer changes the parameters to (H and I). Again, these new parameters are now just being pushed to the Excel Spreadsheet. Because of the lag in the parameters coming back from the Excel Spreadsheet, the fitness function now is equal to (F). The Optimizer now sees that the parameters (H and I) result in the fitness function (F).

This process goes on until the number of Optimization Runs is complete. It is the nature of the previous fitness function to still be in a position to be observed by the Optimizer as associated with the new parameters that are being input and simultaneously pushed to the Excel Spreadsheet.

I ended up having to recreate all my logic in the GH script, and therefore wasting a significant amount of time. The script works well now, given the limitation that I cannot call outside the GH script to support the process.

I apologize if this leaves you more confused. I would suggest setting up a simple problem using the Excel read and write components and one of the many Optimization Plugins to see what I mean.

Hope this helps,