Beruflich Dokumente
Kultur Dokumente
Thomas Stidsen
1
Learning Objectives
2
Why NLP ?
3
How NLP ?
• In constraints (worst)
4
NLP limitations
5
Warnings
6
• If you have to raise a variable or a param-
eter to a certain value e.g. 2, there are
three possibilities:
µj .
σij .
7
• Problem. Pick an “optimal” portfolio i.e.
how big percentage should be invested in
security 1 and so forth.
• Decision variables xj .
8
• Measure of risk (the variance):
n X
X n
V (x) = σij xixj
i=1 j=1
(1 − β)R(x) − βV (x).
β ∈ [0, 1].
9
Model:
n
P n
P n
P
max (1 − β) µ j xj − β σij xixj
j=1 i=1 j=1
n
P
s.t. xj = 1
j=1
xj ≥ 0
• Why?
10
Efficient Frontier
13
Beta = 0
12
11
10
Return
Beta = 0.5
8
7
Beta = 1
6
0 1 2 3 4 5 6 7 8 9 10
Variance
11
A GAMS model
$Title A Quadratic Programming Model for Portfolio Analysis.
$Ontext
$Offtext
alias (i,j);
/ hardware 8
software 9
show-biz 12
t-bills 7 /
hardware 4 3 -1 0
software 3 6 1 0
show-biz -1 1 10 0
t-bills 0 0 0 0
Variables z
x(i) fraction of portfolio invested in asset i
Positive Variable x;
12
Equations fsum fractions must add to 1.0
obj objective function ;
fsum..
sum(i, x(i)) =e= 1.0 ;
obj..
(1-beta)*sum(i, mean(i)*x(i))
- beta*sum((i,j), x(i)*v(i,j)*x(j)) =e= z;
for(beta=0 to 1 by 0.1,
13
Comments:
• General syntax:
while(condition,
GAMS statements;
);
14
• Program generates a lot of output!
15
Example report
Beta Return Variance
0.00 12.0000 10.0000
0.05 12.0000 10.0000
0.10 12.0000 10.0000
0.15 11.8929 9.3750
0.20 11.2909 6.5091
0.25 10.7818 4.7273
0.30 10.4424 3.8222
0.35 9.8827 2.6768
0.40 9.3284 1.7463
0.45 8.8972 1.1594
0.50 8.5522 0.7761
0.55 8.2700 0.5196
0.60 8.0348 0.3449
0.65 7.8358 0.2250
0.70 7.6652 0.1426
0.75 7.5174 0.0862
0.80 7.3881 0.0485
0.85 7.2739 0.0242
0.90 7.1725 0.0096
0.95 7.0817 0.0021
1.00 7.0000 0.0000
16
How was that created?
GAMS code
* Open a file called results.dat and assign the name
* results_file to it.
put ’Beta’:<10,
’Return’:<>20,
’Variance’:<>20 /;
for(beta=0 to 1 by 0.05,
put beta:<10,
sum(i, mean(i)*x.l(i)):<>20:4,
sum((i,j), x.l(i)*v(i,j)*x.l(j)):<>20:4 /;
);
17
• Text put:
put ’text’:<15
• Numerical put:
put x.l:<>20:5
18
Summary
19