【发布时间】:2015-07-23 08:34:05
【问题描述】:
我正在使用 spmd 在 matlab 中实现模拟退火算法。我将比较不同的实现类型。其中之一是异步并行。 12 名工人将运行代码。如果其中一个符合条件(错误
【问题讨论】:
标签: matlab parallel-processing simulated-annealing spmd
我正在使用 spmd 在 matlab 中实现模拟退火算法。我将比较不同的实现类型。其中之一是异步并行。 12 名工人将运行代码。如果其中一个符合条件(错误
【问题讨论】:
标签: matlab parallel-processing simulated-annealing spmd
根据@Daniel 的建议,在 MATLAB R2013b 及更高版本中,您可以使用parfeval 来执行此操作。像这样的:
% First, kick off the asynchronous work:
N = 12;
for idx = 1:N
f(idx) = parfeval(@myFcn, 1, args);
end
% Next, consume the results
for idx = 1:N
% fetchNext blocks until one of 'f' has completed,
% returning the index into 'f' that completed, as
% well as the result.
[idxInF, result] = fetchNext(f);
if result < 0.01
% we're done!
cancel(f); % Cancel all outstanding work
break; % stop looping and calling fetchNext
end
end
【讨论】:
我将使用作业启动所有 12 个进程。您可以检查其中一项已完成的作业是否符合您的条件,然后取消其他作业。
http://www.mathworks.com/help/distcomp/cancel.html http://www.mathworks.com/help/distcomp/create-simple-independent-jobs.html
【讨论】: