AMPL 个人投资线性规划问题

设:总资金=150000元
x1=  定期存款 年息2.25%
x2= 货币型基金 年收益在[ 2%, 4% ]

x3= 债券型基金 年收益在[ -2%, 12% ] 

x4= 股票型基金 年收益在[ -30%, 100% ]

求:最大化收益,最小化损失。

AMPL Code:

var x1 >=0;
var x2 >=0;
var x3 >=0;
var x4 >=0;

maximize profit: 0.0325*x1 + 0.04*x2 + 0.08*x3 + 0.50*x4;
minimize loss:   0.0325*x1 + 0.02*x2 - 0.02*x3 - 0.20*x4;

C1: x1 + x2 + x3 + x4 <= 150000;
C2: x1 + x2 <= 120000;
C3: x3 + x4 <= 120000;

solve;
display x1,x2,x3,x4, profit, loss;

执行 ampl.exe grtz_lp.mod

MINOS 5.5: optimal solution found.
2 iterations, objective 61200
Objective = profit
x1 = 0
x2 = 30000
x3 = 0
x4 = 120000
profit = 61200
loss = -23400

最好情况下收益率: 61200/150000= 40.8%

最坏情况下损失:-2812.5/150000= -15.6%

看来考验人的是资金分配的配置比例。

你可能感兴趣的:(AMPL,c)