第1个回答 2010-06-06
model:
sets:
a/1..5/;
time(a,a):t,n;!n(i,j)=1则意味i去做j任务;
endsets
data:
t=8 6 10 9 12
9 12 7 11 9
7 4 3 5 8
9 5 8 11 8
4 6 7 5 11;
enddata
[OBJ]min=@sum(time:t*n);
@for(a(i):@sum(a(j):n(i,j))=1);!每个任务只给一个人做;
@for(a(j):@sum(a(i):n(i,j))=1);!每个人只能做一件任务;
end
运行结果:
Global optimal solution found.
Objective value: 30.00000
Total solver iterations: 6
Variable Value Reduced Cost
T( 1, 1) 8.000000 0.000000
T( 1, 2) 6.000000 0.000000
T( 1, 3) 10.00000 0.000000
T( 1, 4) 9.000000 0.000000
T( 1, 5) 12.00000 0.000000
T( 2, 1) 9.000000 0.000000
T( 2, 2) 12.00000 0.000000
T( 2, 3) 7.000000 0.000000
T( 2, 4) 11.00000 0.000000
T( 2, 5) 9.000000 0.000000
T( 3, 1) 7.000000 0.000000
T( 3, 2) 4.000000 0.000000
T( 3, 3) 3.000000 0.000000
T( 3, 4) 5.000000 0.000000
T( 3, 5) 8.000000 0.000000
T( 4, 1) 9.000000 0.000000
T( 4, 2) 5.000000 0.000000
T( 4, 3) 8.000000 0.000000
T( 4, 4) 11.00000 0.000000
T( 4, 5) 8.000000 0.000000
T( 5, 1) 4.000000 0.000000
T( 5, 2) 6.000000 0.000000
T( 5, 3) 7.000000 0.000000
T( 5, 4) 5.000000 0.000000
T( 5, 5) 11.00000 0.000000
N( 1, 1) 0.000000 0.000000
N( 1, 2) 0.000000 0.000000
N( 1, 3) 0.000000 3.000000
N( 1, 4) 1.000000 0.000000
N( 1, 5) 0.000000 3.000000
N( 2, 1) 0.000000 1.000000
N( 2, 2) 0.000000 6.000000
N( 2, 3) 0.000000 0.000000
N( 2, 4) 0.000000 2.000000
N( 2, 5) 1.000000 0.000000
N( 3, 1) 0.000000 3.000000
N( 3, 2) 0.000000 2.000000
N( 3, 3) 1.000000 0.000000
N( 3, 4) 0.000000 0.000000
N( 3, 5) 0.000000 3.000000
N( 4, 1) 0.000000 2.000000
N( 4, 2) 1.000000 0.000000
N( 4, 3) 0.000000 2.000000
N( 4, 4) 0.000000 3.000000
N( 4, 5) 0.000000 0.000000
N( 5, 1) 1.000000 0.000000
N( 5, 2) 0.000000 4.000000
N( 5, 3) 0.000000 4.000000
N( 5, 4) 0.000000 0.000000
N( 5, 5) 0.000000 6.000000
N(i,j)=1的地方就是安排i去干j任务。
第2个回答 2015-01-20
model:
sets:
r/1..5/:;
c/1..5/:;
link(r,c):time,x;
endsets
data:
time= 8 6 10 9 2
9 12 7 11 9
7 4 3 5 8
9 5 8 11 8
4 6 7 5 11;
enddata
min=@sum(link:x*time);
@for(link:@bin(x));
@for(r(i):@sum(c(j):x(i,j))=1);
@for(c(j):@sum(r(i):x(i,j))=1);
end
Global optimal solution found.
Objective value: 23.00000
Objective bound: 23.00000
Infeasibilities: 0.000000
Extended solver steps: 0
Total solver iterations: 0
Variable Value Reduced Cost
TIME( 1, 1) 8.000000 0.000000
TIME( 1, 2) 6.000000 0.000000
TIME( 1, 3) 10.00000 0.000000
TIME( 1, 4) 9.000000 0.000000
TIME( 1, 5) 2.000000 0.000000
TIME( 2, 1) 9.000000 0.000000
TIME( 2, 2) 12.00000 0.000000
TIME( 2, 3) 7.000000 0.000000
TIME( 2, 4) 11.00000 0.000000
TIME( 2, 5) 9.000000 0.000000
TIME( 3, 1) 7.000000 0.000000
TIME( 3, 2) 4.000000 0.000000
TIME( 3, 3) 3.000000 0.000000
TIME( 3, 4) 5.000000 0.000000
TIME( 3, 5) 8.000000 0.000000
TIME( 4, 1) 9.000000 0.000000
TIME( 4, 2) 5.000000 0.000000
TIME( 4, 3) 8.000000 0.000000
TIME( 4, 4) 11.00000 0.000000
TIME( 4, 5) 8.000000 0.000000
TIME( 5, 1) 4.000000 0.000000
TIME( 5, 2) 6.000000 0.000000
TIME( 5, 3) 7.000000 0.000000
TIME( 5, 4) 5.000000 0.000000
TIME( 5, 5) 11.00000 0.000000
X( 1, 1) 0.000000 8.000000
X( 1, 2) 0.000000 6.000000
X( 1, 3) 0.000000 10.00000
X( 1, 4) 0.000000 9.000000
X( 1, 5) 1.000000 2.000000
X( 2, 1) 0.000000 9.000000
X( 2, 2) 0.000000 12.00000
X( 2, 3) 1.000000 7.000000
X( 2, 4) 0.000000 11.00000
X( 2, 5) 0.000000 9.000000
X( 3, 1) 0.000000 7.000000
X( 3, 2) 0.000000 4.000000
X( 3, 3) 0.000000 3.000000
X( 3, 4) 1.000000 5.000000
X( 3, 5) 0.000000 8.000000
X( 4, 1) 0.000000 9.000000
X( 4, 2) 1.000000 5.000000
X( 4, 3) 0.000000 8.000000
X( 4, 4) 0.000000 11.00000
X( 4, 5) 0.000000 8.000000
X( 5, 1) 1.000000 4.000000
X( 5, 2) 0.000000 6.000000
X( 5, 3) 0.000000 7.000000
X( 5, 4) 0.000000 5.000000
X( 5, 5) 0.000000 11.00000