hannah520
2016-12-23 16:19:15 +08:00
啊啊啊啊,竟然回答也需要铜币!重新回答一次吧
数学模型:
*******************************并不造如何上传公式或者图片**************************************
matlab 求解:
function [f]=transport(x)
f=0;
C=[7 1 1 6 3 3 7 6 9 7 9 5 4 2 5 8 7 1 3 9];
for i=1:20
f=f+x(i)*C(i);
end
end
lb = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
ub = [Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf Inf];
x0 = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
Aeq = [1 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 1 0 0;
0 0 1 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 1;
1 1 1 1 0 0 0 0 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 0 0 0 0 1 1 1 1 0 0 0 0 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 0 0 0 0 1 1 1 1];
Beq = [30 90 30 60 70 30 50 40 20];
[x,f] = fmincon(@transport,x0,[],[],Aeq,Beq,lb,ub)
结果如下:
x =
1 至 13 列
0.0000 39.1780 30.0000 0.8220 20.8220 0.0000 0.0000 9.1780 0.0000 0.0000 0.0000 50.0000 9.1780
14 至 20 列
30.8220 0.0000 0.0000 0.0000 20.0000 0.0000 0.0000
f =
560.0000