Dynamic Programming

Posted on 2006-11-27
Medium Priority
Last Modified: 2011-10-17
Hi all,
         I was trying to analyze the following problem but couldnt get any idea of how the total amount of terabytes can be calculated. Could you please help me in understanding the problem. And let me know the better way to do the (dynamic) program.

         Suppose n=4 and the values of x and s are given by the following table.

           Day1      Day2      Day3      Day4

x      10      1      7      7      
s      8      4      2      1

      The best solution would be to reboot on day2 only; this way, you process 8 terabytes
on day1, then 0 on day2, then 7 on day3, then 4 on day4, for a total of 19.
Note that if you didn't reboot at all, you'd process 8+1+2+1 =12; and other rebooting strategies
give you less than 19 as well.

      Give an efficient algorithm that takes values for x1,x2,x3..........xn and
s1,s2,s3........sn and returns the total number of terabytes processed by an optimal solution.

Thanks & Regards,
Question by:vjonnada
LVL 15

Expert Comment

ID: 18025442
There must be some other information somewhere about what x and s are and what effect rebooting has.  It's not clear enough from what you posted.  If you have this information and can share it, someone here might be able to explain it.  If you don't have it, I think you will have to get it from somewhere other than here.

Author Comment

ID: 18025884
Hi, Here is the complete problem. Can anyone read this and explain me exactly what it is saying, I am not asking you the entire program. Just give me ideas and explain the logic to do this.

Problem Statement:

To run a high performance computing system capable of
processing several terabytes of data per day .For each of n days ,you are
being presented with a quantity of data; on day i ,you’re presented with xi
terabytes .For each terabyte you process ,you receive a fixed revenue, but any
unprocessed data becomes unavailable(i.e expires) at the end of the day and
thus you can not work on it in subsequent days.
   You also can not always process everything each day because you are
constrained by the capabilities of your computing system one-of-a kind software that, while very sophisticated ,is not totally reliable, and so the amount of data you can process goes down with each day that passes since the most recent reboot of the system. On the first day after a reboot, you can process s1 terabytes, on the second day after the reboot ,you can process s2 terabytes ,and so on, up to sn; it is assumed that s1>s2>s3>….>sn>0.Note that on day i you can only process up to xi terabytes, even if the corresponding sj is larger(note the applicable subscripts can be different values).To get the system back to peak performance, you can choose to reboot it; but on any day that you choose to reboot the system, you can not process any data.

•      the xi values(i.e x1,x2,….xn) represent the amount of data available(in terabytes) for processing on day i.
•      the si values(i.e. s1,s2,…..sn) represent the amount of data(in terabytes) that your system can process on the ith day after a reboot.

Program to print:
•      The maximum total amount of data that the system could process( in terabytes).
•      The day numbers on which a reboot should occur. Note that there may well be more than one such day number and days start numbering at 1(not 0).

Thanks & regards,
LVL 15

Accepted Solution

efn earned 1000 total points
ID: 18026244
OK, you have n days and you want to maximize the total output for all n days.  For each day, the output is the lesser of the x value for that day and the capacity for that day.  You are given the x values for all n days.  The capacity is not the s value for that day; instead, the capacity is determined by when you schedule reboots.  For every day, you can either have a reboot or not.  If you do, the capacity for that day is 0, and so the output for that day is also zero.  The capacity for the first day is s1, the capacity for the second day is s2, and so on until a reboot, after which it starts over at s1 again.

So for every day, the reboot decision is a trade-off.  If you reboot, you have no output that day, but you restore maximum capacity for the next day.  If you don't reboot, you can use that day's capacity up to that day's x, but the capacity will be lower the next day.

For n days, there are 2 to the nth power possible reboot schedules.  The simplest algorithm would be just to calculate the output totals for all of them and pick the one with the highest total.  This will not be practical unless n is fairly small, so you will probably have to design a cleverer algorithm.

Some elementary reasoning can reduce the solution space to be searched.  For example, there is no point in rebooting on the last day, since that would just throw away capacity with no benefit.  Similarly, there is no point in rebooting two days in a row.

I don't have a good algorithm for you, but I hope this helps you understand the problem.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 39

Expert Comment

ID: 18027049
>>>> Similarly, there is no point in rebooting two days in a row.

Don't think that is true. Look at the following table:

x     10    1     2    8
s       8    4     2   1

Obviously it is best to reboot at day 2 *and* at day 3 to catch the 8 capacity at day 4.

I don't have a good algorithm either but you could consider to have a loop where you check whether a reboot is good or not. For that check you recursively need to check the next day and maybe some more. If I understand the statement "note the applicable subscripts can be different values" correctly, the number of indices of s is (much) less than that of x. If so, the number of recursive checks is limited by the number of indices of s.

Regards, Alex
LVL 15

Expert Comment

ID: 18033979
> Obviously it is best to reboot at day 2 *and* at day 3 to catch the 8 capacity at day 4.

Somehow this is not obvious to me.  If you reboot on days 2 and 3, your output is 8 + 0 + 0 + 8 = 16.  If you reboot on day 3 only, your output is 8 + 1 + 0 + 8 = 17.
LVL 39

Expert Comment

ID: 18036284
>>>> your output is 8 + 1 + 0 + 8 = 17.

You are right. That means two reboots on a row never is an option.

That reduces the number of possible solutions to 2^(n-1) - (n-1) what - unfortunately - means that checking all possibilities isn't an efficient method for large n.

Regards, Alex

Expert Comment

ID: 21427228
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup Zone:
  Accept: efn {http:#18026244}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Sean Durkin
Experts Exchange Cleanup Volunteer

Expert Comment

ID: 21449013
Forced accept.

EE Admin

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question