Parallel Computing in Optimization Toolbox Functions

Parallel Optimization Functionality


The Optimization Toolbox™ solvers fmincon, fgoalattain, and fminimax can automatically distribute the numerical estimation of gradients of objective functions and nonlinear constraint functions to multiple processors. These solvers use parallel gradient estimation under the following conditions:

  • You have a license for Parallel Computing Toolbox™ software.

  • The option GradObj is set to 'off', or, if there is a nonlinear constraint function, the option GradConstr is set to 'off'. Since 'off' is the default value of these options, you don't have to set them; just don't set them both to 'on'.





Parallel Estimation of Gradients

One subroutine was made parallel in the functions fmincon, fgoalattain, and fminimax: the subroutine that estimates the gradient of the objective function and constraint functions. This calculation involves computing function values at points near the current location x. Essentially, the calculation is



  • f represents objective or constraint functions

  • ei are the unit direction vectors

  • Δi is the size of a step in the ei direction


Parallel Central Differences




Enable central finite differences by using optimoptions to set the FinDiffType option to 'central'. To use forward finite differences, set the FinDiffType option to 'forward'.

Nested Parallel Functions

Solvers employ the Parallel Computing Toolbox function parfor to perform parallel estimation of gradients. parfor does not work in parallel when called from within another parfor loop. Therefore, you cannot simultaneously use parallel gradient estimation and parallel functionality within your objective or constraint functions.





When parfor Runs In Parallel

Was this topic helpful?