lingo中的多维数组型变量

来源:互联网 发布:js正则表达式验证邮箱 编辑:程序博客网 时间:2024/05/29 17:23

例一:派生集合与多维数组型变量Derived collections with a multidimensional array variable

sets:a/1..100/:;b/1..200/:;C(a,b):x;!derived set;Endsets!Goal and restriction period;

例二

sets:a/1..100/:;b/1..200/:;C(a,b):x;Endsets!Goal and restriction period;@for(b(j):@sum(a(i):x(i,j))>150.001;!集合元素的循环函数

例三

sets:a/1..100/:;b/1..200/:y;C(a,b):x;Endsets!Goal and restriction period;@for(b(j):@gin(y(j)));@for(C(i,j):@bin(x(i,j)));

The logical operator and filter criteria

#and# #or##not##eq#  !equal#ne#  !not equal#gt#   !greater than#ge#  !greater than or equal#lt#    !less than#le#   !less than or equal

**f = @If(x#le#500,4*x,@if(x#lf#1000,500+3*x,1500+2*x)
**

lingo程序的模型文件

lingo model (*.lg4)
lingo model(text only)(*.lng)
lingo data (*.ldt)
lingo command script (*.ltf)
lingo model (*.ltx)

线性规划模型的lingo求解

例一

sets:rows/1..3/:B;columns/1..4/:X;factor(rows,columns):A;endsetsdata:A  =  1 2 3 1    2 5 1 2    3 1 6 -2;B  =  4 5 7;enddata@for(rows(i):@sum(columns(j):A(i,j)*X(j))>=B(i));

例二

model:title Calls on the transport of rice;!fine the collection period;sets:granary/1..2/:A;grainstation/1..3/:B;transfood(granary,grainstation):x,c;endsetsdata:!distancec  =  12 24  8    30 12 24;A = 4 8;B = 2 4 5;enddatamin=@sum(transfood:c*x);!min=@sum(transfood(i,j):c(i,j)*x(i,j));!Upper limit constraint;@for(granary(i):@sum(grainstation(j):x(i,j))<A(i));!lower bound;@for(grainstation(j):@sum(granary(i):x(i,j))>B(j));end
原创粉丝点击