Вы находитесь на странице: 1из 5

Script for DC Motor Design Optimization

Open the script Demo3_optimMotorDesign.m. This will walk you through the demo.

Note1: Ive used the AEG cluster with 16 workers for this example, you will have to
change this script file, and reference the cluster you plan to use.

Note2: There is a eigs function in motorDesign.m (at the bottom) that you can use the
make the problem more/less expensive to run if your resources are different.

This script contains the MATLAB commands Im going to use to show how to
perform a multi-level optimization problem.
The first cell defines the Motor design parameters in d, and a scaling dscale that
Ill use to scale the optimization problem to have similar magnitudes in the design
variables. Execute cell
This next cell defines the operating parameters of the motor, recall these are
coupled to the control design function. Execute cell
Next Ill define the constants used in the problem. Execute cell
And well start by solving for the optimal design with the operating conditions
given in b. Execute cell
This gives a good starting point to use when we solve both the design and control
problems together.
This next cell defines the initial parameters for the PID control design. Note that
the input to the function motorController, v, is an output from the motorDesign
function. Execute cell
The plot shows the how the control design performs. We now want to optimize
both the motor design and the PID design simultaneously. This next cell calls the
motorSystem function which couples the motorDesign function to the
motorController function. Execute cell


And if when we run the optimization problem on a single worker we get an
execution time of around 6 seconds. Execute cell


Execute cell Running the same problem with 4 workers reduces the time to



Now lets run multiple optimization problems to map the Pareto front. This next
cell will run the problem over 10 different values for the weight, alpha, on a
single worker.
Execute cell. This will take about 5 minutes.So have something to talk
about.Go back to the slides and explain whats going on with the tasks
flowchart

You can see the result in the figure window that shows the trade off. As the
motor gets heavier, larger armature winding, the response time (or performance
index), is relatively constant. As the motor gets lighter (smaller armature
winding), the controller performance degrades (becomes limited by the electrical
power supplied to meet performance goals).



Lets simply rerun this using parfor in place of the for loop and 4 workers (the
number of optimization problems).

Notice that I have a parfor loop, and the optimization option useParallel is set to
never. Inside the optimization solver, it is using a parfor loop to accelerate the
gradient estimation step when this is set to always. I cant have a nested parfor
loop, so even if I enabled useParallel it would only use the first parfor statement,
this loop you see here.
The reason why nested parfor loops arent allowed is that there is no automated
way to determine how each loop should allocate workers. But we can do this
manually using creatematlabpooljob and parfor (or useParallel option).
Now lets run this in parallel using jobs/tasks and the built in useParallel option in
the optimization solver.
This next cell defines the job and creates the tasks, which are to solve the
optimization problem as a task.
Open motorOptimizationTask.m
And the task itself is opening a matlabpool with nLabs (well use 4).
Now well create the job and task. You can see its in the queue.
And use submit to run the job and wait for results.


You can see that the additional benefit is diminishing. But keep in mind that this
example isnt that computationally expensive, and if your problems take longer,
or have more dimensions, you could see even greater speed up.

Return to slides

Вам также может понравиться