Lingo案例分析

上传人:鲁** 文档编号:489920851 上传时间:2023-06-30 格式:DOC 页数:34 大小:270KB
返回 下载 相关 举报
Lingo案例分析_第1页
第1页 / 共34页
Lingo案例分析_第2页
第2页 / 共34页
Lingo案例分析_第3页
第3页 / 共34页
Lingo案例分析_第4页
第4页 / 共34页
Lingo案例分析_第5页
第5页 / 共34页
点击查看更多>>
资源描述

《Lingo案例分析》由会员分享,可在线阅读,更多相关《Lingo案例分析(34页珍藏版)》请在金锄头文库上搜索。

1、精品文档,仅供学习与交流,如有侵权请联系网站删除最小费用运输问题单位 销地运价产地B1B2B3B4B5B6B7B8产量A16267425960A24953858255A35219743351A47673927143A52395726541A65522814352销量3537223241324338280/302i.e:model:!6发点8收点运输问题;sets: warehouses/wh1.wh6/: capacity; vendors/v1.v8/: demand; links(warehouses,vendors): cost, volume;endsets!目标函数; min=sum

2、(links: cost*volume);!需求约束; for(vendors(J): sum(warehouses(I): volume(I,J)=demand(J);!产量约束; for(warehouses(I): sum(vendors(J): volume(I,J)=capacity(I);!这里是数据;data: capacity=60 55 51 43 41 52; demand=35 37 22 32 41 32 43 38; cost=6 2 6 7 4 2 9 5 4 9 5 3 8 5 8 2 5 2 1 9 7 4 3 3 7 6 7 3 9 2 7 1 2 3 9 5

3、 7 2 6 5 5 5 2 2 8 1 4 3;enddata1 LINGO中的集1.1 The Sets Section of a ModelSets are defined in an optional section of a LINGO model, called the sets section. Before you use sets in a LINGO model, you have to define them in the sets section of the model. The sets section begins with the keyword SETS: (

4、including the colon), and ends with the keyword ENDSETS. A model may have no sets section, a single sets section, or multiple sets sections. A sets section may appear anywhere in a model. The only restriction is you must define a set and its attributes before they are referenced in the models constr

5、aints.1.2 Defining Primitive SetsTo define a primitive set in a sets section, you specify: the name of the set, optionally, its members (objects contained in the set), and optionally, any attributes the members of the set may have.A primitive set definition has the following syntax: setname / member

6、_list / : attribute_list;When using implicit set member lists, you do not have to list a name for each set member. Use the following syntax when using an implicit set member list:setname / member1.memberN / : attribute_list;where member1 is the name of the first member in the set and memberN is the

7、name of the last member. LINGO automatically generates all the intermediate member names between member1 and memberN. While this can be a very compact and convenient method for building a primitive set, there is one catch in that only certain formats of names are accepted for the initial and termina

8、l member names. The following table details the available options:Implicit MemberList FormatExample Set Members1.n1.51, 2, 3, 4, 5stringM.stringNTRUCKS3.TRUCKS204TRUCK3, TRUCK4, ., TRUCK204dayM.dayNMON.FRIMON, TUE, WED, THU, FRImonthM.monthNOCT.JANOCT, NOV, DEC, JANmonthYearM.monthYearNOCT2001.JAN20

9、02OCT2001, NOV2001, DEC2001, JAN2002i.e1:!集部分;sets: students:sex,age;endsets!数据部分;data: students,sex,age= John 1 16 Jill 0 14 Rose 0 17 Mike 1 13;enddatai.e2:data: NUMBER_OF_WH = 6;enddatasets: WAREHOUSES / 1.NUMBER_OF_WH/: CAPACITY;endsets1.3 Defining Derived SetsTo define a derived set, you specif

10、y: the name of the set, its parent sets, optionally, its members, and optionally, any attributes the set members have.A derived set definition has the following syntax:setname( parent_set_list) / member_list / : attribute_list;i.e3:sets: product/ A ,B/; machine / M, N/; week/ 1.2/; allowed(product,m

11、achine,week);endsetsallowed Set Membership:IndexMember1(A,M,1)2(A,M,2)3(A,N,1)4(A,N,2)5(B,M,1)6(B,M,2)7(B,N,1)8(B,N,2)i.e:sets: !学生集:性别属性sex,1表示男性,0表示女性;年龄属性age. ; students/John,Jill,Rose,Mike/:sex,age; !男学生和女学生的联系集:友好程度属性friend,0,1之间的数。 ; linkmf(students,students)|sex(&1) #eq# 1 #and# sex(&2) #eq#

12、0: friend; !男学生和女学生的友好程度大于0.5的集; linkmf2(linkmf) | friend(&1,&2) #ge# 0.5 : x;endsetsdata: sex,age = 1 16 0 14 0 17 0 13; friend = 0.3 0.5 0.6;enddataNote:竖线是用来标记一个成员资格过滤器的开始。#eq#表示逻辑运算符,相等为真,&1表示派生集的第1个原始父集的索引,它取遍该原始父集的所有成员;,&2表示派生集的第2个原始父集的索引,它取遍该原始父集的所有成员;以此类推。2 LINGO中的数据部分数据部分提供了模型相对静止部分和数据分离的可能

13、性。数据部分以关键字“data:”开始,以关键字“enddata”结束。在这里,可以指定集成员、集的属性。其语法如下:object_list = value_list;对象列(object_list)包含要指定值的属性名、要设置集成员的集名,用逗号或空格隔开。一个对象列中至多有一个集名,而属性名可以有任意多。如果对象列中有多个属性名,那么它们的类型必须一致。如果对象列中有一个集名,那么对象列中所有的属性的类型就是这个集。数值列(value_list)包含要分配给对象列中的对象的值,用逗号或空格隔开。注意属性值的个数必须等于集成员的个数。i.e:sets: set1/A,B,C/: X,Y;en

14、dsetsdata: X=1,2,3; Y=4,5,6;enddata也可采用复合数据声明(data statement)实现同样的功能。i.e:sets: set1/A,B,C/: X,Y;endsetsdata: X,Y=1 4 2 5 3 6;enddata看到这个例子,可能会认为X被指定了1、4和2三个值,因为它们是数值列中前三个,而正确的答案是1、2和3。假设对象列有n个对象,LINGO在为对象指定值时,首先在n个对象的第1个索引处依次分配数值列中的前n个对象,然后在n个对象的第2个索引处依次分配数值列中紧接着的n个对象,以此类推。模型的所有数据属性值和集成员被单独放在数据部分,这可能是最规范的数据输入方式。3 LINGO中的函数3.1 逻辑运算符(Logical Operators)LogicalOperatorReturn Value#NOT#

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 中学教育 > 试题/考题 > 初中试题/考题

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号