-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest2.cpp
89 lines (75 loc) · 3.62 KB
/
test2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "package.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main (int argc,char *arg[]){
int np=8;
Package *package=new Package(np);
double *price=new double[np];
price[0]= 104.09;
price[1]= 34.88;
price[2]= 33.53;
price[3]= 49.04;
price[4]= 87.08;
price[5]= 54.51;
price[6]= 83.05;
price[7]= 32.57;
package->setPrice(price);
double *w_walk_lb=new double[np];
w_walk_lb[0]=0.05;
w_walk_lb[1]=0.05;
w_walk_lb[2]=0.05;
w_walk_lb[3]=0.0;
w_walk_lb[4]=0.05;
w_walk_lb[5]=0.05;
w_walk_lb[6]=0.05;
w_walk_lb[7]=0.05;
package->setLb(w_walk_lb);
double *w_walk_ub=new double[np];
w_walk_ub[0]=0.4;
w_walk_ub[1]=0.4;
w_walk_ub[2]=0.4;
w_walk_ub[3]=0.4;
w_walk_ub[4]=0.4;
w_walk_ub[5]=0.4;
w_walk_ub[6]=0.4;
w_walk_ub[7]=0.4;
package->setUb(w_walk_ub);
double *revenue_weight=new double[np]{0.0021532084194948575, 7.475738493503719E-4, -0.006326840321119702, 1.2386054562314402E-4, 0.0011076249589600004, 9.778069429387285E-4, 0.0026140588361591734, 0.0011475750683716931};
package->setRevenue(revenue_weight);
double *risk_weight=new double[np*np]{
4.1067985538413934E-4, 3.907075502328885E-4, 0.0013062323808480131, 7.735662410732668E-6, -1.1913970711014461E-5, -1.0174725175322413E-5, 3.4813213480351635E-4, 4.576893690584706E-4,
3.9070755023288845E-4, 4.980370896229549E-4, 0.001513817137052966, 1.1699173768480222E-5, -9.542461024679097E-6, -1.4393811000831372E-5, 3.456790153355711E-4, 5.715494965920865E-4,
0.0013062323808480131, 0.0015138171370529662, 0.04958201978191183, 7.684132301858718E-5, 1.1367509755177182E-4, -1.9702229531360643E-5, 8.827622707034841E-4, 0.0026399487149149346,
7.735662410732667E-6, 1.1699173768480224E-5, 7.684132301858717E-5, 2.4624148670171226E-5, 3.07984244815917E-5, 8.048000897627799E-6, 5.8710295576385835E-5, 3.0988867325667597E-6,
-1.1913970711014461E-5, -9.542461024679098E-6, 1.1367509755177181E-4, 3.07984244815917E-5, 9.202487363548772E-5, 2.862862120817286E-5, 1.4124648511060727E-4, -2.5535310365541127E-5,
-1.0174725175322411E-5, -1.4393811000831372E-5, -1.9702229531360646E-5, 8.048000897627799E-6, 2.862862120817286E-5, 2.0301514048952664E-5, 4.325400833141057E-5, -2.1909014009757933E-5,
3.4813213480351635E-4, 3.456790153355711E-4, 8.827622707034841E-4, 5.8710295576385835E-5, 1.4124648511060727E-4, 4.325400833141057E-5, 0.0010310818434250437, 3.579261165328639E-4,
4.5768936905847063E-4, 5.715494965920865E-4, 0.002639948714914934, 3.0988867325667597E-6, -2.5535310365541127E-5, -2.1909014009757936E-5, 3.579261165328639E-4, 0.0013533114981784528
};
package->setRisk(risk_weight);
double *w_original=new double[np];
w_original[0]= 0.05957734885559657;
w_original[1]= 0.04765414459188403;
w_original[2]= 0.043177060336855956;
w_original[3]= 0.2726055246781877;
w_original[4]= 0.052109103799610694;
w_original[5]= 0.4144245107929405;
w_original[6]= 0.0607072545271851;
w_original[7]= 0.0496086989099577;
double assets=11002.3282;
double *out_weight=new double[np];
package->run(assets,w_original,out_weight,true);
for(int i=0;i<np;i++)
cout<<out_weight[i]<<" ";
cout<<std::endl;
delete []out_weight;
delete []w_original;
delete []price;
delete []w_walk_lb;
delete []w_walk_ub;
delete []revenue_weight;
delete []risk_weight;
delete package;
}