数学建模 之 投资的收益与风险(线性规划)

本文最后更新于 2025年9月19日 星期五 10:48

1998 年全国大学生数学建模竞赛 A 题[1]

线性规划。

符号说明

符号 含义
\(x_i\) 投资到资产 \(i\) 的资金数量
\(r_i\) 资产 \(i\) 的平均收益率
\(q_i\) 资产 \(i\) 的风险损失率
\(p_i\) 资产 \(i\) 的交易费费率
\(u_i\) 资产 \(i\) 的投资阈值(\(i\neq0\))

除特殊说明外,\(i=0,1,\dots,n\)

题目描述

题目给定:\(M\) 为总资金。

\(i\) \(r_i/\%\) \(q_i/\%\) \(p_i/\%\) \(u_i/\) \(1+p_i\) \(r_i-p_i\)
0(银行) 5 0 0 \(\infty\) 1 0.05
1 28 2.5 1 103 1.01 0.27
2 21 1.5 2 198 1.02 0.19
3 23 5.5 4.5 52 1.045 0.185
4 25 2.6 6.5 40 1.065 0.185

模型建立

目标函数:

\[ \begin{cases} \max\sum_{i=0}^n(r_i-p_i)x_i \\ \min\{\max_{1\leq i\leq n}\{q_ix_i\}\} \end{cases} \]

约束条件:

\[ \begin{cases} \sum_{i=0}^n(1+p_i)x_i=M \\ x_i\geq0,\ i=0,1,\dots,n \end{cases} \]

模型一:固定风险水平,优化收益

设风险界限 \(a\)

\[ \begin{gather} \max\sum_{i=0}^n(r_i-p_i)x_i \\ \text{s.t.} \begin{cases} q_ix_i\leq aM,\ i=1,2,\dots,n \\ \sum_{i=0}^n(1+p_i)x_i=M \\ x_i\geq0,\ i=0,1,\dots,n \end{cases} \end{gather} \]

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
clear;
M = 10000;
c = [0.05, 0.27, 0.19, 0.185, 0.185];
Aeq = [1, 1.01, 1.02, 1.045, 1.065];
q = [0.025; 0.015; 0.055; 0.026];
a = 0;
aa = [];
QQ = [];
XX = [];

prob = optimproblem('ObjectiveSense', 'max');
x = optimvar('x', 5, 1, 'LowerBound', 0);
prob.Objective = c * x;
prob.Constraints.con1 = Aeq * x == M;

while a < 0.05
prob.Constraints.con2 = q .* x(2:end) <= a * M;
[sol, Q, flag, out] = solve(prob);
aa = [aa; a];
QQ = [QQ, Q];
XX = [XX; sol.x'];
a = a + 0.001;
end

plot(aa, QQ, '*k')
xlabel('$a$', 'Interpreter', 'latex')
ylabel('$Q$', 'Interpreter', 'latex', 'Rotation', 0)

模型二:固定盈利水平,极小化风险

\(x_{n+1}=\max_{1\leq i\leq n}\{q_ix_i\}\)

\[ \begin{gather} \min x_{n+1} \\ \text{s.t.} \begin{cases} q_ix_i\leq x_{n+1},\ i=1,2,\dots,n \\ \sum_{i=0}^n(r_i-p_i)x_i\geq kM \\ \sum_{i=0}^n(1+p_i)x_i=M \\ x_i\geq0,\ i=0,1,\dots,n \end{cases} \end{gather} \]

\(M=1\)

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
clear;
r = [0.05, 0.28, 0.21, 0.23, 0.25];
p = [0, 0.01, 0.02, 0.045, 0.065];
q = [0.025, 0.015, 0.055, 0.026]';
V = []; %风险初始化
Q = [];
X = [];
k = 0.05;

prob = optimproblem;
x = optimvar('x', 6, 'LowerBound', 0);
prob.Objective = x(6);

while k < 0.26
prob.Constraints.con1 = [q .* x(2:5) <= x(6)
(p - r) * x(1:end - 1) <= -k];
prob.Constraints.con2 = (1 + p) * x(1:end - 1) == 1;
[sol, fval, flag, out] = solve(prob);
xx = sol.x;
V = [V, max(q .* xx(2:end - 1))];
X = [X; xx'];
Q = [Q, (r - p) * xx(1:end - 1)];
k = k + 0.001;
end

plot(Q, V, '*r')
xlabel('$Q$', 'Interpreter', 'latex')
ylabel('$V$', 'Interpreter', 'latex', 'rotation', 0)
index = find(Q >= 0.21, 1);
sx = X(index, 1:end - 1)
v = V(index)

模型三:两个目标函数加权求和

\[ \begin{gather} \min wx_{n+1}-(1-w)\sum_{i=0}^n(r_i-p_i)x_i \\ \text{s.t.} \begin{cases} q_ix_i\leq x_{n+1},\ i=1,2,\dots,n \\ \sum_{i=0}^n(1+p_i)x_i=M \\ x_i\geq0,\ i=0,1,\dots,n \end{cases} \end{gather} \]

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
clear;
format long g
M = 10000;
prob = optimproblem;
x = optimvar('x', 6, 1, 'LowerBound', 0);
r = [0.05, 0.28, 0.21, 0.23, 0.25];
p = [0, 0.01, 0.02, 0.045, 0.065];
q = [0, 0.025, 0.015, 0.055, 0.026]';
%w = 0:0.1:1
w = [0.766, 0.767, 0.810, 0.811, 0.824, 0.825, 0.962, 0.963, 1.0];
V = [];
Q = [];
X = [];
prob.Constraints.con1 = (1 + p) * x(1:end - 1) == M;
prob.Constraints.con2 = q(2:end) .* x(2:end - 1) <= x(end);

for i = 1:length(w)
prob.Objective = w(i) * x(end) - (1 - w(i)) * (r - p) * x(1:end - 1);
[sol, fval, flag, out] = solve(prob);
xx = sol.x;
V = [V, max(q .* xx(1:end - 1))];
Q = [Q, (r - p) * xx(1:end - 1)];
X = [X; xx'];
plot(V, Q, '*-')
xlabel('风险/元')
ylabel('收益/元')
end

V
Q

参考文献

  1. 司守奎,孙玺菁. 数学建模算法与应用(第 3 版). ↩︎

数学建模 之 投资的收益与风险(线性规划)
https://blog.gtbcamp.cn/article/mathematical-modelling-investiment/
作者
Great Thunder Brother
发布于
2022年12月23日
更新于
2025年9月19日
许可协议