Search for question

options along with the estimated return on investment for each one. You also have a given amount of money to invest. The specific file of investment options you will be given will vary, but you will always have the following 3 pieces of information you can obtain from the file: InvestmentName, Investment Cost, EstimatedReturnOnInvestment For example: Algorithms for Data Science Assignment3 Portfolio Optimization A, 10, 60 B, 20,100 C, 30, 120 Start by putting all your code in a file called portfolio.py. Create a function called loadInvestments that takes in the investmentFilename and returns a list of possible investment options: name, cost, and estimated return. You will be given a file of actual investment options along with specific directions for that file on how to obtain the 3 pieces of information necessary for this assignment. Then make a function called optimizelnvestments that takes the list of possible investments along with the amount of money available to spend. This function should return both the optimal return on investment amount as well as the actual investments selected to achieve this optimal. Implement this function using Dynamic Programming. For Dynamic Programming, one needs a recursive breakdown of the problem. We have a number of possible investments and an amount we are able to spend. At each step we can decide to either include investment x or exclude it. If we include it, then we are left with a smaller problem of finding the optimal with all the possible investments without investment x with a smaller amount we are able to spend (because we purchased investment x). If we exclude it, then we are left with a smaller problem of finding the optimal with all the possible investments without investment x, but with the same amount of money to spend as we had before. A DAC solution could be attempted, but it ends up having too much repeated work. So we will implement our solution with Dynamic Programming. Note that this is a 2D problem (number of investments and amount of money to spend). Thus, we will need a 2D table. The second step is filling in the base-cases. Note that when we don't select any investments, no matter how much money we have to spend (top-row) then we get no return on investment. So this is a natural base-case. The third step is to identify the goal location in the table. This will be the position where we are allowed to include all investments with our full allocation of funds to spend. This will be the lower right corner. The last step in computing any optimal table is to determine the order to fill in the table, keeping in mind that one always needs all the results for the recursive sub-problems available in order to fill in the next location. Once the optimal table is computed, a trace-back table needs to be added to the implementation. This is so we can find the actual investments that produce the optimal. Recall that trace-back tables store the “winning” options at each step and are then used at the end to trace-back through these winning options. Your code should return the optimal return on investment number as well as a list of the investment names used to obtain this optimal number. Note that this is a similar problem to the 0/1 Knapsack problem and you should use that idea to help guide you through your implementation.