lingo错误代码29怎么解决?

原来的程序是这样的:sets:nodes/1. . 32 /: p;roads( nodes,nodes) : A; endsetsdata:X = 0 1 0…; enddatamin = @ sum( nodes: p) ;@ for( nodes( i) : @ bin( p) ) ;@ for( roads( i,j) | i#gt#j#and#A( i,j) #eq#1:p( i) + p( j) > = 1) ;endend运行之后提示错误代码29,我们把程序改成这样试了试:sets:nodes/1..3/:p; roads(nodes,nodes):A;endsetsdata:X = 1 0 10 1 11 1 0;enddatamin=@sum(nodes:p);@for(nodes(i):@bin(p));@for(roads(i,j) | i#gt#j#and#A(i,j)#eq#1:p(i)+p(j)>=1);endend还是提示错误代码29我们需要这一段程序计算一个3乘3的矩阵,但是矩阵那里一直是错的,这是为什么?

你在DATA中输入的X变量是不是写错了,应该写成A才对。
在你的第二段代码的基础上,把DATA中的X改成A后,可以运行:

sets:
nodes/1..3/:p;
roads(nodes,nodes):A;
endsets
data:
A= 1 0 1
0 1 1
1 1 0;
enddata
min=@sum(nodes:p);
@for(nodes(i):@bin(p));
@for(roads(i,j) | i#gt#j#and#A(i,j)#eq#1:p(i)+p(j)>=1);
end
end

结果是:

Global optimal solution found.
Objective value: 1.000000
Objective bound: 1.000000
Infeasibilities: 0.000000
Extended solver steps: 0
Total solver iterations: 0

Model Class: PILP

Total variables: 3
Nonlinear variables: 0
Integer variables: 3

Total constraints: 3
Nonlinear constraints: 0

Total nonzeros: 7
Nonlinear nonzeros: 0

Variable Value Reduced Cost
P( 1) 0.000000 1.000000
P( 2) 0.000000 1.000000
P( 3) 1.000000 1.000000
A( 1, 1) 1.000000 0.000000
A( 1, 2) 0.000000 0.000000
A( 1, 3) 1.000000 0.000000
A( 2, 1) 0.000000 0.000000
A( 2, 2) 1.000000 0.000000
A( 2, 3) 1.000000 0.000000
A( 3, 1) 1.000000 0.000000
A( 3, 2) 1.000000 0.000000
A( 3, 3) 0.000000 0.000000

Row Slack or Surplus Dual Price
1 1.000000 -1.000000
2 0.000000 0.000000
3 0.000000 0.000000
温馨提示:答案为网友推荐,仅供参考
相似回答