Project Report
Project Report
Report on
Submitted By
This is to certify that Seminar work embodied in this report entitled, “ Portfolio
selection using dynamic Programming ” was carried out by Patel Zalak
(12202110501068) & Akshar Patel (1220211050169), at G H Patel College of
Engineering& Technology for partial fulfilment of B.Tech degree to be awarded by
Charutar Vidya Mandal University (CVMU). This seminar work has been carried out
under my supervision and is to the satisfaction of department.
Date:
Place: G H Patel College of Engineering & Technology
Problem Description:
Given a set of investment options (stocks) with associated returns, risks, and
prices, the task is to:
1. Select Stocks: Based on the user's risk tolerance (low, medium, high) and
budget, choose stocks to invest in.
Include the current stock, reducing the available budget and adding its
profit.
<bits/stdc++.h>using
namespace std;
int knapsack(int profit[], int risk[], int prices[], int budget, int risk_min, int
risk_max, int idx, vector<vector<int>> &dp){
dp[idx][budget] = inc;
} else {
dp[idx][budget] = exc;
return dp[idx][budget];
}
void findSelected(int idx, int budget, int profit[], int prices[], int risk[], int
min, int max, vector<int>& selected,vector<vector<int>> &dp) {
int x = budget;
1][budget]) { selected.push_back(idx -
1);
idx--;
cout<<endl;
void StockSelection(int n,int profit[], int risk[], int prices[], string names[],
int budget, int risk_min, int risk_max,string risk_type){
if (risk_type ==
"high") { risk_min
= 20;
risk_max = 100;
} else if (risk_type ==
risk_max = 20;
} else if (risk_type ==
"low") { risk_min = 5;
risk_max = 15;
} else {
'high'.\n"); return ;
vector<vector<int>>
dp(n+1,vector<int>(budget+1,-1)); vector<int>
selected;
n,dp); findSelected(n,budget,profit,prices,risk,risk_min,
cout<<"index\t"<<"\tName"<<endl;
cout<<selected[i]+1<<"\t:\t" <<
names[selected[i]]<<endl;
int main() {
int n =
20;
int profit[] = {11,14,10,8,14,11,13,16,8,7,13,14,10,11,14,11,8,14,8 ,13};
int prices[] = {200, 500, 300, 150, 400, 250, 350, 600, 180, 120, 350, 420, 220,
300, 550,
280, 310, 640, 150, 280};
int budget;
string risk_type ;
StockSelection(n,profit,risk,prices,names,budget,risk_min,risk_max,risk_type);
return 0;
}
Output