EGR 103/Fall 2017/Lab 6

From PrattWiki
Revision as of 01:50, 3 October 2017 by DukeEgr93 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The following document is meant as an outline of what is covered in this assignment.

Typographical Errors

None yet!

Specific Problems

Chapra Problem 4.1

The primary goals here are to re-use an iterative solver with a different iterator and to present the information in a table generated for LaTeX by MATLAB.

  • The code on page 94 of the Chapra book, in Figure 4.2, is incredibly useful and important. You will need to have it memorized eventually, but for now focus on understanding how it does what it does.
  • One difference between your code and the code in the book is that your original sol will be set equal to the first input, called a instead of x in your code. This will happen on the line under the comment % initialization
  • One more difference will be on the line where sol gets updated. Make sure you understand where and how the update is happening in the original code with the original iterator, then re-write it for your iterator.
  • The page on MATLAB:LaTeX_Table_Writer really will be helpful; note that the RunDivAvg.m code already has comments where you need to make changes.
  • The section on MATLAB:LaTeX_Table_Writer#Saving_to_a_File will explain what the fopen and fclose functions, as well FID variable, do.

Palm Figure 6.1-2, p. 265

The main goals here are to learn how to put italics and math in labels and titles and how to put text on a plot.

5.4.4 Palm 5.33

The main programming concepts here are creating contour plots and imagesc plots. More information on the former can be found at MATLAB:Contour_Plots

5.4.6 Palm 4.28

This problem expands on making surface plots to using 2-D matrices to solve optimization problems. MATLAB:Plotting_Surfaces and MATLAB:Contour_Plots will be useful in making the plots. The section MATLAB:Plotting_Surfaces#Finding_Minima_and_Maxima_in_2-D will be especially helpful in terms of finding the best location for the distribution center.

When testing your code, best bet is to write code to first calculate the distances between one customer and your grid of points. Make a surface plot of that to see if the distance calculations are 0 at the customer and increase radially from there. You can make a one customer data file by running MakeCustomers and entering 1 as the NetID. Then try to figure out how to get the cost function for just that one customer and plot it. With one customer, you can also try to get the rest of the plots as well as the customer map working. You can also find the ideal location and its cost - it should be where the customer is (which is (-22, 4) using MakeCustomersfor one customer) and the cost should be free.

Once you have figured out one customer, put some thought into the work you need to do for two customers - how are you going to get and store the locations and volumes? What's the best way to get the total cost at each location for two customers? For N customers? Note that with two customers the best location will be at (12, -8) because that grid point happens to be closest to the straight line between the customer at (9,-28) and the customer at (15,11); since the two customers have equal volumes, the optimal location is anywhere along that straight line. You can see this in the contour plot: DistContourTwo.png


Also, Douglas Adams wrote funny books.