Does using global variables in objective function risk error when using ga in parallel?

1 view (last 30 days)
Hi,
I am using the optimization toolbox with a relatively complicated computational fluid dynamics tool I have written as the objective function. The tool uses global variables within it becuase it was convenient when I wrote it. Some of these variables are simulation specific and will change based on the optimization input.
My question is, when I use the ga tool in parallel, is there a risk of the global variables becoming confused because simultaneous simulations are being performed on different processors? Or will the global variables be kept private to each processor?
Thank you,
W. S. H.
UPDATE:
Instead of spending excessive time trying to figure out what was going on with my problems, I spent a couple hours modifying my tool to use only private variables. This fixed the issues I was having. So not sure what the problem was in my case, but the lesson here is be VERY CAREFUL if trying to use global variables in this type of problem.

Answers (1)

Rakesh Kumar
Rakesh Kumar on 8 May 2015
Every worker will have its own copy of the global variable not in sync with other workers. Its global for all the M-files on a worker but not for all workers.
I do not fully understand your usage but if global variables depend on (previous) simulation then I don't see any easy way you can use them in parallel.
Rakesh
  2 Comments
Schuyler Hinman
Schuyler Hinman on 8 May 2015
Thanks alot of the response Rakesh. I had assumed it worked that way.
The global variables dont depend on previous or other simulations they should be independent. I am troubleshooting the problem that when my optimization run is finished, when I check the fitness value for the optimum result it doesnt match the best value that the optimization run had reported.
Rakesh Kumar
Rakesh Kumar on 11 May 2015
Are there constraints in the problem? Are you using HybridFcn option? The 'optimization run reported...' are the arguments returned by GA or iterative display?
Please send the iterative display (The last few iterations and stopping message), the final output you get from GA and show how it does not match? This may give some clue.
Thanks,, Rakesh

Sign in to comment.

Categories

Find more on Computational Fluid Dynamics (CFD) in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!