## 一、问题

A航空公司每天有6班航班从上海到北京，从上午10点到晚上8点，每两小时发一班航班。某天获知，前三班机每班可以容纳100名旅客，后三班机每班可以容纳150名旅客。如果某次航班超售，A航空公司可以把某预定了该次航班的旅客转到晚一点的航班，并且针对该延误两小时以上（含两小时）的旅客赔偿200元，每再多一小时，多赔偿20元。A航空公司总是可以把延期到晚上8点以后的旅客安排到另外的航空公司的11点航班上，最后安排的航班总有足够的位置. 假设某天，A航空公司卖了
T10,T12,T14,T16,T18,T20

## 二、部分源代码

t10 = 112;
t12 = 137;
t14=140;
t16=130;
t18=120;
t20=130;

%化简并提系数:200*(x(2)+x(3)+x(4)+x(5)+x(6)+x(7) + x(9)+x(10)+x(11)+x(12)+x(13) + x(15)+x(16)+x(17)+x(18) + x(20)+x(21)+x(22) + x(24)+x(25) + x(27) + x(28)) + 20*( 2*(x(2)+x(9)+x(15)+x(20)+x(24)) + 4*( x(3)+x(10)+x(16)+x(21) ) + 6*( x(4)+x(11)+x(17) ) + 8*( x(5)+x(12) ) + 10x(6)) +20( 13x(7) + 11x(13) + 9x(18) + 7x(22) + 5x(25) + 3x(27) )
f_12= [0 240 280 320 360 400 213 0 240 280 320 360 211 0 240 280 320 209 0 240 280 207 0 240 205 0 203 200];

%指明变量为整数
intcon = [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
];
%不等式约束
% A是7行28列矩阵，b从理论上应该也是7行1列矩阵才对，表示7个不等式约束
A = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0;
0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0;
0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0;
0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,1,1];
b=[100 100 100 150 150 150 get_if_eg_0(t10 + t12 + t14 + t16 + t18 + t20-100-100-100-150-150-150)]';
%等式约束
Aeq= [
1,1,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,0;
0,0,0,0,0,0,0,1,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,0,0,0,0,0,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,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,0,0,0,0,0,0,0,0,1,1,1,0,0,0;
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0];
beq = [t10 t12 t14 t16 t18 t20];
%变量最小值
lb=zeros(1,28);
ub=[];
[x, fval]=intlinprog(f_12,intcon,A,b,Aeq,beq,lb,ub);
fprintf(‘当各航班售票数(含超售票数)分别为:t10=%d,t12=%d,t14=%d,t16=%d,t18=%d,t20=%d时’, t10,t12,t14,t16,t18,t20);
format_result(x)
fprintf(‘按上述安排旅客乘坐班机最优，费用为:%f\n’, fval);
%linprog(f_12,intcon,A,b,Aeq,beq,lb,ub)

## 四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 郑鸿瑞,赵亚文,周风波,甘昭林,胡祎,谭燕花.基于变步长因子的改进LMS算法[J].电子制作. 2022,30(05)