Skip to Main Content Skip to Search
Product Documentation

Using Parallel Computing with fmincon, fgoalattain, and fminimax

Using Parallel Computing with 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 Product Overview.

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

Using Parallel Computing with a Multiprocessor 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.
    • For command-line use, enter

      options = optimset('UseParallel','always');
    • For Optimization Tool, check Options > Approximated derivatives > Evaluate 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

Testing Parallel Computations

To test see if a problem runs correctly in parallel,

  1. Try your problem without parallel computation to ensure that it runs properly serially. Make sure this is successful (gives correct results) before going to the next test.

  2. Set UseParallel to 'always', and ensure matlabpool is closed. Your problem runs parfor serially, with loop iterations in reverse order from a for loop. Make sure this is successful (gives correct results) before going to the next test.

  3. Set UseParallel to 'always', and open matlabpool. Unless you have a multicore processor or a network set up, you won't see any speedup. This testing is simply to verify the correctness of the computations.

Remember to call your solver using an options structure to test or use parallel functionality.

  


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