Parallel Computing in Global Optimization Toolbox
R2026bParallel processing can speed optimization algorithms by distributing function evaluations across multiple processors. To use parallel processing, you must have a Parallel Computing Toolbox™ license.
To set up parallel computing, open a parallel pool:
parpool
Note
Depending on your preferences, MATLAB® can start a parallel pool automatically. To enable this feature, select Parallel > Parallel Settings... in the Environment group on the Home tab, and then select Automatically create a parallel pool.
Then set the UseParallel option to "auto" or
"on" to enable parallel computing for your solver.
| Solver | Command-Line Settings |
|---|---|
ga |
|
gamultiobj |
|
MultiStart |
or
|
paretosearch |
|
particleswarm |
|
patternsearch |
|
surrogateopt |
|
Global Optimization Toolbox solvers use parallel computing in different ways depending on the solver. For details, see the solver-specific pages:
MultiStart —
MultiStartdistributes start points to multiple processors.GlobalSearchdoes not compute in parallel directly, but thefminconlocal solver can estimate gradients in parallel.Parallel Computing with ga, gamultiobj, particleswarm, and paretosearch — These solvers evaluate populations or poll points in parallel.
Parallel Computing with patternsearch —
patternsearchevaluates poll points and search functions in parallel, with specific option requirements.Parallel Computing with surrogateopt —
surrogateoptevaluates search points on workers asynchronously usingparfeval.simulannealbnddoes not run in parallel directly, but can call hybrid functions that take advantage of parallel computing. See Parallel Hybrid Functions.
Note
The documentation recommends not to use parfor or
parfeval when calling Simulink®; see Using sim Function Within parfor (Simulink). Therefore, you might
encounter issues when optimizing a Simulink simulation in parallel using a solver's built-in parallel functionality. For
an example showing how to optimize a Simulink model with several Global Optimization Toolbox solvers, see Optimize Simulink Model in Parallel.