1 answer

You're in charge of running a scientific program (job) that simulates a physical system for as ma...

Question:

Youre in charge of running a scientific program (job) that simulates a physical system for as many discrete steps as you can

You're in charge of running a scientific program (job) that simulates a physical system for as many discrete steps as you can. The lab you're working in has two large supercomputers, which we'll call A and B, which are capable of processing this job. However, you're not one of the high-priority users of these supercomputers, so at any given point in time, you're only able to use as many spare cycles as these machines have available. Here's the problem you face. Your job can only run on one of the machines at any given minute. Over each of the next n minutes, you have a "profile" of how much processing power is available on each machine In minute i you would be able to run ai> 0 steps of the simulation if your job is on machine A, and b, > 0steps of the simulation if your job is on machine B. You also have the ability to move your job from one machine to the other; but doing this costs you a minute of time in which no processing is done on your job. So, given a sequence of n minutes, a plan is specified by a choice of A, B, or "move" for each minute, with the property that choices A and B cannot appear in consecutive minutes. For example, if your job is on machine A in minute i, and you want to switch to machine B, then your choice for minute i+1 must be move, and then your choice for minute i+2 can be B. The value of a plan is the total number of simulation steps that you manage to execute over the n minutes: so it's the sum of ai over all minutes in which the job is in A, plus the sum of b over all minutes in which the job is onB The Problem: Given values a,a an and b,b. .bn find a plan of maximum value. Note that your plan can start at either of the machines A and B in minute 1. Example: Suppose n 4, and the values of a, and bi are given by the following table. Minute 1 10 Minute 2 Minute 3 Minute 4 10 20 20 Then the plan of maximum value would be to choose A for minute 1 then move to minute 2, and then B for minute 3 and 4. The value of this plan would be 10+0+20+20 50 (a) [10 pts Letthe maximum value of any plan that ends at Machine A at the end of the k-th minute Similarly, letthe maximum value of any plan that ends at Machine A at the end of the k-th minute. Write recursive formulas for and (b) [10 pts] Write an algorithm, in pseudo code, that returns the value of the best plan that ends at the n-th minute. The input to your algorithm should be integer arrays a[ ] and bl1, where for eachi- 1ton, old a and

Answers

a.) let V(A,k) denote the maximum value of any plan that ends at machine A at the end of kth minute and let V(B,k) denote the maximum value of any plan that ends at machine B at the end of kth minute.

Now, if any plan ends at machine A at the end of kth sec, then at the end of k-1th second, it could be at machine A or machine B. if there is a simple shift from machine A at the end of k-1th sec to machine A itself, then a[k] is added to the max value plan and if there is a move from machine B to machine A at the end of k-1th sec, then the max value plan remains same(equal to max value plan after k-1th sec) after the kth sec as well since kth sec is utilized in moving.

Hence, we can derive the recurrence relation from this observation as below:-

V(A,k) = max( V(A,k-1) + a[k], V(B,k-1) )

similar explanation can be given for V(B,k) as well and thus the recurrence relation would be

V(B,k) = max( V(B,k-1) + b[k], V(A,k-1) )

  

b.) pseudo code for finding max value plan after nth sec:-

###this is a recursive code:-

max_plan(a[ ], b[ ], n){

// this is base case. if n = 1, it tells that we are at starting point and need to choose the max value from a[1] and b[1]

if( n == 1 ){

return max( a[1], b[1] )

}

// recursive calls

max_A = max( max_plan(a[ ], b[ ], n-1) + a[n], max_plan(b[ ], a[ ], n-1)

  max_B = max( max_plan(b[ ], a[ ], n-1) + b[n], max_plan(a[ ], b[ ], n-1)

// final result

return max( max_A, max_B )

}

.

Similar Solved Questions

1 answer
The graphs below show the force applied to a 250 g cart and the resulting motion....
The graphs below show the force applied to a 250 g cart and the resulting motion. a)How much work was done on the car? b)How much thermal energy was produced (i.e. how much energy was dissipated by friction) Forie v 1o is 2o 2s 3035...
1 answer
Why does a new DNA strand elongate only in the 5' to 3' direction during DNA...
Why does a new DNA strand elongate only in the 5' to 3' direction during DNA replication? The polarity of the DNA molecule prevents addition of nucleotides at the 3' en Replication must progress toward the replication fork. DNA polymerase can add nucleotides only to the free 3' end. ...
1 answer
Suppose that 1,000 people are surveyed regarding their valuation of the benefits of a proposed project...
Suppose that 1,000 people are surveyed regarding their valuation of the benefits of a proposed project to remediate a former industrial site - that is, to remove some of the contaminants from the site, and to make the site suitable for some other use. The actual cost of clean-up is equal to $4 per p...
1 answer
Personal Computer Industry Market Shares Assume the following correctly shows the market shares o...
Personal Computer Industry Market Shares Assume the following correctly shows the market shares of the five firms in the market: Firm Market Share ---------- --------------------- Dell 50% HP 30% Gateway 9% Toshiba 6% Apple 5% ------- 100% Refer to Figure 3-5, above. What is...
1 answer
4. (20 pts) A rapid mixing basin is designed to process 3.0 MGD of water. The...
4. (20 pts) A rapid mixing basin is designed to process 3.0 MGD of water. The basins will be square, and the depth is assumed to be 1.times of the width. Use a detention time of 30 s and velocity gradient of 750 s'. Two basins will be constructed each having a capacity to process exactly half th...
1 answer
Given GH domain 与 3 p
Given GH domain 与 3 p Given GH domain 与 3 p...
1 answer
Question 9 10 pts U.S. Corporate Tax Rate Schedule Taxable income (in $) Marginal Tax Rate...
Question 9 10 pts U.S. Corporate Tax Rate Schedule Taxable income (in $) Marginal Tax Rate 0 - 50,000 15% 50.000 - 75,000 25% 75,000 100.000 34% 100,000 335.000 39% 335.000 10,000,000 34% 10,000,000 15,000,000 35% 38% 15.000.000 - 18.333,333 35% 18 333,333 Based on the US. Corporate Tax Rate Schedul...
1 answer
Two cars are driving in the same direction from the same place. If one travels at 50 mph and the other at 58 mph, how long will it take them to be 40 miles apart?
Two cars are driving in the same direction from the same place. If one travels at 50 mph and the other at 58 mph, how long will it take them to be 40 miles apart?...
1 answer
An investment earning simple interest rate of 1.10% per annum for a term of 5 years earned 82.50 in interest
An investment earning simple interest rate of 1.10% per annum for a term of 5 years earned 82.50 in interest. What was the principal?...
1 answer
For the directed weighted graph given below find shortest distances and shortest paths from A to...
For the directed weighted graph given below find shortest distances and shortest paths from A to all other vertices. Use the Dijkstra algorithm. Show the status of the array of distances after each iteration of the while loop. 2-1 C ) 泊 H e- 90油 2 2 22 (4-21由121回 G...
1 answer
Brief Exercise 17-03 The following T-account is a summary of the Cash account of Cuellar Company....
Brief Exercise 17-03 The following T-account is a summary of the Cash account of Cuellar Company. Cash (Summary Form) Balance, Jan. 1 7,000 Receipts from customers 368,600 Payments for goods Dividends on stock investments 5,400 Payments for operating expenses Proceeds from sale of equipment 36,000 I...
1 answer
2 H2 + O2 → 2 H2O How many grams of H2O are produced from 284...
2 H2 + O2 → 2 H2O How many grams of H2O are produced from 284 grams of H2?...
1 answer
EXAM 3B 1. The Carnot heat engine receives 6500 kJ/h of heat from a boiler at...
EXAM 3B 1. The Carnot heat engine receives 6500 kJ/h of heat from a boiler at 950 °C and rejects the waste heat to a well at 20°C. The produced power output of heat engine is fully used to operate the heat pump that draws the heat from the outdoor environment and transfers it to warm the hou...
1 answer
If an antigen mutates, will the same lymphocytes recognize it? Why or why not? 5. HIV...
If an antigen mutates, will the same lymphocytes recognize it? Why or why not? 5. HIV (the virus that causes AIDS) specifically targets the helper T-lymphocytes, causing the destruction of these cells. Given the role of helper T-lymphocytes, why does this disease increase a person’s susceptibi...
1 answer
How many molecules of water are made from the reaction of 15 moles of HCl with...
How many molecules of water are made from the reaction of 15 moles of HCl with excess oxygen? Given the reaction: 4 HCI + O2-2 H20 + 2Cl2 9.0 x 1025 6.2x 10-24 4.5 x 1024 5.0 x 10-23 3.6 x 1025 2.3x1024 1.8 x 1025...
1 answer
YIELD TO MATURITY A firm's bonds have a maturity of 14 years with a $1,000 face...
YIELD TO MATURITY A firm's bonds have a maturity of 14 years with a $1,000 face value, have an 11% semiannual coupon, are callable in 7 years at $1,224, and currently sell at a price of $1,386. a. What is their nominal yield to maturity? Do not round intermediate calculations. Round your answer ...
1 answer
2. Using the core (Rn) determine the electronic configuration of the following actinides or actinide cations...
2. Using the core (Rn) determine the electronic configuration of the following actinides or actinide cations . U = • U+ = UO,2- Pu 111111 Pu4 Am Am 3+ • Th = . CP+ =...
1 answer
Now damping is introduced and the angle θ is given by the equation: θ-ae" cos(or + φ). It is observed that after one hour the maximum angle of the pendulum has reduced to 0.122 rad due to the dam...
Now damping is introduced and the angle θ is given by the equation: θ-ae" cos(or + φ). It is observed that after one hour the maximum angle of the pendulum has reduced to 0.122 rad due to the damping force. e. (6) Calculate the coefficient α . Now damping is introduced and...