cplex object params not transferred to parfor loop
Show older comments
I am trying to solve the batch of CPLEX problems in parallel using parfor loop. I'm not very fluent in Matlab data types, but CPLEX problems seem to be stored as handle class objects with two structs: Model and Param.
Now, say I have an array with the paths to my .lp problems and I am reading them into cell array:
subp_array = {}; % array to store problems
nSubp = 1; % for indexing problems
% read models into subp_array
for file = filepaths
prob = Cplex('uc');
prob.readModel(file{1});
prob.Param.threads.Cur = 1;
subp_array{nSubp} = prob;
nSubp = nSubp+1;
end
The param threads.Cur is particularly important, because it indicates how many threads can be utilized for a single CPLEX problem (and with anything other than 1, it does not bring any time benefit). Now when I run the loop to solve the problems and I print the param value:
parfor subp_index = 1:length(subp_array)
prob = subp_array{subp_index};
disp(prob.Param.threads.Cur);
% solve the problem
prob.solve();
end
They all happen to be 0 (default value). If I run the for loop instead, it keeps the value of 1.
What happens here? I'm actually trying to catch more differences in my original code as parfor returns completely different results than for - but this one could be an indication for me where the differences come from.
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Parallel Computing Fundamentals 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!