Class with static variables in parallel global optimization algorithm
Ältere Kommentare anzeigen
Hello,
I have a global optimization program dealing with large matrices (several gigabytes of data), so in order to save memory, a class with static variables was implemented similar to the implementation in Static Data, and then one object of this class is created, initialized and passed as an argument to a function handle acting as the objective function of global multistage optimization algorithm (Particle Swarm + Pattern Search). When parallelization in optimoptions is true:
optimoptions( ...
'UseParallel', true);
The optimization always yields false results, but when parallelization is turned off, it works correctly.
Thanks in advance!
Antworten (2)
All variables are cloned when parallelization is used. Each parallel worker operates with an independent copy of any variable sent to it.
5 Kommentare
Omar Kamel
am 8 Feb. 2019
Matt J
am 8 Feb. 2019
We need to see code...
Omar Kamel
am 8 Feb. 2019
Matt J
am 8 Feb. 2019
Okay, but we also need to see how it is used in the optimization.
Omar Kamel
am 14 Feb. 2019
Bearbeitet: Omar Kamel
am 14 Feb. 2019
Walter Roberson
am 14 Feb. 2019
0 Stimmen
Look again at the link you provided . Notice the point about static data not being saved with an object . The process of sending variables to parallel workers involves save and load.
3 Kommentare
Omar Kamel
am 21 Mär. 2019
Bearbeitet: Omar Kamel
am 21 Mär. 2019
Walter Roberson
am 21 Mär. 2019
However, that saves the matrix once per worker, not "only 1 time in the memory". If you strictly need "only 1 time in the memory" then you should look in the File Exchange for https://www.mathworks.com/matlabcentral/fileexchange/28572-sharedmatrix which uses operating system shared memory.
Kategorien
Mehr zu Surrogate Optimization finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!