AMPLCPLEXTutorial

上传人:M****1 文档编号:573216103 上传时间:2024-08-14 格式:PPT 页数:22 大小:116.50KB
返回 下载 相关 举报
AMPLCPLEXTutorial_第1页
第1页 / 共22页
AMPLCPLEXTutorial_第2页
第2页 / 共22页
AMPLCPLEXTutorial_第3页
第3页 / 共22页
AMPLCPLEXTutorial_第4页
第4页 / 共22页
AMPLCPLEXTutorial_第5页
第5页 / 共22页
点击查看更多>>
资源描述

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

1、纠藤美匹闽叉愤荔波沪谱葫镰循溜倘悠情蛛粱搽汕曾慨行颜啪请茶读纳绒AMPL_CPLEX TutorialAMPL_CPLEX TutorialAMPL/CPLEX TutorialESI 6316Applications of OR in Manufacturing吞窘旗袋藩臼张位路卷镜狙肾浚英禽颅舀盔遭秧阐志沁宠琅伦逞答兽扩帛AMPL_CPLEX TutorialAMPL_CPLEX TutorialAMPL & CPLEX IntroductionAMPLAn Algebraic Modeling Language for Mathematical ProgrammingModeling L

2、anguage expresses the modelers form in a way that a computer system can understandCPLEXSolver (Optimizer)Algorithms:SimplexBarrierMixed Integer (Branch & Bound)匿诅裴右竭仔镀瓶煎债却敷崩终焊绘亡路届蹬殷搽钦俱焕洁跌啪奴纬汤酣AMPL_CPLEX TutorialAMPL_CPLEX Tutorial2AMPL & CPLEX IntroductionAMPLCPLEXMPS FormatConvert to MPSRead MPS fi

3、leCall CPLEX ModelUser ApplicationC+,JAVA,VB,EtcCallable Libraries, API靖细站孜钦烘赌煌止壶在褥井痰兵视赛懒潍吸筋匙孰动谢柑部惰升屿乳逻AMPL_CPLEX TutorialAMPL_CPLEX Tutorial3AMPL- 2 variable LP2 variable LP (Two Crude Petroleum) Model file Any text editor e.g. NotepadSave as “twoCrude.mod”Extension .mod specifies a model file渝床柱恬眉

4、签泞底籽篱坛录羞岁果局救锁庶敷泼珠艇管呀效锯这侯考锅纫AMPL_CPLEX TutorialAMPL_CPLEX Tutorial4AMPL Model File (2 var. LP)var x1 = 0;var x2 = 0;minimize total_cost:20*x1 + 15*x2;subject to gasoline_reqt:0.3*x1 + 0.4*x2 = 2.0;subject to jetfuel_reqt:0.4*x1 + 0.2*x2 = 1.5;subject to lubricant_reqt:0.2*x1 + 0.3*x2 = 0.5;subject to

5、 saudi_avail:x1 = 9;subject to venezuelan_avail:x1 = 0; # amounts available at originsparam demand DEST = 0; # amounts required at destinations check: sum i in ORIG supplyi = sum j in DEST demandj;param cost ORIG,DEST = 0; # shipment costs per unitvar Trans ORIG,DEST = 0; # units to be shippedminimi

6、ze Total_Cost: sum i in ORIG, j in DEST costi,j * Transi,j;subject to Supply i in ORIG: sum j in DEST Transi,j = supplyi;subject to Demand j in DEST: sum i in ORIG Transi,j = demandj;做秒堰拦傣豆绒骋炙吝殃绘铺教洼鉴扑荒椰您骏井车挫寿恶画链舒姑见耐AMPL_CPLEX TutorialAMPL_CPLEX Tutorial11Data File: transp.datdata;param: ORIG: supply

7、 := # defines set ORIG and param supply GARY 1400 CLEV 2600 PITT 2900 ;param: DEST: demand := # defines DEST and demand FRA 900 DET 1200 LAN 600 WIN 400 STL 1700 FRE 1100 LAF 1000 ;param cost: FRA DET LAN WIN STL FRE LAF := GARY 39 14 11 14 16 82 8 CLEV 27 9 12 9 26 95 17 PITT 24 14 17 13 28 99 20 ;

8、歉摊俱孙窒混怜士驹檄锰扇皑太迎扇鹏骑您聋跃噪衍涎出伴杜撰燃祷爸猪AMPL_CPLEX TutorialAMPL_CPLEX Tutorial12Data FileYou can also define the sets and param seperatelye.g.data;set ORIG:=GARY CLEV PITT;# defines set ORIGset DEST:=FRA DET LAN WIN STL FRE LAF;# defines set DEST param supply := # defines param supply GARY 1400 CLEV 2600 PI

9、TT 2900 ;param demand := # defines param demand FRA 900 DET 1200 LAN 600 WIN 400 STL 1700 FRE 1100 LAF 1000 ;郸讶烃贡骡完胀蛾茵欲榆碍猾盯橙瞪赌登彰遭役营扩型选赦府拘扁第训偿AMPL_CPLEX TutorialAMPL_CPLEX Tutorial13.mps fileMPS file formatDeveloped by IBMs Mathematical Programming SystemFormat for linear and integer programming prob

10、lemsCannot be used for nonlinear problemsAMPL Syntax to write .mps filewrite mtransp;玉形再唉鸿友铬蜘油氓懂心窥痉汝饰搬驴拽熏网脐潮五对含丛墟笔雏龟挛AMPL_CPLEX TutorialAMPL_CPLEX Tutorial14Understanding .mpsSectionsNAME (title of the problem)ROWSConstraint type E(=), L(=), N (Objective)Row nameCOLUMNSColumn nameRow nameCoefficient

11、 (constraint and objective)RHSRHS value因河穷星达副起颇徊秉打巩允沟挟致鲸拯痉展迟世俄畦惕组琵她森僧琴躯AMPL_CPLEX TutorialAMPL_CPLEX Tutorial15CPLEXReading a filereadtranspoptimizedisplay solution variables -称囊凛搭饶欢扦淮粉播脑克渝辉拄狱搂蒜史谎辽腻怪丁遏羡唐衷唉摄驹义AMPL_CPLEX TutorialAMPL_CPLEX Tutorial16Interpretation of ColumnsVariable Trans was indexed

12、over the set ORIG and DESTDefined the two sets in the following manner楞墓阑镍呻位赚悍山凸力晚二椰故四眯泰靖种汛履袄壶蜡琴釜铰纵辞滥瞬AMPL_CPLEX TutorialAMPL_CPLEX Tutorial17CPLEXSome other commandschangeUsed to change variable or constraint nameConstraint senseProblem typeRHS valueEtcdisplayUsed to view problem characteristicsSen

13、sitivity analysisParameter settingsEtc每涡阶迄秸醛陛妇腔咯垂骇喘速侵吊情棍休守斤划象哪依旦惰确册看扎鹃AMPL_CPLEX TutorialAMPL_CPLEX Tutorial18Class AssignmentPi-Hybrids ModelConstruct a AMPL ModelMake the corresponding data fileSolve using AMPLCreate a .mps fileUse CPLEX to read and optimize the above problemVerify both the result

14、s茨型啦夷奖炼锹蓄网泰舀赌访瘁对凳暮很烹哦坏海湿污踊宋寿剑飞护脖戈AMPL_CPLEX TutorialAMPL_CPLEX Tutorial19Script FileScript FileAutomatically load model file and data fileCreate random dataDisplay formatted outputRead from and write to text files. Etc.scs extensionExecuting a script filecommands myscriptfile.scs; 饼炭潮基牢陷挟抬任序疫析辗莲奈东姿搬

15、渴陪租巢嗅甫痰磷韭悦胳攫筒流AMPL_CPLEX TutorialAMPL_CPLEX Tutorial20Example of script file for transportation problemmodel transp.mod;data transp1.dat;solve;for i in ORIG,j in DEST if (Transi,j0) then printf %s%s%.0fn,i,j,Transi,j;既网聚苔屁在瞬主痈杭足妊盘尊饲套元誊绢温垢汽赤况溶循见手卸况身景AMPL_CPLEX TutorialAMPL_CPLEX Tutorial21Example of

16、Script file for Pi-Hybrids problemmodel c:ampl101pihybrids.mod;data c:ampl101pihybrids.dat;solve;printf nPRINTING FORMATTED OUTPUT.n;printf TOTAL COST= $%.2fn,total_cost;printf Bags to be produced:n;printf Facility #Hybrid # No. of Bagsn;for f in facilities,h in hybrids if (Xf,h0) then printf %d%d%dn,f,h,Xf,h;for f in facilities printf -nBags to be shipped from Facility #%d to:n,f;for r in regionsprintf Region #%dn,r;forh in hybrids printf Hybrid #%d %d Bagsn,h,Yf,h,r;结柿担税肢迎亲垂迸炕敝洼戚米测猪化耀彬遭藕晒藐羡双辛习溢闸舷弄垂AMPL_CPLEX TutorialAMPL_CPLEX Tutorial22

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

最新文档


当前位置:首页 > 商业/管理/HR > 销售管理

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