fmincon with and without parallel computing yields different results
14 views (last 30 days)
Show older comments
Hi all, I have a question concerning the use of fmincon (nonlinear constraints) with the parallelisation toolbox. I use the following code:
options=optimset('Display','iter','Algorithm','active-set','UseParallel','always');
[man_var,f,eflag,outpt] = fmincon(@calculate_obj,man_var_0,[],[],[],[],man_var_lb,man_var_ub,@calculate_ineqc,options);
In the functions calculate_obj and calculate_ineqc I evalute a process model and use its results to calculate the nonlinear constraints and objective value. My problem is that when I add 'UseParallel','always'in the options, I get a different result from fmincon and it seems that fmincon with 'UseParallel','always' solves the problem differntly compared to the fmincon without parallelisation. Here, the problem appers that in the case with parallel computing fmincon starts to oszillate and does not find a solution. As fare as I understood the parallelisation toolbox, it should only distribute the computation to different workes, but the final solution should remain the same. I'm currently using version 2013b, because the model was written in this version of Matlab.
It would be nice if someone could give me a hint how to solve this problem. Thanks a lot.
Best regards Carsten
0 Comments
Answers (1)
Alan Weiss
on 27 Mar 2018
The only difference between using parallel computing and serial computing is that, in parallel, finite difference approximations to the gradient are done in parallel.
So I believe that your calculate_obj function or calculate_ineqc function use random numbers in some way, or write to files that get overwritten in parallel, or some such thing. I can guarantee that the underlying fmincon algorithm is 100% identical in parallel and serial.
For caveats and similar issues, see Improving Performance with Parallel Computing, particularly the section on Factors That Affect Results.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
5 Comments
Alan Weiss
on 28 Mar 2018
Sorry, I really don't know what is going on. The only idea I have is that you might be running in parallel on a network of computers, rather than a multicore machine, and the miniscule error comes from an answer being off by machine eps, which is to be expected whenever you run software on different machines or software versions. These kinds of errors can quickly expand on some ODEs, as the well-known chaos examples show.
If I am right about this, then the answer in parallel is not wrong, any more than the answer in serial is wrong. It just means that your problem is sensitive to miniscule differences in computations, which is not a fault of the solution computations, but is an inherent feature of your problem.
Sorry, that's all I know.
Alan Weiss
MATLAB mathematical toolbox documentation
See Also
Categories
Find more on Surrogate Optimization 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!