线性规划
- lingo代码如下
model:
sets:
products/desks,tables,chairs/:interest,volume;
materials/1..3/:capacity;
links(products,materials):x;
endsets
data:
interest=60,30,20;
capacity=48,20,8;
x=8,4,2
6,2,1.5
1,1.5,0.5;
enddata
max=@sum(products(i):interest(i)*volume(i));
@for(materials(j):@sum(products(i):x(i,j)*volume(i))<=capacity(j));
volume(2)<=5;
end
- 函数由model开始,end结束
- set与endsets之间定义集合
- data与enddata之间输入数据
- @sum函数冒号前为求和的下标,冒号后为求和内容
- @for函数用来对集合的成员生成约束表达式,冒号前为集合名称,冒号后为约束表达式