Lingo案例分析报告.docx

上传人:b****8 文档编号:11209361 上传时间:2023-02-25 格式:DOCX 页数:61 大小:429.43KB
下载 相关 举报
Lingo案例分析报告.docx_第1页
第1页 / 共61页
Lingo案例分析报告.docx_第2页
第2页 / 共61页
Lingo案例分析报告.docx_第3页
第3页 / 共61页
Lingo案例分析报告.docx_第4页
第4页 / 共61页
Lingo案例分析报告.docx_第5页
第5页 / 共61页
点击查看更多>>
下载资源
资源描述

Lingo案例分析报告.docx

《Lingo案例分析报告.docx》由会员分享,可在线阅读,更多相关《Lingo案例分析报告.docx(61页珍藏版)》请在冰豆网上搜索。

Lingo案例分析报告.docx

Lingo案例分析报告

最小费用运输问题

位销地

产地

B1

B2

B3

B4

B5

B6

B7

B8

产量

A1

6

2

6

7

4

2

5

9

60

A2

4

9

5

3

8

5

8

2

55

A3

5

2

1

9

7

4

3

3

51

A4

7

6

7

3

9

2

7

1

43

A5

2

3

9

5

7

2

6

5

41

A6

5

5

2

2

8

1

4

3

52

销量

35

37

22

32

41

32

43

38

280/302 

i.e:

model:

!

6发点8收点运输问题;

sets:

warehouses/wh1..wh6/:

capacity;

vendors/v1..v8/:

demand;

links(warehouses,vendors):

cost,volume;

endsets

!

目标函数;

min=sum(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=605551434152;

demand=3537223241324338;

cost=62674295

49538582

52197433

76739271

23957265

55228143;

enddata

1LINGO中的集

1.1TheSetsSectionofaModel

SetsaredefinedinanoptionalsectionofaLINGOmodel,calledthesetssection.BeforeyouusesetsinaLINGOmodel,youhavetodefinetheminthesetssectionofthemodel.ThesetssectionbeginswiththekeywordSETS:

(includingthecolon),andendswiththekeywordENDSETS.Amodelmayhavenosetssection,asinglesetssection,ormultiplesetssections.Asetssectionmayappearanywhereinamodel.Theonlyrestrictionisyoumustdefineasetanditsattributesbeforetheyarereferencedinthemodel'sconstraints.

1.2DefiningPrimitiveSets

Todefineaprimitivesetinasetssection,youspecify:

✓thenameoftheset,

✓optionally,itsmembers(objectscontainedintheset),and

✓optionally,anyattributesthemembersofthesetmayhave.

Aprimitivesetdefinitionhasthefollowingsyntax:

setname[/member_list/][:

attribute_list];

Whenusingimplicitsetmemberlists,youdonothavetolistanameforeachsetmember.Usethefollowingsyntaxwhenusinganimplicitsetmemberlist:

setname/member1..memberN/[:

attribute_list];

wheremember1isthenameofthefirstmemberinthesetandmemberNisthenameofthelastmember.LINGOautomaticallygeneratesalltheintermediatemembernamesbetweenmember1andmemberN.Whilethiscanbeaverycompactandconvenientmethodforbuildingaprimitiveset,thereisonecatchinthatonlycertainformatsofnamesareacceptedfortheinitialandterminalmembernames.Thefollowingtabledetailstheavailableoptions:

ImplicitMember

ListFormat

ExampleSetMembers

1..n

1..5

1,2,3,4,5

stringM..stringN

TRUCKS3..TRUCKS204

TRUCK3,TRUCK4,...,TRUCK204

dayM..dayN

MON..FRI

MON,TUE,WED,THU,FRI

monthM..monthN

OCT..JAN

OCT,NOV,DEC,JAN

monthYearM..monthYearN

OCT2001..JAN2002

OCT2001,NOV2001,DEC2001,JAN2002

i.e1:

!

集部分;

sets:

students:

sex,age;

endsets

!

数据部分;

data:

students,sex,age=John116

Jill014

Rose017

Mike113;

enddata

i.e2:

data:

NUMBER_OF_WH=6;

enddata

sets:

WAREHOUSES/1..NUMBER_OF_WH/:

CAPACITY;

endsets

1.3DefiningDerivedSets

Todefineaderivedset,youspecify:

✓thenameoftheset,

✓itsparentsets,

✓optionally,itsmembers,and

✓optionally,anyattributesthesetmembershave.

Aderivedsetdefinitionhasthefollowingsyntax:

setname(parent_set_list)[/member_list/][:

attribute_list];

i.e3:

sets:

product/A,B/;

machine/M,N/;

week/1..2/;

allowed(product,machine,week);

endsets

allowedSetMembership:

IndexMember

1(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#0:

friend;

!

男学生和女学生的友好程度大于0.5的集;

linkmf2(linkmf)|friend(&1,&2)#ge#0.5:

x;

endsets

data:

sex,age=116

014

017

013;

friend=0.30.50.6;

enddata

Note:

竖线是用来标记一个成员资格过滤器的开始。

#eq#表示逻辑运算符,相等为真,&1表示派生集的第1个原始父集的索引,它取遍该原始父集的所有成员;,&2表示派生集的第2个原始父集的索引,它取遍该原始父集的所有成员;……以此类推。

2LINGO中的数据部分

数据部分提供了模型相对静止部分和数据分离的可能性。

数据部分以关键字“data:

”开始,以关键字“enddata”结束。

在这里,可以指定集成员、集的属性。

其语法如下:

object_list=value_list;

对象列(object_list)包含要指定值的属性名、要设置集成员的集名,用逗号或空格隔开。

一个对象列中至多有一个集名,而属性名可以有任意多。

如果对象列中有多个属性名,那么它们的类型必须一致。

如果对象列中有一个集名,那么对象列中所有的属性的类型就是这个集。

数值列(value_list)包含要分配给对象列中的对象的值,用逗号或空格隔开。

注意属性值的个数必须等于集成员的个数。

i.e:

sets:

set1/A,B,C/:

X,Y;

endsets

data:

X=1,2,3;

Y=4,5,6;

enddata

也可采用复合数据声明(datastatement)实现同样的功能。

i.e:

sets:

set1/A,B,C/:

X,Y;

endsets

data:

X,Y=14

25

36;

enddata

看到这个例子,可能会认为X被指定了1、4和2三个值,因为它们是数值列中前三个,而正确的答案是1、2和3。

假设对象列有n个对象,LINGO在为对象指定值时,首先在n个对象的第1个索引处依次分配数值列中的前n个对象,然后在n个对象的第2个索引处依次分配数值列中紧接着的n个对象,……,以此类推。

模型的所有数据——属性值和集成员——被单独放在数据部分,这可能是最规的数据输入方式。

3LINGO中的函数

3.1逻辑运算符(LogicalOperators)

LogicalOperatorReturnValue

#NOT#TRUEiftheoperandimmediatelytotherightisFALSE,elseFALSE.

#EQ#TRUEifbothoperandsareequal,elseFALSE.

#NE#TRUEifbothoperandsarenotequal,elseFALSE.

#GT#TRUEiftheleftoperandisstrictlygreaterthantherightoperand,elseFALSE.

#GE#TRUEiftheleftoperandisgreater-than-or-equal-totherightoperand,elseFALSE.

#LT#TRUEiftheleftoperandisstrictlylessthantherightoperand,elseFALSE.

#LE#TRUEiftheleftoperandisless-than-or-equal-totherightoperand,elseFALSE.

#AND#TRUEonlyifbothargumentsareTRUE,elseFALSE.

#OR#FALSEonlyifbothitsargumentsareFALSE,elseTRUE.

Thepriorityrankingofthelogicaloperatorsis:

PriorityLevelOperator(s)

Highest#NOT#

#EQ##NE##GT##GE##LT##LE#

Lowest#AND##OR#

3.2数学运算符(MathematicalFunctions)

LINGOoffersanumberofstandard,mathematicalfunctions.Thesefunctionsreturnasingleresultbasedononeormorescalararguments.Thesefunctionsarelistedbelow:

ABS(X)

ThisreturnstheabsolutevalueofX.

COS(X)

ThisreturnsthecosineofX,whereXisanangleinradians.

EXP(X)

Thisreturnse(2.718281...)raisedtothepowerX.

FLOOR(X)

ThisreturnstheintegerpartofX.Tobespecific,ifX>=0,FLOORreturnsthelargestinteger,I,suchthatI<=X.IfXisnegative,FLOORreturnsthemostnegativeinteger,I,suchthatI>=X.

LGM(X)

Thisreturnsthenatural(basee)logarithmofthegammafunctionofX(i.e.,logof(X-1)!

).ItisextendedtononintegervaluesofXbylinearinterpolation.

Note:

伽玛方程表达式为:

Γ(x)=∫e^(-t)*t^(x-1)dt(积分的下限式0,上限式+∞)

  利用分部积分法(integrationbyparts)我们可以得到

  Γ(x)=(x-1)*Γ(x-1)

LOG(X)

ThisreturnsthenaturallogarithmofX.

MOD(X,Y)

ThisreturnsthevalueofXmoduloY,or,inotherwords,theremainderofanintegerdivideofXbyY.

POW(X,Y)

ThisreturnsthevalueofXrasiedtotheYpower.

SIGN(X)

Thisreturns-1ifX<0.Otherwise,itreturns+1.

SIN(X)

ThisreturnsthesineofX,whereXistheangleinradians.

SMAX(X1,X2,...,XN)

ThisreturnsthemaximumvalueofX1,X2,...,andXN.

SMIN(X1,X2,...,XN)

ThisreturnstheminimumvalueofX1,X2,...,andXN.

SQR(X)

ThisreturnsthevalueofXsquared.

SQRT(X)

ThisreturnsthesquarerootofX.

TAN(X)

ThisreturnsthetangentofX,whereXistheangleinradians

3.3金融函数(FinancialFunctions)

LINGOcurrentlyofferstwofinancialfunctions.Onecomputesthepresentvalueofanannuity.Theotherreturnsthepresentvalueofalumpsum.

FPA(I,N)

Thisreturnsthepresentvalueofanannuity.Thatis,astreamof$1paymentsperperiodataninterestrateofIforNperiodsstartingoneperiodfromnow.Iisnotapercentage,butafractionrepresentingtheinterestrate(e.g.,youwoulduse.1torepresent10%).Togetthepresentvalueofanannuitystreamof$Xpayments,multiplytheresultbyX.

返回如下情形的净现值:

单位时段利率为I,连续n个时段支付,每个时段支付单位费用。

若每个时段支付x单位的费用,则净现值可用x乘以fpa(I,n)算得。

fpa的计算公式为

净现值就是在一定时期为了获得一定收益在该时期初所支付的实际费用。

年值,用A(Annuity)表示。

它表示发生在每年的等额现金流量,即在某个特定时间序列,每隔相同时间收入或支出的等额资金。

在工程经济分析计算中,如无特别说明,一般约定A发生在期末,如第1年末、第2年末等。

i.e:

贷款买房问题贷款金额50000元,贷款年利率5.31%,采取分期付款方式(每年年末还固定金额,直至还清)。

问拟贷款10年,每年需偿还多少元?

LINGO代码如下:

50000=x*fpa(.0531,10);

结果:

Feasiblesolutionfound.

Totalsolveriterations:

0

VariableValue

X6573.069

RowSlackorSurplus

10.000000

FPL(I,N)

Thisreturnsthepresentvalueofalumpsumof$1NperiodsfromnowiftheinterestrateisIperperiod.Iisnotapercentage,butafractionrepresentingtheinterestrate(e.g.,youwoulduse.1torepresent10%).Togetthepresentvalueofalumpsumof$X,multiplytheresultbyX.

返回如下情形的净现值:

单位时段利率为I,第n个时段支付单位费用。

fpl(I,n)的计算公式为

以上两个函数存在的关系为:

3.4概论函数(ProbabilityFunctions)

LINGOhasanumberofprobabilityrelatedfunctions.ThereareexamplesthatmakeuseofmostofthesefunctionsinDevelopingMoreAdvancedModelsandinAdditionalExamplesofLINGOModeling.

PBN(P,N,X)二项分布的累积分布函数

Thisisthecumulativebinomialprobability.ItreturnstheprobabilitythatasampleofNitems,fromauniversewithafractionofPofthoseitemsdefective,hasXorlessdefectiveitems.Itisextendedtonon-integervaluesofXandNbylinearinterpolation.

PCX(N,X)自由度为n的χ2分布的累积分布函数

ThisisthecumulativedistributionfunctionfortheChi-squareddistributionwithNdegreesoffreedom.Itreturnstheprobabilitythatanobservationfromthisdistributionisless-than-or-equal-toX.

PEB(A,X)当到达负荷为a,服务系统有x个服务器且允许无穷排队时的Erlang繁忙概率

ThisisErlang抯busyprobabilityforaservicesystemwithXserversandanarrivingloadofA,withinfinitequeueallowed.TheresultofPEBcanbeinterpretedaseitherthefractionoftimeallserversarebusyorthefractionofcustomersthatmustwaitinthequeue.ItisextendedtononintegervaluesofXbylinearinterpolation.Thearrivingload,A,istheexpectednumberofcustomersarrivingperunitoftimemultipliedbytheexpectedtimetoprocessonecustomer.

PEL(A,X)当到达负荷为a,服务系统有x个服务器且不允许排队时的Erlang繁忙概率。

ThisisErlang抯lossprobabilityforaservicesystemwithXserversandanarrivinglo

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报 > 实习总结

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1