Скачать презентацию Today s topics Java Applications Simulation Upcoming Software Engineering Скачать презентацию Today s topics Java Applications Simulation Upcoming Software Engineering

7318037329f8eacf725d3fcb5d2526ba.ppt

  • Количество слайдов: 14

Today’s topics Java Applications Simulation Upcoming Software Engineering (Chapter 7) Reading Great Ideas, Chapters Today’s topics Java Applications Simulation Upcoming Software Engineering (Chapter 7) Reading Great Ideas, Chapters 6 Comp. Sci 001 19. 1

What does it mean to be human? v Tool User? q v Speech? q What does it mean to be human? v Tool User? q v Speech? q v Some animals (whales? ) seem to communicate by sound Do simulations? q v Some animals use tools ? ? ? Many things we do could be called simulations q q q Drawing a diagram of something to build Using a map to give directions Moveable furniture cutouts on a floor plan Comp. Sci 001 19. 2

Computer Simulation v v As suggested before, can simulate without computer Computer greatly extends Computer Simulation v v As suggested before, can simulate without computer Computer greatly extends the domain q v v What are some of the things made possible by computer simulation? Early efforts: q q q v Nowadays almost everything built is simulated first Fancy camera lenses among first beneficiaries Efficient paths for space ships Population projections in relation to birth control policies Let’s use the computer to find solution to simple problem Comp. Sci 001 19. 3

Dog Lot Fence v Optimize: i. e. , give your dog the biggest lot Dog Lot Fence v Optimize: i. e. , give your dog the biggest lot in the face of constraints q q q Build lot against side of house Fixed length roll of fencing (and posts) Rectangular layout x y v Length of fence is 2*x + y Use program to try different values of x and y q Better than actually trying many layouts with a posthole digger!! Comp. Sci 001 19. 4

Fence public class Fence extends java. applet. Applet implements Action. Listener { Text. Field Fence public class Fence extends java. applet. Applet implements Action. Listener { Text. Field m. Instruct; Label l. Length; Double. Field g. Length; Button b. Simulate, b. Display; Text. Area m. Results; int k; public void init() { l. Length = new Label("Length"); m. Instruct = new Text. Field(70); m. Instruct. set. Text( "Enter length of fence, the press Simulate or Display"); g. Length = new Double. Field(10); b. Simulate = new Button("Simulate"); b. Display = new Button("Display"); m. Results = new Text. Area(25, 60); Comp. Sci 001 19. 5

Fence. 2 b. Simulate. add. Action. Listener(this); b. Display. add. Action. Listener(this); add(m. Instruct); Fence. 2 b. Simulate. add. Action. Listener(this); b. Display. add. Action. Listener(this); add(m. Instruct); add(l. Length); add(g. Length); add(b. Simulate); add(b. Display); add(m. Results); } public void action. Performed(Action. Event event) { Object cause = event. get. Source(); double fence. Length; if (cause == b. Simulate) { fence. Length = g. Length. get. Double(); fence. Table(fence. Length); } if (cause == b. Display) { fence. Length = g. Length. get. Double(); fence. Plot(fence. Length); } } Comp. Sci 001 19. 6

Fence. 3 void fence. Table(double fence. Length) { double area, x, y; x = Fence. 3 void fence. Table(double fence. Length) { double area, x, y; x = 0. 0; y = fence. Length - 2. 0 * x; m. Results. set. Text("Fence Optimization Tablen"); while (y >= 0. 0) { area = x * y; m. Results. append("x = " + x + " y = " + y + " area = " + area + "n"); x = x + 1. 0; y = fence. Length - 2. 0 * x; } } Comp. Sci 001 19. 7

Fence. 4 void fence. Plot(double fence. Length) { double area, x, y; x = Fence. 4 void fence. Plot(double fence. Length) { double area, x, y; x = 0. 0; y = fence. Length - 2. 0 * x; m. Results. set. Text("Fence Optimization Plotn"); while (y >= 0. 0) { area = x * y; m. Results. append(x+"t"+plot. String(area)+"n"); x = x + 1. 0; y = fence. Length - 2. 0 * x; } } String plot. String(double area) { String s = ""; while (area > 0) { s = s + "*"; area = area - 5. 0; } return s; } } Comp. Sci 001 19. 8

Fence Optimization v Output makes it clear how fence should be arranged q q Fence Optimization v Output makes it clear how fence should be arranged q q v Note we eyeballed the output to get answer q q v Not necessarily intuitive (makes simulation useful) (Can use other tricks -- non computer -- to get answer) Could have had computer pick the maximum area Could you sketch that program out? Let’s use slightly different approach; answer not obvious q q q Fix area Minimize amount of fencing used Change scenario a bit o Build into corner o Put in a tree! Comp. Sci 001 19. 9

Fence with Tree x 2 y tree (xt, yt) y 2 x v Program Fence with Tree x 2 y tree (xt, yt) y 2 x v Program a bit more complicated q q Will not go over details However, intuitive methods not likely to work Must use program to get right answer Program is on-line Comp. Sci 001 19. 10

Pitfalls in Automatic Methods v Optimization problems seem straightforward enough q v May involve Pitfalls in Automatic Methods v Optimization problems seem straightforward enough q v May involve many variables q q v Not always the case Exhaustively checking all possible values may take too long Need to intelligently look for optimal solution However, can have local maxima or minima Can lead to wrong answer Sometimes optimal Solution is computationally out of reach q Will come back to that theme at end of semester Comp. Sci 001 19. 11

Simulation in Microelectronics v Modern microchips too complicated to be build without simulation q Simulation in Microelectronics v Modern microchips too complicated to be build without simulation q v One chip takes tens of thousands of dollar to make q q v Additional ones are almost free One error and it’s useless Each much too complex to check by hand q v It take computers to build computers (recursion? ) Modern chips have millions of transistors Every aspect of the process is simulated q q Logic Layout Circuit characteristics Fabrication Process Comp. Sci 001 19. 12

Other Popular Simulation Targets v Games that are Simulations q q q v Graphics Other Popular Simulation Targets v Games that are Simulations q q q v Graphics q q q v Sim. City Flight Simulator Often serious simulation tools make interesting games Many movies now use computer graphics More and more are entirely graphics o Not voices, though! Pioneering: UNC Computer Science Walk-through Virtual Reality q q Headsets Caves Comp. Sci 001 19. 13

Other Popular Simulation Targets v Architecture q q q v Artificial Aging q v Other Popular Simulation Targets v Architecture q q q v Artificial Aging q v Computerized generation of suspect’s face Beauty q v Project what missing child would look like now Police Work q v Models “Walk-through” extensions Design your own kitchen Your image with different hairdos, makeup, etc. Your entry here: ______ Comp. Sci 001 19. 14