实例4:有10种不同的零件,它们都可或在设备A或B或C上加工, 单件加工费用见下表。 又只要有零件在设备A、B、C上加工,不管加工1种或多种, 分别发生的一次性准备费用为dA,dB,dC元。要求: ①上述10种零件每种加工1件; ②若第1种零件在设备A上加工,则第2种零件应在B或C上加工; ③零件3,4,5必须在不同的设备上加工; ④在设备C上加工的零件种数不超过3种。 试确定使总的费用为最小的加工方案。
零件
设备
1
2
3
4
5
6
7
8
9
10
A
B
C
a1
b1
c1
a2
b2
c2
a3
b3
c3
a4
b4
c4
a5
b5
c5
a6
b6
c6
a7
b7
c7
a8
b8
c8
a9
b9
c9
a10
b10
c10
实例4 q1
clc;
clear all;
c=[5 8 5 6 9 7 3 4 11 10 ...
4 4 8 4 6 5 5 7 9 11 ...
7 9 3 7 10 8 4 6 12 9 ...
120 132 125];
ic=[1:33];
A=[1 1 1 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 -9999 0 0;
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 -9999 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 1 1 1 1 0 0 -9999;
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 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 1 1 1 1 0 0 0];
b=[0 0 0 1 3];
aeq=[1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0;
0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0;
0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0;
0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0;
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 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;
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 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0];
beq=ones(13,1);
lb=zeros(33,1);
ub=[99 99 99 99 99 99 99 99 99 99 ...
99 99 99 99 99 99 99 99 99 99 ...
99 99 99 99 99 99 99 99 99 99 ...
1 1 1];
[x,fval]=intlinprog(c,ic,A,b,aeq,beq,lb,ub);
x=[x']; FF=[0 0 0 0 0 0 0]; x=[x,FF];X=reshape(x,10,4);x=[X'];
disp('最优解'),disp(x(1:3,1:10)), disp('设备启动'),disp(x(4,1:3)), disp('最优总费用'),disp(fval)

实例4 q2
clc;
clear all;
c=[5 8 5 6 9 7 3 4 11 10 ...
4 4 8 4 6 5 5 7 9 11 ...
7 9 3 7 10 8 4 6 12 9 ...
120 132 125];
ic=[1:33];
A=[1 1 1 1 1 1 1 1 1 1 0 0 0 0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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0];
beq=[10 10 10 10 10 10 10 10 10 10 10 10 10];
lb=zeros(33,1);
ub=[999 999 999 999 999 999 999 999 999 999 ...
999 999 999 999 999 999 999 999 999 999 ...
999 999 999 999 999 999 999 999 999 999 ...
1 1 1];
[x,fval]=intlinprog(c,ic,A,b,aeq,beq,lb,ub);
x=[x']; FF=[0 0 0 0 0 0 0]; x=[x,FF];X=reshape(x,10,4);x=[X'];
disp('最优解'),disp(x(1:3,1:10)), disp('设备启动'),disp(x(4,1:3)), disp('最优总费用'),disp(fval)

实例4 q3 考虑时间没有第二问限制条件
clc;
clear all;
c=[5 8 5 6 9 7 3 4 11 10 ...
4 4 8 4 6 5 5 7 9 11 ...
7 9 3 7 10 8 4 6 12 9 ...
120 132 125];
ic=[1:33];
A=[1 1 1 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 -9999 0 0;
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 -9999 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 1 1 1 1 0 0 -9999;
0.2 0.3 0.5 0.1 0.3 0.4 0.3 0.2 0.1 0.5 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 0 0 0 0 0 0.4 0.2 0.3 0.4 0.2 0.5 0.3 0.1 0.2 0.5 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 0 0 0 0 0 0.3 0.4 0.2 0.2 0.5 0.4 0.5 0.6 0.2 0.3 0 0 0 ];
b=[0 0 0 16 18 12];
aeq=[1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0;
0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0;
0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0;
0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0;
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0];
beq=[10 10 10 10 10 10 10 10 10 10];
lb=zeros(33,1);
ub=[999 999 999 999 999 999 999 999 999 999 ...
999 999 999 999 999 999 999 999 999 999 ...
999 999 999 999 999 999 999 999 999 999 ...
1 1 1];
[x,fval]=intlinprog(c,ic,A,b,aeq,beq,lb,ub);
x=[x']; FF=[0 0 0 0 0 0 0]; x=[x,FF];X=reshape(x,10,4);x=[X'];
disp('考虑时间没有第二问限制条件的最优解'),disp(x(1:3,1:10)), disp('设备启动'),disp(x(4,1:3)), disp('最优总费用'),disp(fval)

实例4 q3 考虑时间且有第二问限制条件
clc;
clear all;
c=[5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 0 0 0 1 0 0 0 0 0 0 0 0;
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 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;
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 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0];
beq=[10 10 10 10 10 10 10 10 10 10 10 10 10];
lb=zeros(33,1);
ub=[999 999 999 999 999 999 999 999 999 999 ...
999 999 999 999 999 999 999 999 999 999 ...
999 999 999 999 999 999 999 999 999 999 ...
1 1 1];
[x,fval]=intlinprog(c,ic,A,b,aeq,beq,lb,ub);
x=[x']; FF=[0 0 0 0 0 0 0]; x=[x,FF];X=reshape(x,10,4);x=[X'];
disp('考虑时间且有第二问限制条件的最优解'),disp(x(1:3,1:10)), disp('设备启动'),disp(x(4,1:3)), disp('最优总费用'),disp(fval)

实例4 q4 不考虑固定费用 不考虑问题二限制(仅考虑生产费用和时间限制)
clc;
clear all;
c=[5 8 5 6 9 7 3 4 11 10 ...
4 4 8 4 6 5 5 7 9 11 ...
7 9 3 7 10 8 4 6 12 9];
ic=[1:30];
A=[0.2 0.3 0.5 0.1 0.3 0.4 0.3 0.2 0.1 0.5 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 0 0 0.4 0.2 0.3 0.4 0.2 0.5 0.3 0.1 0.2 0.5 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 0 0 0.3 0.4 0.2 0.2 0.5 0.4 0.5 0.6 0.2 0.3];
b=[16 18 12];
aeq=[1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0;
0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0;
0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0;
0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0;
0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0;
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0;
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0;
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0;
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0;
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1];
beq=[10 10 10 10 10 10 10 10 10 10];
lb=zeros(30,1);
ub=[999 999 999 999 999 999 999 999 999 999 ...
999 999 999 999 999 999 999 999 999 999 ...
999 999 999 999 999 999 999 999 999 999];
[x,fval]=intlinprog(c,ic,A,b,aeq,beq,lb,ub);
X=reshape(x,10,3);x=[X'];
disp('仅考虑时间限制的最优解'),disp(x(1:3,1:10))
disp('最优总费用'),disp(fval)

实例5:
校篮球队准备从以下6名队员中选拔3名为正式队员, 并使平均身高尽可能高, 这6名预备队员情况如下下表所示。
队员的挑选要满足下列条件:
(1)至少补充一名后卫队员;
(2)大李或小田中间只能入选一名;
(3)最多补充一名中锋;
(4)如果大李或小赵入选,小周就不能入选。 试确定合理的入选队员。
实例五
c=[-193;-191;-187;-186;-180;-185];
aeq=[1 1 1 1 1 1;
0 0 0 0 -1 -1;
0 1 0 0 1 0;
1 1 0 0 0 0;
0 1 0 0 0 1;
0 0 0 1 0 1;];
beq=[3 -1 1 1 1 1];
lb=[0;0;0;0;0;0];
ub=[1;1;1;1;1;1];
intcon=[1,2,3,4,5,6];%intcon为整数约束变量的位置。
[x,fval]=intlinprog(c,intcon,aeq,beq,[],[],lb)

优化零件加工方案:最小费用与设备约束
本文讨论了一个关于10种零件加工成本、一次性费用及设备选择的问题。目标是在满足特定条件(如零件搭配、设备使用限制)下,找到总费用最低的加工方案。实例提供了使用整数线性规划解决实际问题的过程和结果。

被折叠的 条评论
为什么被折叠?



