Question: CS319 - Scientific Computing Lab 2: An optimization problem (and functions in C++) You will develop an algorithm for solving an optimis- tion problem. This

 CS319 - Scientific Computing Lab 2: An optimization problem (and functions

CS319 - Scientific Computing Lab 2: An optimization problem (and functions in C++) You will develop an algorithm for solving an optimis- tion problem. This will give a context in which to study some of the intricacies of functions in C++, including global and local variables; pass-by-reference functions as arguments to other functions 2. Take c to be the midpoint of a and b. 3. Take I to be the midpoint of the left interval, a,c. andr to be the milpoint of the right interval, 4, 5]. 4. Compare () Fle) and f(r), and if f(c) is largest set a l, and buri . if f() is largest keep a, and set b = c. . if f(n) is largest keep 5, and set a = c. 5. Repeat the algorithm until b-a is less than some prescribed tolerance. The first step is illustrated in Figure 2. In this case, since fle) > >f(r), for the wond step we will set a=! and b=r. 1 Optimization For the purposes of this lab, "optimisation" means find- ing the point at which a given function achieves its max- imum value. Typical optimization problems you might be familiar with include at what speed does my car have the best fuel effi- ciency? . what is the maximum height a ball will reach if thrown with particular initial velocity? The problems can be posed in a mathematical frame- work. We'll take a given function, J. which we call the objective function. We find the value of m that max- imises f in a given interval, [4, 5]. That is, find m such that a le-6) C - (a+b)/2.0; double 1 - (a+c)/2.0, r=(c+b)/2.0: if ( ((c) > f(1)) && (f(c) > f())) Figure 1: A sample objective function else if ( f(1) > f(n)) 2 Algorithm 1: Bisection else We'll first solve this problem using a bisection algorithm: 1. Choose points a and b (where a >f(r), for the wond step we will set a=! and b=r. 1 Optimization For the purposes of this lab, "optimisation" means find- ing the point at which a given function achieves its max- imum value. Typical optimization problems you might be familiar with include at what speed does my car have the best fuel effi- ciency? . what is the maximum height a ball will reach if thrown with particular initial velocity? The problems can be posed in a mathematical frame- work. We'll take a given function, J. which we call the objective function. We find the value of m that max- imises f in a given interval, [4, 5]. That is, find m such that a le-6) C - (a+b)/2.0; double 1 - (a+c)/2.0, r=(c+b)/2.0: if ( ((c) > f(1)) && (f(c) > f())) Figure 1: A sample objective function else if ( f(1) > f(n)) 2 Algorithm 1: Bisection else We'll first solve this problem using a bisection algorithm: 1. Choose points a and b (where a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!