UseParallel Option with fmincon

26 次查看(过去 30 天)
Hello,
I am using fmincon to solve a large dimensioned problem (thousands of variables) and want to turn on the 'UseParallel' option to reduce computational time. Currently I supply fmincon with objective and constraint functions (nonlinear equality) as well as the gradients for these two functions. Before I run fmincon I establish a parallel pool on my local machine using parpool('local') which begins a parallel pool connected to two workers. Next, I run fmincon with the "UseParallel" option set to true. When I do this I receive no errors, however I observe no reduction in speed or any other evidence fmincon is actually computing anything in parallel. It was my understanding that by turning this option on fmincon would compute the gradient and constraints in parallel, but this doesn't seem to be happening. Am I misunderstanding something?

采纳的回答

Alan Weiss
Alan Weiss 2017-3-28
Well, if you supply the gradients and set the appropriate options (set SpecifyObjectiveGradient and SpecifyConstraintGradient to true), then fmincon does not estimate the gradients numerically, so there is no point in using parallel computing. There is no parallel gradient estimation going on in this case.
Depending on the complexity of your gradient calculations, it can be faster to estimate the gradients numerically. I mean, it is possible that numerical estimation of the gradients would be faster than analytic evaluation. Set the gradient options to false and see. Of course,it is also possible that numerical estimates are slower than analytic evaluations.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 个评论
repritchett92
repritchett92 2017-3-28
Hi Alan,
Thanks for your quick answer, this was really helpful. I turned off the user supplied gradient options and then fmincon did indeed compute the gradients in parallel. However, due to the size of my optimization problem even this option is still much slower per iteration than the strategy I use in my user supplied gradients. I currently employ complex step differentiation written in a vectorized code format to compute sparse versions of the necessary gradients. If I were to employ parfor loops within my supplied gradient function (I don't currently) would turning on the "UseParallel" option then be helpful?
Additionally, I was hoping that when I turn the "UseParallel" option on fmincon would use parallel computing in its computation of the Hessian matrix. But based on what I've observed this is this not the case, correct?
Alan Weiss
Alan Weiss 2017-3-29
As documented, the automatic parallel functionality is to estimate gradients by parallel finite differences. If you want to do something fancier in parallel, feel free, but you'll have to write the parallel code yourself.
Alan Weiss
MATLAB mathematical toolbox documentation

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by