1. lingo代码怎么写 model:
sets:
p/1..3/:a,b;
no/1..10/;
m(p,no):xyz,v,go;
u(p,p):w;
endsets
data:
xyz=2 1 3 5 4 7 8 4 3 1
3 5 3 6 8 7 4 5 3 2
4 3 3 4 3 7 5 5 4 3;
a=50
60
80;
enddata
min=go(3,10);
@for(p(i):@sum(p(j):w(i,j))=1);
@for(p(j):@sum(p(i):w(i,j))=1);
@for(u(i,j):@bin(w));
@for(m(i,j):v(i,j)[email protected](p(k):w(i,k)*xyz(k,j)));
@for(p(i):b(i)[email protected](p(k):w(i,k)*a(k)));
go(1,1)=v(1,1);
@for(no(j)|j#gt#1:go(1,j)=go(1,j-1)+v(1,j));
@for(p(i)|i#gt#1:go(i,1)=go(i-1,1)+v(i,1));
go(2,2)[email protected](go(1,2),go(2,1))+v(2,2);
go(3,2)[email protected](go(2,2),go(3,1))+v(3,2);
go(2,3)=go(2,2)+v(2,3);
go(3,3)=go(3,2)+v(3,3);
go(2,4)[email protected](go(1,4),go(2,3))+v(2,4);
go(3,4)[email protected](go(2,4),go(3,3))+v(3,4);
go(2,5)[email protected](go(1,5),go(2,4))+v(2,5);
go(3,5)[email protected](go(2,5),go(3,4))+v(3,5);
go(2,6)=go(2,5)+v(2,6);
go(3,6)=go(3,5)+v(3,6);
@for(m(i,j)|i#gt#1 #and# j#gt#6:go(i,j)[email protected](go(i-1,j),go(i,j-1))+v(i,j));
@for(p(i):go(i,10)
2. lingo if具体怎么写的 举例如下:
MIN = COST;
COST = XCOST + YCOST;
XCOST = @IF( X #GT# 0, 100, 0) + 2 * X;
YCOST = @IF( Y #GT# 0, 60, 0) + 3 * Y;
X + Y >= 30;
运行结果:
Linearization components added:
Constraints: 30
Variables: 20
Integers: 12
Global optimal solution found.
Objective value: 150.0000
Extended solver steps: 0
Total solver iterations: 25
Variable Value Reduced Cost
COST 150.0000 0.000000
XCOST 0.000000 0.000000
YCOST 150.0000 0.000000
X 0.000000 0.000000
Y 30.00000 0.000000
Row Slack or Surplus Dual Price
1 150.0000 -1.000000
2 0.000000 -1.000000
3 0.000000 -1.000000
4 0.000000 -1.000000
3. 用lingo代码怎么写 model:
sets:
row/1..1000/:t;
col/1..100/;
link(row,col):m,c;
endsets
data:
m=
;
enddata
[email protected](link:m*c);
@for(row(i):@sum(col(j):c(i,j))=3*t(i));
@sum(row(i):@sum(col(j):c(i,j)))=2850;
@for(row:@bin(t));
@for(link:@bin(c));
end
【lingo怎么写】m的值你要输进去哟