Sunteți pe pagina 1din 5

AAE 550, FALL 2019

H OM EWO RK #0, P AGE 1

AAE 550 MULTIDISCIPLINARY DESIGN OPTIMIZATION


FALL 2019

HOMEWORK ASSIGNMENT #0
DUE SEPTEMBER 4, 2019

The following problems will reinforce some computer skills needed to complete subsequent homework problems,
while also introducing features of Blackboard (http://www.itap.purdue.edu/tlt/blackboard/).

If you are unfamiliar with MATLAB or any of the functions used here, please refer to the “MATLAB Primer” posed
on the Blackboard site. In addition to the MATLAB Primer, the on-line MATLAB tutorial located at the Mathworks
web site (http://www.mathworks.com/academia/student_center/tutorials/launchpad.html) provides help for beginners.

If you are unfamiliar with Microsoft Excel, the on-line training from Microsoft may be helpful. Help for Excel 2013
is available here (http://office.microsoft.com/en-us/excel-help/training-courses-for-excel-2013-HA104032083.aspx).
Help for Excel 2016 is available here (https://support.office.com/en-us/article/Need-Help-with-Office-2016-
bde11048-255e-44f7-85b3-d2470cb68310).

If you want to use MATLAB or Microsoft Excel and do not have it installed on your computer, you can use Purdue
ITAP’s “software remote” (http://goremote.itap.purdue.edu/to access both of these programs.

This homework will not be included in the calculations of your final grade, but all students must submit their response
by the 11:59pm (Eastern Daylight Time) on September 4, 2019 to successfully complete the course. Please take this
opportunity to practice delivering the homeworks in an acceptable format – we will provide feedback in this regard
on your “graded” homework 0 – to mitigate the potential for lost points on future homeworks that count towards your
final grade.

If you are having troubles with this assignment, please contact one of the teaching assistants or the instructor right
away.

SUBMITTING HOMEWORK

The written homework assignments will generally consist of one (or more) “engineering” problem(s). These problems
will apply techniques learned in class to problems that are similar to, but much simpler than, optimization problems
encountered in the “real world”.

Fully substantiated solutions will be required for these problems (e.g. show your work, code, figures, etc.). These
should be typed or your work scanned into a file. We greatly prefer Adobe Acrobat compatible files (*.pdf). PDF
files can be generated from Microsoft Word Documents by selecting Save As PDF. These files will then be uploaded
onto Blackboard under the homework link before the due date (be sure to click both the ‘upload file’ and ‘submit’
buttons). Include your name on the document. While the Blackboard site will keep track of your assignment,
occasionally, the TAs or the instructor will print a hard copy of your submittal to grade.

Late homework will only be accepted if prior approval is obtained from the instructor at least three business
days before the due date.

HOMEWORK FORMAT

Submitted homework should follow this basic format:


1) brief problem statement,
2) problem development and analysis,
3) results (use a tabular format, do not simply cut/paste a screen dump of MATLAB output into your document),
4) any required discussion of results, and finally

©Prof William A. Crossley, Purdue University, 2019


AAE 550, FALL 2019
H OM EWO RK #0, P AGE 2

5) all code written for the problem (this includes scripts that you modified from examples provided by the instructor;
this demonstrates that the work you did modifying these scripts is, in fact, your own).
If you hand-write and then scan your work into a document, be sure all work is clearly legible; no credit will be given
otherwise. Again, be sure that your name is clearly prominent in the file that you upload to Blackboard. All work
and solutions must be in one document file. When grading, the TA’s will only look at ONE submission file and
ignore any other attached MATLAB code, Excel sheets, etc.

See the example “Example Homework 0 2019.docx” file available from the Blackboard site for guidance on your
submittal’s content. You should use this as a template for your own submittal for HW 0 and for subsequent submittals.

Important note: Matlab code snippets/Excel spreadsheets pasted in the report shows that you have completed the work
yourself. Responses to questions in the problem statement should be stated in the text/discussion section of the report.
Graders should not be expected to read the code to determine the response.

©Prof William A. Crossley, Purdue University, 2019


AAE 550, FALL 2019
H OM EWO RK #0, P AGE 3

There are four parts for Homework #0. Please complete all questions in all four parts.

I. FUNCTIONS OF ONE VARIABLE

1) Write a MATLAB function file called func_one.m that accepts a single input variable ‘x’, evaluates the
function (1), and returns an output variable ‘f’. MATLAB, by default, uses radians when evaluating the sine
function.
f ( x ) = e-0.25 x cos ( x ) (1)

2) Write a MATLAB script that plots the function f(x) over the domain 0 ≤ x ≤ 3π using the plot command
and func_one.m. Be sure to label all axes and give an appropriate title; add labels either via commands
in your script or via the menus in the MATLAB figure window.

3) Create a formula in Excel that computes the value of f(x) in one cell that uses a value of x from another cell
as input. Excel also uses radians when evaluating the sine function.

4) Repeat question 2) using the chart tool in Excel. You should create a table of x and f(x) values that can be
used by the chart tool. Create the plot as an “XY scatter” plot, and connect the points you computed in the
table with an interpolating curve.

II. FUNCTIONS OF TWO VARIABLES

1) Write a MATLAB function file called func_two.m that accepts a vector ‘x’ that contains values of x1 and
x2, evaluates the function (2), and returns an output variable ‘f’.
f ( x ) = x13 + 2x22 - 2x1 - 3x2 (2)
The class02func.m file provides an example of a MATLAB function file that computes a value for a
function of two-variables.

2) Using the surf command and your func_two.m function, write a script file that plots the function over
the following region: -2 ≤ xi ≤ 6. Also, using the contour and clabel commands, plot a series of contours
with labels of the function values. Again, be sure to label all axes and give an appropriate title.

The contour_problem.m file provides an example that includes a labeled contour plot of a function of
two variables, where the function is evaluated using the class02func function in the class02func.m
file. The contour_problem.m file also plots two additional functions on the same figure; for this part,
only the contours of f(x) in equation (2) should appear in the plot.

3) Repeat question 1) by creating a formula in Excel that computes the value of f(x) in one cell given a value of
x1 and x2 from two other cells as input.

4) Repeat question 2) using the chart tool in Excel. You should now generate a series of evenly spaced x1 values
in a row and a series of evenly spaced x2 values in a column so that this defines the outside of a region in
your spreadsheet. Then, write the function so that the value of a cell inside this defined region is a function
of the x1 value in the row at the top of the region and of the x2 value in the column at the left of the region.
Create the plot as a “surface” plot. Then, make a copy of the graph and change the chart type to show this as
a wireframe contour plot.

The contour_example.xls and contour_example.xlsx files contain a worksheet that computes


values of a two-variable function to generate a surface plot and as a contour plot or wireframe contour plot.
Because of how Excel creates the surface plot, the data defining x1 and x2 must be available in evenly spaced
increments.

©Prof William A. Crossley, Purdue University, 2019


AAE 550, FALL 2019
H OM EWO RK #0, P AGE 4

III. GRAPHICAL SOLUTION OF AN OPTIMIZATION PROBLEM


It is difficult to superpose multiple contour plots in Excel; however, MATLAB makes this comparatively easy.
For this part of the homework, you use the file func_two.m that you created in part II above.

1) A simple optimization problem with two variables can be expressed as:


Minimize f ( x ) = x13 + 2x22 - 2x1 - 3x2 (3)
Subject to: x1 + 3x2 ³ 6 (4)
x1 ³ 1
Convert the constraints into functions gi(x) ≤ 0.

2) Write a MATLAB function file cons_three.m that computes the values of g1(x) and g2(x) and returns
these in a single MATLAB vector g.

The contour_problem.m file plots the example function along with two constraint functions on the same
figure. The class02cons.m file computes these two example constraint functions.

3) Use your script from part II that creates contour plots of f(x) over the region: -2 ≤ xi ≤ 6. Add commands to
this file that add the contours of g1(x) ≤ 0 and g2(x) ≤ 0. Be sure to use the “hold on” command to allow
this; see the contour_problem.m file for assistance. Generate this contour plot. Identify the optimum
design x* from this graph.

IV. USING MATLAB’S OPTIMIZATION TOOLBOX GRAPHICAL USER INTERFACE


This part of Homework 0 introduces the new Optimization Toolbox Graphical User Interface (available with
version 5.0 of the Optimization Toolbox). Using this feature is not required for the course, but it might prove
helpful for some students. If you do not have version 5.0 of the optimization toolbox, please respond to this part
of the homework using MATLAB from the ITaP Software Remote (http://goremote.itap.purdue.edu/)

The problem presented here is a multivariable, nonlinear, constrained minimization problem; so many details of
the solution algorithm do not appear here. These details of the Sequential Quadratic Programming (SQP)
algorithm will be covered later in the 550 class lectures; the focus here is to have you become familiar with the
GUI.

To start the Optimization Toolset GUI, simply type optimtool in the MATLAB prompt.

In part III, the optimum design x* was visually identified using a contour plot. In this part, you will find the exact
solution to the minimization problem in part III.

1) Since the objective function is nonlinear and constrained, the function fmincon will be used to solve the
problem. The two constraints presented in part III are linear, and SQP handles linear constraints in the form
of a system of linear equations, Ax ≤ b. Because the constraints in part III appear using “≥”, convert the
constraints into the form for Ax ≤ b.

Note that fmincon uses the “trust-region-reflective” algorithm as default in MATLAB 2013, whereas
MATLAB 2014 uses “interior-point.” This shouldn’t pose a problem as we ask you to use “SQP” instead.

©Prof William A. Crossley, Purdue University, 2019


AAE 550, FALL 2019
H OM EWO RK #0, P AGE 5

2) Setup the optimization problem in optimtool using the following settings:


In left hand pane:
Solver: “fmincon – Constrained nonlinear minimization”
Algorithm: “SQP”
Objective function: “@func_two”
Derivatives: “Approximated by solver”
Start point: Select a starting point with x1 and x2 between -2 and 6. Enter in form of “[x1, x2]”
Linear inequalities: A = A matrix from previous question (2x2). Enter as “[a11, a12; a21, a22]”
b = b vector from previous question (2x1). Enter as “[b1; b2]”
Bounds: Lower: “[-2, -2]”, Upper: “[6, 6]”
Derivatives: “Approximated by solver”

In right hand pane:


Leave all defaults set as they are, but in the last section, select Level of Display = “iterative with
detailed message”

Take a screenshot of the configured GUI. One way to do this is to press Ctrl-Print Screen, and then paste the
picture into your homework file.

3) Solve the problem by pressing the start button. The design variable values for the optimal solution appear
under the results dialog. What is the optimal solution to the minimization problem, including the objective
function value? How does this result compare to the solution from visual inspection of the contour plot in
part III of the homework?

4) After solving the problem, export the results to the workspace by selecting File à Export to Workspace and
select “Export results to a MATLAB Structure named:” (You may change the default structure name if you
desire.) This structure contains valuable information that is required for future homework.

What is the value of “exitflag” reported back from fmincon?


How many iterations and function evaluations did fmincon take to find the optimal solution? (Look in
optimresults.output)
What was the final value of the gradient vector of the objective function? (Look in optimresults.grad)

©Prof William A. Crossley, Purdue University, 2019

S-ar putea să vă placă și