...end 在lingo实现时显示错误有个教程上说
编辑: admin 2017-12-03
-
4
这个有多组解 由于起点不同计算结果也不同 而且lingo默认变量为非负 所以会提示没有可行解
你要解出来可以到lingo options设置使用global solver或者你在init段设置初始x y的值
类似问题
类似问题1:lingo程序:MIN=(-2*x+x^2)*@exp (-x^2-y^2-x*y);为什么总是显示出错
因为你的括号都是中文标点换成英文的这个()就行了
类似问题2:lingo模型定义出错问题model: sets: center/1..3/:u; addr/1..7/:v; w(center,addr):x,y;endsets data: y=36 24 49 21 81 72 4530 20 56 24 99 88 5536 24 63 27 90 80 50 ;enddatamin=@sum(w:x(i,j)*y(i,j));@sum(addr:x(1,j))=3;@sum(addr:x(2,j))=2;@sum(a[数学科目]
model:
sets:
center/1..3/:u;
addr/1..7/:v;
w(center,addr):x,y;
endsets
data:
y=
36 24 49 21 81 72 45
30 20 56 24 99 88 55
36 24 63 27 90 80 50 ;
enddata
min=@sum(w:x*y);
@sum(addr(j):x(1,j))=3;
@sum(addr(j):x(2,j))=2;
@sum(addr(j):x(3,j))=2;
@for(addr(j):@sum(center(i):x(i,j))=1);
@for(w:@bin(x));
end
结果:
Global optimal solution found.
Objective value: 329.0000
Objective bound: 329.0000
Infeasibilities: 0.000000
Extended solver steps: 0
Total solver iterations: 0
Variable Value Reduced Cost
U( 1) 0.000000 0.000000
U( 2) 0.000000 0.000000
U( 3) 0.000000 0.000000
V( 1) 0.000000 0.000000
V( 2) 0.000000 0.000000
V( 3) 0.000000 0.000000
V( 4) 0.000000 0.000000
V( 5) 0.000000 0.000000
V( 6) 0.000000 0.000000
V( 7) 0.000000 0.000000
X( 1, 1) 0.000000 36.00000
X( 1, 2) 0.000000 24.00000
X( 1, 3) 1.000000 49.00000
X( 1, 4) 0.000000 21.00000
X( 1, 5) 1.000000 81.00000
X( 1, 6) 1.000000 72.00000
X( 1, 7) 0.000000 45.00000
X( 2, 1) 1.000000 30.00000
X( 2, 2) 1.000000 20.00000
X( 2, 3) 0.000000 56.00000
X( 2, 4) 0.000000 24.00000
X( 2, 5) 0.000000 99.00000
X( 2, 6) 0.000000 88.00000
X( 2, 7) 0.000000 55.00000
X( 3, 1) 0.000000 36.00000
X( 3, 2) 0.000000 24.00000
X( 3, 3) 0.000000 63.00000
X( 3, 4) 1.000000 27.00000
X( 3, 5) 0.000000 90.00000
X( 3, 6) 0.000000 80.00000
X( 3, 7) 1.000000 50.00000
Y( 1, 1) 36.00000 0.000000
Y( 1, 2) 24.00000 0.000000
Y( 1, 3) 49.00000 0.000000
Y( 1, 4) 21.00000 0.000000
Y( 1, 5) 81.00000 0.000000
Y( 1, 6) 72.00000 0.000000
Y( 1, 7) 45.00000 0.000000
Y( 2, 1) 30.00000 0.000000
Y( 2, 2) 20.00000 0.000000
Y( 2, 3) 56.00000 0.000000
Y( 2, 4) 24.00000 0.000000
Y( 2, 5) 99.00000 0.000000
Y( 2, 6) 88.00000 0.000000
Y( 2, 7) 55.00000 0.000000
Y( 3, 1) 36.00000 0.000000
Y( 3, 2) 24.00000 0.000000
Y( 3, 3) 63.00000 0.000000
Y( 3, 4) 27.00000 0.000000
Y( 3, 5) 90.00000 0.000000
Y( 3, 6) 80.00000 0.000000
Y( 3, 7) 50.00000 0.000000
Row Slack or Surplus Dual Price
1 329.0000 -1.000000
2 0.000000 0.000000
3 0.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
类似问题3:lingo中这样求解对么 为什么运行错误?Min= (x^2-(2-y)^2)^1/2+((4-x)^2+(4-y)^2)^1/2+y X<=4 Y<=4[数学科目]
当然不对 括号都要用英文的 每句后面加分号 不能连写不等号 相乘要有*
类似问题4:lingo 模型定义错误,求高手修改,model:sets:n/1..20/;a/1..13/:demand;links(n,a):b,x;endsetsdata:demand,b=@ole('D:\123.xls');enddatamin=@sum(links:b*x(i,j));@for(a(j):@sum(n(i):x(i,j))=1);@for(n(i):@sum(a(j):x(i,j))
model:
sets:
n/1..20/;
a/1..13/:demand;
links(n,a):b,x;
endsets
data:
demand,b=@ole('D:\123.xls');
enddata
min=@sum(links:b*x);
@for(a(j):
@sum(n(i): x(i,j))=1);
@for(n(i):
@sum(a(j): x(i,j))
类似问题5:lingo程序:model:sets:product/1..3/:a,b; row/1..5/:c,d,y; num/1..9/:x; endsets其中的product和num该怎么用?还有平时不是用的col么而不是num区别在哪?
集名而已 可以随便写 不重名就行
建议你自己查一下集循环函数的写法 看看怎么写就知道了