classification error: slicing struct for parfor loop
3 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to run several calibrations in parallel, however even after slicing all the variables I still get the error: The variable parforloopData in a parfor cannot be classified. Here's the abbreviated code:
parfor (i=1:size(uniqueDates,1))
if( parforloopData(i,1).skip == 0 )
while (parforloopData(i,1).gbest > DEParams.VTR)
% start differential evolution
[parforloopData(i,1).bestmem, parforloopData(i,1).bestval, parforloopData(i,1).bestFctParams, parforloopData(i,1).iterno, parforloopData(i,1).pop] = differentialevolution( DEParams, paramDefCell, objFctHandle, parforloopData(i,1), parforloopData(i,1).objFctParams, emailParams, optimInfo);
parforloopData(i,1).gbest = parforloopData(i,1).bestval;
for(k=1:size(parforloopData(i,1).pop,1))
parforloopData(i,1).ObjectiveFunction = @(x) SVJObjFunDEGulli(parforloopData(i,1), x);
[parforloopData(i,1).posbestSet, parforloopData(i,1).posgbest,parforloopData(i,1).exitflag, parforloopData(i,1).output] = fminsearch(parforloopData(i,1).ObjectiveFunction, parforloopData(i,1).pop(k,:));
if (parforloopData(i,1).posgbest < parforloopData(i,1).gbest)
parforloopData(i,1).bestSet = parforloopData(i,1).posbestSet;
parforloopData(i,1).gbest = parforloopData(i,1).posgbest;
end
end
if ( abs(parforloopData(i,1).bestLocalMinimum - parforloopData(i,1).gbest) > reseterrgrad)
parforloopData(i,1).bestLocalMinimum = parforloopData(i,1).gbest
else
parforloopData(i,1).newSet = minbound+(maxbound-minbound).*rand(1,8);
while (~checkStartingValuesDifference(parforloopData(i,1).newSet,parforloopData(i,1).startingValuesMatrix, diffInStartingValues ))
parforloopData(i,1).newSet = minbound+(maxbound-minbound).*rand(1,8);
end
parforloopData(i,1).startingValuesMatrix(end+1,:) = parforloopData(i,1).newSet;
parforloopData(i,1).objFctParams.V0 = parforloopData(i,1).newSet(1)
end
end
optimParams(i,:) = [uniqueDates(i) parforloopData(i,1).bestSet parforloopData(i,1).gbest];
end
end
parforloopData is a struct, which has many of its variables entered in a previous normal loop. I don't really understand why I get the error here, since each loop works on its own slice of parforloopData
0 件のコメント
採用された回答
Jill Reese
2014 年 7 月 2 日
It might help to store parforloopData(i,1) in a temporary variable inside the loop, use the temporary variable everywhere, and then update parforloopData(i,1) with the value of the temporary before exiting the parfor loop.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Parallel for-Loops (parfor) についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!