急求解,为啥运行LINGO时会出现错误代码11,多谢了

2024-12-18 00:12:46
推荐回答(1个)
回答1:

第13行结尾的分号你用成了冒号,修改后即可运行。

model:
sets:
shebei/1..6/;
qiye/1..4/;
link(shebei,qiye):c,x;
endsets
data:
c=4 2 3 4
6 4 5 5
7 6 7 6
7 8 8 6
7 9 8 6
7 10 8 6;
enddata
max=@sum(link:c*x);
@for(qiye(j):@sum(shebei(i):x(i,j))>1);
@for(shebei(i):@sum(qiye(j):x(i,j))=1);
@for(link:@bin(x));
end

运行结果,全局最优解:
Global optimal solution found.
Objective value: 44.00000
Objective bound: 44.00000
Infeasibilities: 0.000000
Extended solver steps: 0
Total solver iterations: 0

Model Class: PILP

Total variables: 24
Nonlinear variables: 0
Integer variables: 24

Total constraints: 11
Nonlinear constraints: 0

Total nonzeros: 72
Nonlinear nonzeros: 0

Variable Value Reduced Cost
C( 1, 1) 4.000000 0.000000
C( 1, 2) 2.000000 0.000000
C( 1, 3) 3.000000 0.000000
C( 1, 4) 4.000000 0.000000
C( 2, 1) 6.000000 0.000000
C( 2, 2) 4.000000 0.000000
C( 2, 3) 5.000000 0.000000
C( 2, 4) 5.000000 0.000000
C( 3, 1) 7.000000 0.000000
C( 3, 2) 6.000000 0.000000
C( 3, 3) 7.000000 0.000000
C( 3, 4) 6.000000 0.000000
C( 4, 1) 7.000000 0.000000
C( 4, 2) 8.000000 0.000000
C( 4, 3) 8.000000 0.000000
C( 4, 4) 6.000000 0.000000
C( 5, 1) 7.000000 0.000000
C( 5, 2) 9.000000 0.000000
C( 5, 3) 8.000000 0.000000
C( 5, 4) 6.000000 0.000000
C( 6, 1) 7.000000 0.000000
C( 6, 2) 10.00000 0.000000
C( 6, 3) 8.000000 0.000000
C( 6, 4) 6.000000 0.000000
X( 1, 1) 0.000000 -4.000000
X( 1, 2) 0.000000 -2.000000
X( 1, 3) 0.000000 -3.000000
X( 1, 4) 1.000000 -4.000000
X( 2, 1) 1.000000 -6.000000
X( 2, 2) 0.000000 -4.000000
X( 2, 3) 0.000000 -5.000000
X( 2, 4) 0.000000 -5.000000
X( 3, 1) 1.000000 -7.000000
X( 3, 2) 0.000000 -6.000000
X( 3, 3) 0.000000 -7.000000
X( 3, 4) 0.000000 -6.000000
X( 4, 1) 0.000000 -7.000000
X( 4, 2) 0.000000 -8.000000
X( 4, 3) 1.000000 -8.000000
X( 4, 4) 0.000000 -6.000000
X( 5, 1) 0.000000 -7.000000
X( 5, 2) 1.000000 -9.000000
X( 5, 3) 0.000000 -8.000000
X( 5, 4) 0.000000 -6.000000
X( 6, 1) 0.000000 -7.000000
X( 6, 2) 1.000000 -10.00000
X( 6, 3) 0.000000 -8.000000
X( 6, 4) 0.000000 -6.000000

Row Slack or Surplus Dual Price
1 44.00000 1.000000
2 1.000000 0.000000
3 1.000000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000000
7 0.000000 0.000000
8 0.000000 0.000000
9 0.000000 0.000000
10 0.000000 0.000000
11 0.000000 0.000000