Code covered by the BSD License

# Speeding Up Optimization Problems with Parallel Computing

### Stuart Kozola (view profile)

Files from the webinar: Speeding up optimization problems with parallel computing

### Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

motorSystem(x,a,u,alpha)
```function varargout = motorSystem(x,a,u,alpha)
% Motor system design function, couples motor design with conrtrol design

% Copyright 2010 The MathWorks, Inc.
bscale = [122 40 3.94 5.12e-3];

d = x(1:5);
p = x(6:8);
b = x(9:end).*bscale;

[w,cd,ceqd,v] = motorDesign(d,a,b);
[J,cc,ceqc,B] = motorController(p,u,v);

c = [cd cc];
ceq = [ceqd ceqc];

% Add system constraint (B - b <= 0)
c = [c B-b];

%[mx,imx] = max(c)
%% Define Use (Objective or Constraint)
switch nargout
case 1 % objective function
varargout{1} = alpha*w + (1-alpha)*J; % combinded objective
case 2 % constraints
varargout{1} = c;
varargout{2} = ceq;
case {3,4} % objective, constraints, and control outputs
varargout{1} = [w,J];
varargout{2} = c;
varargout{3} = ceq;
varargout{4} = {a,b,u,v,alpha};
end

%% Refrence
% This demo is inspired by "Combined Optimal Design with Application to an
% Electric DC Motor", Julie A. Reyer, Panos Y. Papalambros, Journal of
% Mechanical Design,  Vol 124, June 2002 ```