你在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
温馨提示:答案为网友推荐,仅供参考