Question

In: Computer Science

Truck Loading Problem Description: You seek to select most profitable collection of items that you can...

Truck Loading Problem Description: You seek to select most profitable collection of items that you can transport on a truck. Each item has a profit and a weight associated with it, and the truck has a maximum weight limit that cannot be exceeded. Inputs:  profit[], an array of non-negative floating point numbers, where the i th entry in the array corresponds to the value of the i th item  weights[], an array of non-negative integers, where weights[i] equals the size of the i th item  limit, the maximum weight limit for the truck Return: select[], an array of values, where the i th entry in the array is 1 if i th item is included in the collection of items to be loaded, and 0 otherwise. The values in the select[] array are ones that maximize the profit, where: ?????? = ∑ ??????[?] ∙ ??????[?] ?−1 ?=0 Subject to the constraints: ∑ ??????[?] ∙ ????ℎ??[?] ≤ ????? ?−1 ?=0 ??????[?] ∈ {0,1} Consider the following heuristics (rules) used in selecting the next component in greedy algorithms. Would the resulting algorithm be correct? Justify your answers. (5 points each) 1a. Earliest item first (select the item with the smallest index in the weight and profit arrays, subject to the limit constraint). 1b. Lightest item first (select the lightest of the remaining items, subject to the limit constraint). 1c. Heaviest item first (select the heaviest of the remaining items, subject to the limit constraint). 1d. Highest value item first (select the item with the largest value of the remaining items, which would not violate the limit constraint). 1e. Lowest value item first (select the item with the smallest value of the remaining items, which would not violate the limit constraint). 1e. Highest value per pound first (select the item with the largest ratio of profit to weight, from the collection of items that would not violate the limit constraint). 1f. Highest weight per value first (select the item with the largest ratio of weight to profit, from the collection of items that would not violate the limit constraint).

Truck Loading Problem for Sand Delivery Company Description: You seek to select most profitable collection of sand that you can transport on a truck. As before, each type of sand has a profit and a weight associated with it, and the truck has a maximum weight limit that cannot be exceeded. However, you can choose to load just a portion of a type of sand on the truck. Inputs:  profit[], an array of non-negative floating point numbers, where the i th entry in the array corresponds to the value of the i th type of sand  weights[], an array of non-negative integers, where weights[i] equals the total amount of the i th type of sand  limit, the maximum weight limit for the truck Return: select[], an array of values, where the i th entry in the array represents the fraction of the i th type of sand that is to be loaded, and 0 if no sand of the i th type of sand is taken. The values in the take[] array are ones that maximize the profit, given by the following expression: ?????? = ∑ ??????[?] ∙ ??????[?] ?−1 ?=0 Subject to the constraints: ∑ ??????[?] ∙ ????ℎ??[?] ≤ ????? ?−1 ?=0 0 ≤ ??????[?] ≤ 1 2a. Write an algorithm (using pseudocode) that provides an efficient solution to this problem. The pseudocode should contain enough detail so that it is possible to analyze the running time and correctness of the algorithm. Note that an efficient algorithm will run in time that is bounded above by a polynomial. (30 points) 2b. Express the worst case time complexity of your algorithm using asymptotic notation. Justify your answer. (5 points) 2c. Prove that your algorithm is correct. (30 points)

Solutions

Expert Solution

1a. Earliest item first (select the item with the smallest index in the weight and profit arrays, subject to the limit constraint).

--> No, As the earliest item in the array may not be the best one to select for eg

itemWeight = [10,2,3,4,5]

valuePerUnit = [1,20,30,40,50]

Clearly, by choosing 10 units of item 1 (assuming that it is still in limit) is no good as profit earned is only 10 (10 units * profit per unit which is 1)

1b. Lightest item first (select the lightest of the remaining items, subject to the limit constraint).

--> Not necessarily true as per the eg below, the lightest article is at index 0 which has a profit of only 1 per unit weight.

itemWeight = [1,2,3,4,5]

valuePerUnit = [1,20,30,40,50]

1c. Heaviest item first (select the heaviest of the remaining items, subject to the limit constraint).

Not necessarily true, similar to explanation in 1b

1d. Highest value item first (select the item with the largest value of the remaining items, which would not violate the limit constraint).

--> Not necessarily true as there might be a more optimum solution available.

1e. Lowest value item first (select the item with the smallest value of the remaining items, which would not violate the limit constraint). 1e. Highest value per pound first (select the item with the largest ratio of profit to weight, from the collection of items that would not violate the limit constraint).

--> Clearly not best solution as the goal is to maximize the profit.

1f. Highest weight per value first (select the item with the largest ratio of weight to profit, from the collection of items that would not violate the limit constraint).

--> Clearly the best approach since we select the items which give is maximum profit per unit.

Algorithm:

1) Compute the profitPerUnitWeight for each item and store it in profitPerUnitWeight[], mark each item as unselected i.e

selected[] = 0 for all items

2) Let W denote the total weight that can be put on the truck, do step 3

3) Select the unselected item (item which still has selected[]=0) with highest profitPerUnitWeight

4) If the weight of selected item is less than W, mark the item selected[] = 1 and set W = W - weight of selected item

5) if W>0 and there is atleast 1 unselected item, goto step 3

Clearly, we traverse each entry of a 2D array of size N*W where N is the total number of items and W is the total weight, the run time complexity hence becomes O(nw)


Related Solutions

You have a collection of unique items which all implementComparable. The items need to be...
You have a collection of unique items which all implement Comparable. The items need to be kept sorted at all times. It is important that the items can be queried for as fast as possible. Which Collection is most suitable?TreeMapHashSetTreeSetHashMap
For each of the code description on left, you will select its most appropriate answer from...
For each of the code description on left, you will select its most appropriate answer from the right. There is only one answer to each code description: Group of answer choices A function signature with a function name, its list of parameter types, and its return type.       [ Choose ]            continue statement            float            function declaration            pass by value            double            local...
Problem 6 – For each of the items below provide a brief description of the SIGNIFANCE...
Problem 6 – For each of the items below provide a brief description of the SIGNIFANCE (usefulness/importance). Several sentences for each should be all that you need. a. Identify and a sentence or two reflection for each. The three factors that are used to develop a forecasted required rate of return. b. The significance of the statement of cash flows (don’t just list the three sections) discuss the SIGNIFICANCE (usefulness/importance) c. The Role of Financial Markets
You are the owner of a food truck selling paninis and other lunch items. You have...
You are the owner of a food truck selling paninis and other lunch items. You have been in business for 3 years and your sales are growing at a rate of 20% a year. You still owe $10,000 on your existing truck but based off your research you have determined that you can expand your operations in other areas of the city and make a profit. You have decided to add 2 new food trucks. Here are the financing facts...
2. Suppose you have a collection of n items i1, i2, ..., in with weights w1,...
2. Suppose you have a collection of n items i1, i2, ..., in with weights w1, w2, ..., wn and a bag with capacity W (a) Describe a simple, efficient algorithm to select as many items as possible to fit inside the bag e.g. the maximum cardinality set of items that have weights that sum to at most W. (b) Prove your answer.
Select a business problem that you can learn more about by conducting survey research. You will...
Select a business problem that you can learn more about by conducting survey research. You will create an online survey for all of your classmates to take, so design your projects around the assumption that you are finding out what university-aged students think or feel about the topic. Design the survey so that it can be completed in three to five minutes. Do the following: A.   Create the survey with between 5 and 15 survey questions
A) Do you think leading a health care organization by serving the most profitable customers or...
A) Do you think leading a health care organization by serving the most profitable customers or providing the most profitable services might create health disparities? B) What would be the effects of providing the most profitable services to the most profitable customers on population health?
Cigarette butts, the most littered items in the world, are posing an intractable trash problem for...
Cigarette butts, the most littered items in the world, are posing an intractable trash problem for regulators and tobacco companies:  Throwing them on the ground is a firmly entrenched habit for many smokers.  According to the World Health Organization, the filters in cigarette butts are the biggest source of litter world-wide, including in the U.S.  The filters in the butts are made from cellulose acetate, a form of plastic that takes years to break down once discarded.  Studies show that butts often wash from...
How would you tackle the welfare problem? State the goals you would seek, and explain how...
How would you tackle the welfare problem? State the goals you would seek, and explain how the measures you propose would work to meet those goals.
Imagine you are a shareholder of a company. Select 3 financial items or accounts that are...
Imagine you are a shareholder of a company. Select 3 financial items or accounts that are most important to you. For each item or account, explain why it is important to you.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT