模型:
model:
sets:
row/1..6/;
col/1..3/:c,m,sp;
A(row,col):p,n;
!若n(i,j)=1则表示j元件采用i-1个备用件;
endsets
data:
p=0.5 0.6 0.7
0.6 0.75 0.9
0.7 0.95 1
0.8 1 1
0.9 1 1
1 1 1;
c=20 30 40;
m=2 4 6;
enddata
max=sp(1)*sp(2)*sp(3);
@for(col(j):sp(j)=@sum(row(i):n(i,j)*p(i,j));@sum(row(i):n(i,j))=1);
@sum(A(i,j):(i-1)*n(i,j)*c(j))<150;
@sum(A(i,j):(i-1)*n(i,j)*m(j))<20;
@for(A:@gin(n));
end
运行结果:
Local optimal solution found.
Objective value: 0.5400000
Extended solver steps: 2
Total solver iterations: 121
Variable Value Reduced Cost
C( 1) 20.00000 0.000000
C( 2) 30.00000 0.000000
C( 3) 40.00000 0.000000
M( 1) 2.000000 0.000000
M( 2) 4.000000 0.000000
M( 3) 6.000000 0.000000
SP( 1) 1.000000 0.000000
SP( 2) 0.6000000 0.000000
SP( 3) 0.9000000 0.000000
P( 1, 1) 0.5000000 0.000000
P( 1, 2) 0.6000000 0.000000
P( 1, 3) 0.7000000 0.000000
P( 2, 1) 0.6000000 0.000000
P( 2, 2) 0.7500000 0.000000
P( 2, 3) 0.9000000 0.000000
P( 3, 1) 0.7000000 0.000000
P( 3, 2) 0.9500000 0.000000
P( 3, 3) 1.000000 0.000000
P( 4, 1) 0.8000000 0.000000
P( 4, 2) 1.000000 0.000000
P( 4, 3) 1.000000 0.000000
P( 5, 1) 0.9000000 0.000000
P( 5, 2) 1.000000 0.000000
P( 5, 3) 1.000000 0.000000
P( 6, 1) 1.000000 0.000000
P( 6, 2) 1.000000 0.000000
P( 6, 3) 1.000000 0.000000
N( 1, 1) 0.000000 0.2700002
N( 1, 2) 1.000000 0.3600000
N( 1, 3) 0.000000 0.1800001
N( 2, 1) 0.000000 0.2160002
N( 2, 2) 0.000000 0.2250000
N( 2, 3) 1.000000 0.6000004E-01
N( 3, 1) 0.000000 0.1620001
N( 3, 2) 0.000000 0.4500001E-01
N( 3, 3) 0.000000 0.000000
N( 4, 1) 0.000000 0.1080001
N( 4, 2) 0.000000 0.000000
N( 4, 3) 0.000000 0.000000
N( 5, 1) 0.000000 0.5400004E-01
N( 5, 2) 0.000000 0.000000
N( 5, 3) 0.000000 0.000000
N( 6, 1) 1.000000 0.000000
N( 6, 2) 0.000000 0.000000
N( 6, 3) 0.000000 0.000000