File Exchange Pick of the Week

Our best user submissions

MATLAB Parallel Cloud

Sean's pick this week is MATLAB Parallel Cloud by MathWorks Parallel Computing Toolbox Team.   Note: With the release of R2016a on March 3rd 2016, MATLAB Parallel Cloud has been removed from the File Exchange and is now part of the Parallel Computing Toolbox product.  For more information, please visit the product page:


Have you ever wanted borrow a more powerful computer to finish a certain task or to see how well your code scales? If you have, but do not want to deal with moving your files to another computer or don't have access to another computer with MATLAB, then MATLAB Parallel Cloud is a good option. For just a few dollars per hour, it lets you have access to 16 MATLAB parallel workers (headless MATLAB engines) on 16 physical cores on a machine running on Amazon EC2. My laptop, in comparison, has only a wimpy two cores. MATLAB Parallel Cloud only allows for interactive use of the workers, so you can use parfor, parfeval and spmd just like always. It will not work with batch for totally offloading your work like you could do with the Distributed Computing Server. It's also nice that I don't need to be on my corporate network to use it. If this interests you, you need to be running R2015a or R2015b, be located in North America, and have the Parallel Computing Toolbox installed. Then just download the installer from the File Exchange. Installing requires a credit card which will be billed for every hour of usage. Once you download it, run setupParallelCloud and then test the connection: Now to use it, you just have to switch your default parallel cluster to MATLAB Parallel Cloud. CAUTION As soon as you start the pool, you'll be billed for an hour and again for the next hour 60 minutes later. If you don't think you'll need it for more than an hour, it would be wise to set a pool idle timeout in parallel preferences to make sure you're not paying for unused time. I'd also be sure to always set the default pool back to Local when you're done.


For my example, I'm going to run a nonlinear integer optimization to minimize production cost for a semiconductor manufacturing plant. The model is made in SimEvents, MathWork's discrete event simulation tool that sits on Simulink. Here's a peek at the model: Since I'm working with a Simulink model, I need to load it into each worker's workspace. This is done with spmd, which runs the same command on each worker:
% Open the pool if there is none and supply it with the model
p = gcp;

Now I need to set up the optimization problem. I'll use ga, the genetic algorithm optimizer in the Global Optimization Toolbox, since it can handle integer constraints. Here we will be optimizing the time between starting new lots, the number of human operators, and how many lots can be held at once.
% Options, the important one is  'UseParallel' which will evaluate the
% individuals in parallel on the available workers.
opts = gaoptimset('PlotFcns',{@gaplotbestf; @gaplotbestindiv},...
                  'Generations',20, 'StallGenLimit', 10, ...
                  'PopulationSize',25, 'EliteCount',1, ...
                  'UseParallel', true);

% Lower and upper bounds on variables.
% All variables must be integers
lb = [50 1 10];
ub = [1000 5 3000];
IntCon = [1 2 3];

% Execute genetic algorithm solver.  productionCcost calculates the final
% production cost after running the model with the given parameters.
finalResult = ga(@productionCost,3,[],[],[],[],lb,ub,[],IntCon,opts);

% Report results
disp('Time Between Lots')
disp('Number of Operators')
disp('Holding for Lots')
Optimization terminated: maximum number of generations exceeded.
Time Between Lots

Number of Operators

Holding for Lots

I'm seeing a 10x speedup for the optimization over running it locally in serial.


Do you need to scale up your analysis? If so, what kind of speed-ups or size scaling are you looking for? Give it a try and let us know what you think.

Published with MATLAB® R2015b
  • print
  • send email


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.