LINGO软件程序.docx

上传人:b****5 文档编号:6892579 上传时间:2023-01-12 格式:DOCX 页数:15 大小:20.69KB
下载 相关 举报
LINGO软件程序.docx_第1页
第1页 / 共15页
LINGO软件程序.docx_第2页
第2页 / 共15页
LINGO软件程序.docx_第3页
第3页 / 共15页
LINGO软件程序.docx_第4页
第4页 / 共15页
LINGO软件程序.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

LINGO软件程序.docx

《LINGO软件程序.docx》由会员分享,可在线阅读,更多相关《LINGO软件程序.docx(15页珍藏版)》请在冰豆网上搜索。

LINGO软件程序.docx

LINGO软件程序

LINGO软件程序

程序一:

MODEL:

SETS:

!

Dynamicprogrammingillustration(seeAnderson,

Sweeney&Williams,AnIntrotoMgtScience,

6thEd.).Wehaveanetworkof10cities.We

wanttofindthelengthoftheshortestroute

fromcity1tocity10.;

!

Hereisourprimitivesetoftencities,where

F(i)representstheshortestpathdistance

fromcityitothelastcity;

CITIES/1..10/:

F,CONPATH;

!

ThederivedsetROADSliststheroadsthat

existbetweenthecities(note:

notallcity

pairsaredirectlylinkedbyaroad,androads

areassumedtobeoneway.);

ROADS(CITIES,CITIES)/

1,21,31,4

2,52,62,7

3,53,63,7

4,54,6

5,85,9

6,86,9

7,87,9

8,109,10/:

D,RONPATH;

!

D(i,j)isthedistancefromcityitoj;

ENDSETS

DATA:

!

Herearethedistancesthatcorrespondtothe

abovelinks;

D=

152

131211

6104

1214

39

65

810

52;

ENDDATA

!

Ifouarealreadyinlastcity,thenthecostto

traveltoitis0;

F(@SIZE(CITIES))=0;

!

Thefollowingistheclassicdynamicprogramming

recursion.Inwords,theshortestdistancefrom

Cityitolastcityistheminimumoverall

citiesjreachablefromiofthesumofthe

distancefromitojplustheminimaldistance

fromjtolastcity;

@FOR(CITIES(i)|i#LT#@SIZE(CITIES):

F(i)=@MIN(ROADS(i,j):

D(i,j)+F(j));

);

!

SetCONPATH(j)>0ifcityjisonanycriticalpath,

i.e.,ifgoingtojfromsomeionthecriticalpath,

stillallowsustogettolastcityinoptimaltime;

CONPATH

(1)=1;

@FOR(CITIES(j)|j#GT#1:

CONPATH(j)=@MAX(ROADS(i,j):

CONPATH(i)*((F(I)-F(j)#EQ#D(i,j))));

);

!

SetRONPATH(i,j)=1ifarci,jisonanycriticalpath,

i.e.,bothiandjareonpathand(i,j)isshortestpath

fromitoj.Note,wedonotassumedistancessatisfy

triangleinequality;

@FOR(ROADS(i,j):

RONPATH(I,J)=

@SMIN(CONPATH(i),CONPATH(j))*((F(i)-F(j))#EQ#D(i,j));

);

END

程序二:

MODEL:

!

TheMexicanSteelproblem;

SETS:

!

Steelplants;

PLANT/AHMSAFUNDIDASICARTSAHYLSAHYLSAP/:

RD2,MUE;

!

Markets;

MARKET/MEXICOMONTEGUADA/:

DD,RD3,MUV;

!

Finalproducts;

CF/STEEL/:

PV,PE,EB;

!

Intermediateproducts;

CI/SPONGEPIGIRON/;

!

Rawmaterials;

CR/PELLETSCOKENATGASELECTRICSCRAP/:

PD;

!

Processes;

PR/PIGIRON1SPONGE1STEELOHSTEELELSTEELBOF/;

!

Productiveunits;

UNIT/BLASTFUROPENHEARBOFDIRECTELECARC/;

!

;

CRXP(CR,PR):

A1;CIXP(CI,PR):

A2;

CFXP(CF,PR):

A3;UXP(UNIT,PR):

B;

UXI(UNIT,PLANT):

K;

PXM(PLANT,MARKET):

RD1,MUF;

PXI(PR,PLANT):

Z;

CFXPXM(CF,PLANT,MARKET):

X;

CRXI(CR,PLANT):

U;CFXI(CF,PLANT):

E;

CFXM(CF,MARKET):

D,V;

ENDSETS

!

Demandequations;

@FOR(CFXM(C,J):

D(C,J)=5.209*(1+40/100)*DD(J)/100);

!

Transportrateequations;

@FOR(PXM(I,J)|RD1(I,J)#GT#0:

MUF(I,J)=2.48+.0084*RD1(I,J));

@FOR(PXM(I,J)|RD1(I,J)#LE#0:

MUF(I,J)=0);

@FOR(PLANT(I)|RD2(I)#GT#0:

MUE(I)=2.48+.0084*RD2(I));

@FOR(PLANT(I)|RD2(I)#LE#0:

MUE(I)=0);

@FOR(MARKET(J)|RD3(J)#GT#0:

MUV(J)=2.48+.0084*RD3(J));

@FOR(MARKET(J)|RD3(J)#LE#0:

MUV(J)=0);

!

ForeachplantI1;

@FOR(PLANT(I1):

!

Sources>=uses,finalproducts;

@FOR(CF(CF1):

[MBF]

@SUM(PR(P1):

A3(CF1,P1)*Z(P1,I1))>=

@SUM(MARKET(J1):

X(CF1,I1,J1))+

E(CF1,I1));

!

Intermediateproducts;

@FOR(CI(CI1):

[MBI]

@SUM(PR(P1):

A2(CI1,P1)*

Z(P1,I1))>=0);

!

Rawmaterials;

@FOR(CR(CR1):

[MBR]

@SUM(PR(P1):

A1(CR1,P1)*

Z(P1,I1))+U(CR1,I1)>=0);

!

CapacityofeachproductiveunitM1;

@FOR(UNIT(M1):

[CC]

@SUM(PR(P1):

B(M1,P1)*Z(P1,I1))<=

K(M1,I1));

);

!

ForeachfinalproductCF1;

@FOR(CF(CF1):

!

DemandrequirementsforeachmarketJ1;

@FOR(MARKET(J1):

[MR]

@SUM(PLANT(I1):

X(CF1,I1,J1))+V(CF1,J1)

>=D(CF1,J1));

!

Upperlimitonexports;

[ME]@SUM(PLANT(I1):

E(CF1,I1))<=EB(CF1);

);

!

Componentsofobjective;

PHIPSI=@SUM(CR(CR1):

@SUM(PLANT(I1):

PD(CR1)*U(CR1,I1)));

PHILAM=@SUM(CF(CF1):

@SUM(PLANT(I1):

@SUM(MARKET(J1):

MUF(I1,J1)*

X(CF1,I1,J1)))+@SUM(MARKET(J1):

MUV(J1)*V(CF1,J1))+@SUM(PLANT(I1):

MUE(I1)*E(CF1,I1)));

PHIPI=@SUM(CFXM(CF1,I1):

PV(CF1)*V(CF1,I1));

PHIEPS=@SUM(CFXP(CF1,I1):

PE(CF1)*E(CF1,I1));

[OBJROW]MIN=PHIPSI+PHILAM+PHIPI-PHIEPS;

DATA:

A1=-1.58,-1.38,0,0,0,

-0.63,0,0,0,0,

0,-0.57,0,0,0,

0,0,0,-0.58,0,

0,0,-0.33,0,-0.12;

A2=1,0,-0.77,0,-0.95,

0,1,0,-1.09,0;

A3=0,0,1,1,1;

B=10000

00100

00001

01000

00010;

K=3.25,1.40,1.10,0,0,

1.50,0.85,0,0,0,

2.07,1.50,1.30,0,0,

0,0,0,0.98,1,

0,0,0,1.13,0.56;

RD1=12042181125

101701030

8191305704

101701030

1851085760;

RD2=739,521,0,521,315;

RD3=428,521,300;

PD=18.7,52.17,14,24,105;

PV=150;

PE=140;

EB=1;

DD=55,30,15;

ENDDATA

END

程序三:

MODEL:

!

TheVehicleRoutingProblem(VRP);

!

************************************;

!

WARNING:

Runtimesforthismodel;

!

increasedramaticallyasthenumber;

!

ofcitiesincrease.Formulations;

!

withmorethanadozencities;

!

WILLNOTSOLVEinareasonable;

!

amountoftime!

;

!

************************************;

SETS:

!

Q(I)istheamountrequiredatcityI,

U(I)istheaccumulateddeliversatcityI;

CITY/1..8/:

Q,U;

!

DIST(I,J)isthedistancefromcityItocityJ

X(I,J)is0-1variable:

Itis1ifsomevehicle

travelsfromcityItoJ,0ifnone;

CXC(CITY,CITY):

DIST,X;

ENDSETS

DATA:

!

city1representthecommondepo;

Q=063771845;

!

distancefromcityItocityJissamefromcity

JtocityIdistancefromcityItothedepotis

0,sincethevehiclehastoreturntothedepot;

DIST=!

ToCity;

!

ChiDenFrsnHousKCLAOaklAnahFrom;

099621621067499205421342050!

Chicago;

0011671019596105912271055!

Denver;

01167017471723214168250!

Fresno;

0101917470710153819041528!

Houston;

059617237100158918271579!

K.City;

0105921415381589037136!

L.A.;

01227168190418273710407!

Oakland;

0105525015281579364070;!

Anaheim;

!

VCAPisthecapacityofavehicle;

VCAP=18;

ENDDATA

!

Minimizetotaltraveldistance;

MIN=@SUM(CXC:

DIST*X);

!

Foreachcity,exceptdepot....;

@FOR(CITY(K)|K#GT#1:

!

avehicledoesnottravalinsideitself,...;

X(K,K)=0;

!

avehiclemustenterit,...;

@SUM(CITY(I)|I#NE#K#AND#(I#EQ#1#OR#

Q(I)+Q(K)#LE#VCAP):

X(I,K))=1;

!

avehiclemustleaveitafterservice;

@SUM(CITY(J)|J#NE#K#AND#(J#EQ#1#OR#

Q(J)+Q(K)#LE#VCAP):

X(K,J))=1;

!

U(K)isatleastamountneededatKbutcan't

exceedcapacity;

@BND(Q(K),U(K),VCAP);

!

IfKfollowsI,thencanboundU(K)-U(I);

@FOR(CITY(I)|I#NE#K#AND#I#NE#1:

U(K)>=U(I)+Q(K)-VCAP+VCAP*

(X(K,I)+X(I,K))-(Q(K)+Q(I))

*X(K,I);

);

!

IfKis1ststop,thenU(K)=Q(K);

U(K)<=VCAP-(VCAP-Q(K))*X(1,K);

!

IfKisnot1ststop...;

U(K)>=Q(K)+@SUM(CITY(I)|

I#GT#1:

Q(I)*X(I,K));

);

!

MaketheX'sbinary;

@FOR(CXC:

@BIN(X));

!

Minimumno.vehiclesrequired,fractional

androunded;

VEHCLF=@SUM(CITY(I)|I#GT#1:

Q(I))/VCAP;

VEHCLR=VEHCLF+1.999-

@WRAP(VEHCLF-.001,1);

!

Mustsendenoughvehiclesoutofdepot;

@SUM(CITY(J)|J#GT#1:

X(1,J))>=VEHCLR;

END

程序四:

MODEL:

MIN=10*W88+18*W87+23*W86+28*W85+33*W84+38*W83+43*W82+48*W81+16*W78+8*W77+16*W76+21*W75+26*W74+31*W73+36*W72+41*W71+19*W68+14*W67+6*W66+14*W65+19*W64+24*W63+29*W62+34*W61+22*W58+17*W57+12*W56+4*W55+12*W54+17*W53+22*W52+27*W51+25*W48+20*W47+15*W46+10*W45+2*W44+10*W43+15*W42+20*W41+28*W38+23*W37+18*W36+13*W35+8*W34+8*W32+13*W31+40*W28+35*W27+30*W26+25*W25+20*W24+15*W23+7*W22+15*W21+52*W18+47*W17+42*W16+37*W15+32*W14+27*W13+22*W12+14*W11;

!

Probabilitiessumto1;

W88+W87+W86+W85+W84+W83+W82+W81+W78+W77+W76+W75+W74+W73+W72+W71+W68+W67+W66+W65+W64+W63+W62+W61+W58+W57+W56+W55+W54+W53+W52+W51+W48+W47+W46+W45+W44+W43+W42+W41+W38+W37+W36+W35+W34+W33+W32+W31+W28+W27+W26+W25+W24+W23+W22+W21+W18+W17+W16+W15+W14+W13+W12+W11=1;

!

Prob{outofstate1}-Prob{intostate1}=0;

-.4*W82-.5*W81-.4*W72-.5*W71-.4*W62-.5*W61-.4*W52-.5*W51-.4*W42-.5*W41-.4*W32-.5*W31-.4*W22-.5*W21+W18+W17+W16+W15+W14+W13+.6*W12+.5*W11=0;

!

Intostate2;

-.4*W83-.1*W82-.5*W81-.4*W73-.1*W72-.5*W71-.4*W63-.1*W62-.5*W61-.4*W53-.1*W52-.5*W51-.4*W43-.1*W42-.5*W41-.4*W33-.1*W32-.5*W31+W28+W27+W26+W25+W24+.6*W23+.9*W22+.5*W21-.4*W13-.1*W12-.5*W11=0;

!

Intostate3;

-.4*W84-.1*W83-.5*W82-.4*W74-.1*W73-.5*W72-.4*W64-.1*W63-.5*W62-.4*W54-.1*W53-.5*W52-.4*W44-.1*W43-.5*W42+W38+W37+W36+W35+.6*W34+.9*W33+.5*W32+W31-.4*W24-.1*W23-.5*W22-.4*W14-.1*W13-.5*W12=0;

!

Intostate4;

-.4*W85-.1*W84-.5*W83-.4*W75-.1*W74-.5*W73-.4*W65-.1*W64-.5*W63-.4*W55-.1*W54-.5*W53+W48+W47+W46+.6*

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

当前位置:首页 > 法律文书 > 调解书

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

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