Job Selection Problem – Loss Minimization Strategy | Set 2
We have discussed one loss minimization strategy before: Job Sequencing Problem – Loss Minimization. In this article, we will look at another strategy that applies to a slightly different problem.
We are given a sequence of N goods of production numbered from 1 to N. Each good has a volume denoted by (Vi). The constraint is that once a good has been completed its volume starts decaying at a fixed percentage (P) per day. All goods decay at the same rate and further each good takes one day to complete.
We are required to find the order in which the goods should be produced so that the overall volume of goods is maximized.
Input: 4, 2, 151, 15, 1, 52, 12 and P = 10% Output: 222.503
Solution: In the optimum sequence of jobs, the total volume of goods left at the end of all jobs is 222.503
Input: 3, 1, 41, 52, 15, 4, 1, 63, 12 and P = 20% Output: 145.742
Solution: In the optimum sequence of jobs the total volume of goods left at the end of all jobs is 145.72
Since this is an optimization problem, we can try to solve this problem by using a greedy algorithm. On each day we make a selection from among the goods that are yet to be produced. Thus, all we need is a local selection criterion or heuristic, which when applied to select the jobs will give us the optimum result.
Instead of trying to maximize the volume, we can also try to minimize the losses. Since the total volume that can be obtained from all goods is also constant, if we minimize the losses we are guaranteed to get the optimum answer.
Now consider any good having volume V
Loss after Day 1: PV
Loss after Day 2: PV + P(1-P)V or V(2P-P^2)
Loss after Day 3: V(2P-P^2) + P(1 – 2P + P^2)V or V(3P – 3P^2 + P^3)
As the day increases the losses to increase. So the trick would be to ensure that the goods are not kept idle after production. Further, since we are required to produce at least one job per day, we should perform low-volume jobs, and then perform high-volume jobs.
This strategy works due to two factors.
- High Volume goods are not kept idle after production.
- As the volume decreases the loss per day too decreases, so for low-volume goods, the losses become negligible after a few days.
So in order to obtain the optimum solution we produce the larger volume goods later on. For the first day select the good with the least volume and produce it. Remove the produced good from the list of goods. For the next day repeat the same. Keep repeating while there are goods left to be produced.
When calculating the total volume at the end of production, keep in mind the good produced on day i, will have
times its volume left. Evidently, the good produced on day N (last day) will have its volume intact since
Step 1: Add all the goods to a min-heap Step 2: Repeat following steps while Queue is not empty Extract the good at the head of the heap Print the good Remove the good from the heap [END OF LOOP] Step 4: End
Below is the implementation of the solution.
1 2 3 4 5 6 7 8 9 10 41.3811
Time Complexity: O(N log N)
Auxiliary Space: O(N)
Please Login to comment...