# 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: https://www.mathworks.com/products/parallel-computing/matlab-parallel-cloud/.

### Example

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;

spmd
end
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('Results')
disp('Time Between Lots')
disp(finalResult(1))
disp('Number of Operators')
disp(finalResult(2))
disp('Holding for Lots')
disp(finalResult(3))
Optimization terminated: maximum number of generations exceeded.
Results
Time Between Lots
84

Number of Operators
1

Holding for Lots
13


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