why does (ga + parallel + global variables + sub2ind) fail?
显示 更早的评论
When optimizing with ga and parallel computing, a sub2ind call using globals fails (subscript vectors must be of same size), but when doing it in serial, it doesn't fail. Why?
采纳的回答
更多回答(2 个)
Walter Roberson
2016-9-10
1 个投票
Global variables are never copied to parallel workers.
You might be able to take advantage of parallel.pool.Constant or of parfevalOnAll() to initialize the variable on all of the workers.
1 个评论
Walter Roberson
2016-9-11
If you have especially large shared data, you could also use the File Exchange contribution https://www.mathworks.com/matlabcentral/fileexchange/28572-sharedmatrix to use shared memory. This will only work if the compute nodes are on the same host, though
类别
在 帮助中心 和 File Exchange 中查找有关 Parallel Computing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!