Skip to Main Content Skip to Search
Product Documentation

How to Use Parallel Processing

Multicore Processors

If you have a multicore processor, you might see speedup using parallel processing. You can establish a matlabpool of several parallel workers with a Parallel Computing Toolbox license. For a description of Parallel Computing Toolbox software, and the maximum number of parallel workers, see Parallel Computing with MathWorks Products.

Suppose you have a dual-core processor, and want to use parallel computing:

When you run an applicable solver with options, applicable solvers automatically use parallel computing.

To stop computing optimizations in parallel, set UseParallel to 'never', or set the Optimization Tool not to compute in parallel. To halt all parallel computation, enter

matlabpool close

Processor Network

If you have multiple processors on a network, use Parallel Computing Toolbox functions and MATLAB Distributed Computing Server™ software to establish parallel computation. Here are the steps to take:

  1. Make sure your system is configured properly for parallel computing. Check with your systems administrator, or refer to the Parallel Computing Toolbox documentation, or the Administrator Guide documentation for MATLAB Distributed Computing Server.

    To perform a basic check:

    1. At the command line, enter

      matlabpool open conf

      or

      matlabpool open conf n

      where conf is your configuration, and n is the number of processors you want to use.

    2. If network_file_path is the network path to your objective or constraint functions, enter

      pctRunOnAll('addpath network_file_path')

      so the worker processors can access your objective or constraint files.

    3. Check whether a file is on the path of every worker by entering

      pctRunOnAll('which filename')

      If any worker does not have a path to the file, it reports

      filename not found.
  2. Set your solver to use parallel processing.

    MultiStartPatternsearchGA

    ms = MultiStart('UseParallel', 'always');

    or

    ms.UseParallel = 'always'

    options = psoptimset('UseParallel', 'always', 'CompletePoll', 'on', 'Vectorized', 'off');

    options = gaoptimset('UseParallel', 'always', 'Vectorized', 'off');

     

    For Optimization Tool:

    • Options > User function evaluation > Evaluate objective and constraint functions > in parallel

    • Options > Complete poll > on

    For Optimization Tool:

    • Options > User function evaluation > Evaluate fitness and constraint functions > in parallel

After you establish your parallel computing environment, applicable solvers automatically use parallel computing whenever you call them with options.

To stop computing optimizations in parallel, set UseParallel to 'never', or set the Optimization Tool not to compute in parallel. To halt all parallel computation, enter

matlabpool close

Parallel Search Functions or Hybrid Functions

To have a patternsearch search function run in parallel, or a hybrid function for ga or simulannealbnd run in parallel, do the following.

  1. Set up parallel processing as described in Multicore Processors or Processor Network.

  2. Ensure that your search function or hybrid function has the conditions outlined in these sections:

patternsearch Search Function

patternsearch uses a parallel search function under the following conditions:

In the Optimization Tool, first create the gaopt structure as above, and then use these settings:

For more information about search functions, see Using a Search Method.

Parallel Hybrid Functions

ga and simulannealbnd can have other solvers run after or interspersed with their iterations. These other solvers are called hybrid functions. For information on using a hybrid function with gamultiobj, see Parallel Computing with gamultiobj. Both patternsearch and fmincon can be hybrid functions. You can set options so that patternsearch runs in parallel, or fmincon estimates gradients in parallel.

Set the options for the hybrid function as described in Hybrid Function Options for ga, or Hybrid Function Options for simulannealbnd. To summarize:

  


Free Optimization Interactive Kit

Learn how to use optimization to solve systems of equations, fit models to data, or optimize system performance.

Get free kit

Trials Available

Try the latest version of optimization products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS