>> f=[-2;-3;5];
>> a=[-2,5,-1;1,3,1];b=[-10;12];aeq=[1,1,1];beq=7;
>> [x,y]=linprog(f,a,b,aeq,beq,zeros(3,1));
>> x,y=-y
最大化收益率、最小化风险
投入资金为M、每一项大于等于0
分险减收益最小,分险小收益大 赔的少
关注两个拐点,分险在0.006之前,收益率快速上升,
分险在0.006---0.025之间,收益率匀速上升,超过0.025,收益率不变
>> clear all
>> f=[0.25-1,0.5-1.65,0.0321*7-1,0.0321*9-1.65,0.0321*12-2.3,6/16,0.5,783*4/7000,783*11/7000,0.35];
a=[5,0,10,0,0,0,0,0,0,0;0,0,7,9,12,0,0,0,0,0;0,0,0,0,0,6,8,0,0,0;0,0,0,0,0,0,0,4,11,0;0,0,0,0,0,0,0,0,0,7];
b=[6000;10000;4000;7000;4000];
aeq=[1,0,1,0,0,-1,0,-1,0,-1;0,1,0,1,0,0,-1,0,0,0;0,0,0,0,1,0,0,0,-1,0];
beq=[0;0;0];
>> lb=zeros(10,1)
lb =
0
0
0
0
0
0
0
0
0
0
>> [x,y]=linprog(f,a,b,aeq,beq,lb);
x,y=-y
Optimal solution found.
x =
1.0e+03 *
1.2000
0
0
0.5000
0.4078
0
0.5000
0.6286
0.4078
0.5714
y =
1.1284e+03
minimize 15*x1 + 18*x2 + 21*x3 + 24*x4 +19*x5 + 23*x6 + 22*x7
+ 18*x8 +26*x9 + 17*x10 + 16*x11 + 19*x12 +19*x13 + 21*x14
+ 23*x15 + 17*x16
subject to x1 + x2 + x3 + x4 = 1
x5 + x6 + x7 + x8 = 1
x9 + x10 + x11 + x12 = 1
x13 + x14 + x15 + x16 = 1
x1 + x5 + x9 + x13 = 1
x2 + x6 + x10 + x14 = 1
x3 + x7 + x11 + x15 = 1
x4 + x8 + x12 + x16 = 1
x1 >= 0
x2 >= 0
x3 >= 0
x4 >= 0
x5 >= 0
x6 >= 0
x7 >= 0
x8 >= 0
x9 >= 0
x10 >= 0
x11 >= 0
x12 >= 0
x13 >= 0
x14 >= 0
x15 >= 0
x16 >= 0
f = [15; 18; 21; 24; 19; 23; 22; 18; 26; 17; 16; 19; 19; 21; 23; 17];
Aeq = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1;
1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0;
0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0;
0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0;
0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1];
beq = [1; 1; 1; 1; 1; 1; 1; 1];
lb = zeros(16, 1);
[x, fval, exitflag] = linprog(f, [], [], Aeq, beq, lb);
甲A乙D丙C丁B