Borrar filtros
Borrar filtros

UseParallel Option with fmincon

26 visualizaciones (últimos 30 días)
repritchett92
repritchett92 el 27 de Mzo. de 2017
Comentada: Alan Weiss el 29 de Mzo. de 2017
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?

Respuesta aceptada

Alan Weiss
Alan Weiss el 28 de Mzo. de 2017
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 comentarios
repritchett92
repritchett92 el 28 de Mzo. de 2017
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 el 29 de Mzo. de 2017
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by