Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 123 Computational Lab IIl Spring 2008 Department of Computer Science Drexel University Copyright by the authors. Permission is given for students and.

Similar presentations


Presentation on theme: "CS 123 Computational Lab IIl Spring 2008 Department of Computer Science Drexel University Copyright by the authors. Permission is given for students and."— Presentation transcript:

1 CS 123 Computational Lab IIl Spring 2008 Department of Computer Science Drexel University Copyright by the authors. Permission is given for students and staff of CS 123 Spring 2008 to reproduce these notes for their own use.

2 Calendar ActivityDue Date Lab 1Week 2Week 3 Quiz 1Week 3 Lab 2Week 4 (Apr 20)‏Week 5 (May 3,5:00 PM)‏ Quiz 2Start (Apr 27)‏Week 5 (May 3,5:00 PM)‏ Lab 3Week 6Week 7 Quiz 3Week 7 Lab 4Week 8Week 9 Quiz 4Week 9 Lab exam (in class)‏Week 10

3 QUIZ 1 – server crash and resolution A few people were caught on Friday afternoon when the Maple TA server crashed due to heavy load. A few minutes before that it started giving “bad responses” to user input. For those people, the quiz will be available from Monday 4/21 at 8am to Tuesday 4/22 at 5pm We will give you a quiz score based on the cumulative result of the two quizzes All retake quizzes must be completed/submitted by 5pm on Tuesday. Problems ?! Stop by UC147 on quiz days or discussion threads on Bb!

4 Rules for today’s Lab 1)You should work in a group 2)You don't get credit for the lab until you show a TA or instructor your results from the end of the lab. You can do this at the end of the lab period, or by dropping into the Cyber Learning Center next week. If you do not get "checked in" by a staff member, then you will receive no credit for this lab even if you attended a Lab session.

5 So, What is today’s Lab about? Calculations for a computer controller for a car Last year's winning team from Carnegie Mellon won $2,000,000 for placing first! Computer Control: programming to make decisions about what to do when the car is in various situations.

6 Problems to be solved in autonomous car control When camera input is XXX, and the car is in location/velocity/acceleration (d,v,a) where should it go, how fast should it accelerate? What is the best speed to travel at to minimize fuel cost, hydrocarbon emissions?

7 Implementing a math model for fuel consumption What are we given? Mathematical formulas for fuel and emissions consumption, and a file of numbers for the model coefficients. What do we want ? Ways to calculate fuel consumption, CO emission, HC emission How to get it input data? Implement Maple functions, and check that they work.

8 Math model, continued Step1: Read the input data, convert it to list (revisit old material from CS122 Lab 3)‏ > (Tools -> Assistants -> Import data menu)‏ >ListOfCoefs := convert(%,listlist); Check if you read them in correctly by printing in a table: >tablePrint := proc(LL::list)‏ … complete the procedure >tablePrint(ListOfCoefs);

9 Step 2: Set up the functions Fuel, CO, and HC from the details of the model. You will need to revisit the following Maple ideas: >expr :=... sum(.... exp(.....)..... ); >Fuel := unapply(...., v,a); This will assign Fuel as a function of velocity and acceleration. A problem is that the inputs and outputs of the function are a mishmash of metric and English units. Math modeling, continued

10 Math modelling, continued Step 3 : Create functions FuelEnglish, COEnglish, etc. that use English units (gallons, miles, pounds, etc.) consistently Maple has a way of converting between units that takes advantage of its ability to handle symbolic expressions >convert(5.0, 'units', km, mi);

11 Unit Conversion Convert: convert gets broken if you happen to assign one of the symbols you are using. For example: > s := 47; >convert(5.0, 'units', s, h); --> error ! Set s:=‘s’ to be seconds >unassign(’s’); #Clear residual values from previous problems. we will define functions again with unit conversion Step 4: find the velocity which produces the best fuel economy in an idealized situation -another optimization problem -->NLPSolve

12 Unit conversion in Maple

13 Basic physics: Relating velocity, position and acceleration through integration The group collectively needs to work out how to calculateFuel consumption velocity is an expression given in terms of acceleration. Piecewise acceleration expressions (gears!) needed.

14 Using the fuel consumption model Create a Maple function of fuel consumption in terms of velocity and acceleration FuelEnglish := (v,a) -> expression in v and a Find best fuel consumption by using optimization. Probably will need to use NLPSolve for numerical work. Should do a lot of plots to understand what you're looking at/for.

15 Let’s look at the process of solving an optimization problem once more: Problem: find the velocity which produces the best fuel economy when travelling at a constant speed >time_to_travel_100_miles := 100/v; #v in miles per hour, time in hours >total_fuel := time_to_travel_100_miles*FuelEnglish(v,0); #total fuel consumed, in gallons/hr >plot(total_fuel, v=0..80,view=[0..80,0..10]); Solve the optimization problem that we have formulated: >Optimization[NLPSolve](total_fuel,v=0..100); [1.54533288950136316, [v = 24.2544850971573531]] Answer : minimum consumption is 1.545 gallons; at a velocity of 24.25 mi/h.

16 Lab structure This lab is divided into the following sections: Required Reading: Introduction & Overview, Tutorials 1-3, Wrap-Up Required Problems: Problems 1-10 Optional Problems: Problems 12,11 Remember to do Group CHECK IN !

17 What to turn in?! Lab 2  Due May 3 th,5 P.M Quiz 2  Due May 3 th,5 P.M -Submit your lab via Bb Vista -We have office hours in UC145 next week, if you had any problem in Quiz 2 feel free to stop by and ask questions!


Download ppt "CS 123 Computational Lab IIl Spring 2008 Department of Computer Science Drexel University Copyright by the authors. Permission is given for students and."

Similar presentations


Ads by Google