Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

E+1:41 a submitty.cs.rpi.edu TFW 70 60% Part 1: The Lifeguard Optimal Angle Problem (40 pts) la Homework 1 you created a solution to compute the

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
E+1:41 a submitty.cs.rpi.edu TFW 70 60% Part 1: The Lifeguard Optimal Angle Problem (40 pts) la Homework 1 you created a solution to compute the time it takes for a Ideguard to reach a drowning swimmer. For this assignment, we will extend that conorge to solve an optimization problem by creating two fanctions to compute the angle at which a ldeguard eeds to runm to minimize the time it takes to reach the swimaner. We will then cakate-simple statisti s over a mamber od runs The geometry of the problem shown in Figure isthesae as in Homwk This is a little bit of a different assigntment. Rather than hase ywrite acuepete program, we are going to have you write a module with two functions that we will call to reach a solution. This means that you will nred to pay partienlar attention to how yon write yo functions; both to the parameter lists and to the values returned. On the other hand you are not nequired to have any user interface (UI) code (code that interacts with the user, like calls to input) and printO) We will also provide (in Subenitty) a module called 1ifeguard in file lifeguard.py that has one function, get.response.tine). The function is an implemest ation of the lieguard solution you wrote in Homework 1, Part 1. You will meed to call this function in the code yos write to get the time it takes for the lifeguard to reach the swimmer under different coeditions Figure 1: The lifeguard problem (piture eredit: Mama torets lotitute of Technology. https://ocw.mit edu/courses/sechanical-engineering/2-71-optics-apring-2009/ assignsents/MIT2.710usl1.pdt) See the notes section at the end of this handout for a discussion of testing and for precise definitions of the inputs to and outpats from your functions Computing the optimal angle (30 pts out of 40) Now start writing your code for hu4 part1.py. Create a fanction getoptinalO, that takes two tuples as its parameters. The first is a tuple beach that coatains the parameters from the lifeguard problem and the second parameter is a 3-tuple isterval that eontains a start angle,an end angle and a 'umaher of salliples num samples. The get-egtial() fuaction needs to find the angle that reaches the swiner in the shortest anoant of time by checking mum samples angles beginning at the start angle and stopping at the end angle. This should be compared to the time the lifeguard actually took using the angle in the beach parameter. The fiunction returns a 3-list with the following elements the optimal time, the optimal angle aad the diference between the time the lifeguard actually took and the optimal time An example run of get optina1 (as executed in the Python shell) is peovided below E+1:41 a submitty.cs.rpi.edu TFW 70 60% Part 1: The Lifeguard Optimal Angle Problem (40 pts) la Homework 1 you created a solution to compute the time it takes for a Ideguard to reach a drowning swimmer. For this assignment, we will extend that conorge to solve an optimization problem by creating two fanctions to compute the angle at which a ldeguard eeds to runm to minimize the time it takes to reach the swimaner. We will then cakate-simple statisti s over a mamber od runs The geometry of the problem shown in Figure isthesae as in Homwk This is a little bit of a different assigntment. Rather than hase ywrite acuepete program, we are going to have you write a module with two functions that we will call to reach a solution. This means that you will nred to pay partienlar attention to how yon write yo functions; both to the parameter lists and to the values returned. On the other hand you are not nequired to have any user interface (UI) code (code that interacts with the user, like calls to input) and printO) We will also provide (in Subenitty) a module called 1ifeguard in file lifeguard.py that has one function, get.response.tine). The function is an implemest ation of the lieguard solution you wrote in Homework 1, Part 1. You will meed to call this function in the code yos write to get the time it takes for the lifeguard to reach the swimmer under different coeditions Figure 1: The lifeguard problem (piture eredit: Mama torets lotitute of Technology. https://ocw.mit edu/courses/sechanical-engineering/2-71-optics-apring-2009/ assignsents/MIT2.710usl1.pdt) See the notes section at the end of this handout for a discussion of testing and for precise definitions of the inputs to and outpats from your functions Computing the optimal angle (30 pts out of 40) Now start writing your code for hu4 part1.py. Create a fanction getoptinalO, that takes two tuples as its parameters. The first is a tuple beach that coatains the parameters from the lifeguard problem and the second parameter is a 3-tuple isterval that eontains a start angle,an end angle and a 'umaher of salliples num samples. The get-egtial() fuaction needs to find the angle that reaches the swiner in the shortest anoant of time by checking mum samples angles beginning at the start angle and stopping at the end angle. This should be compared to the time the lifeguard actually took using the angle in the beach parameter. The fiunction returns a 3-list with the following elements the optimal time, the optimal angle aad the diference between the time the lifeguard actually took and the optimal time An example run of get optina1 (as executed in the Python shell) is peovided below

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

3. What might you have done differently

Answered: 1 week ago

Question

4. Did you rethink your decision?

Answered: 1 week ago

Question

3. Did you seek anyones advice?

Answered: 1 week ago