AMPL_CPLEX Tutorial.ppt

上传人:京东小超市 文档编号:5952762 上传时间:2020-08-17 格式:PPT 页数:22 大小:116.50KB
返回 下载 相关 举报
AMPL_CPLEX Tutorial.ppt_第1页
第1页 / 共22页
AMPL_CPLEX Tutorial.ppt_第2页
第2页 / 共22页
亲,该文档总共22页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《AMPL_CPLEX Tutorial.ppt》由会员分享,可在线阅读,更多相关《AMPL_CPLEX Tutorial.ppt(22页珍藏版)》请在三一文库上搜索。

1、AMPL/CPLEX Tutorial,ESI 6316 Applications of OR in Manufacturing,吞窘旗袋藩臼张位路卷镜狙肾浚英禽颅舀盔遭秧阐志沁宠琅伦逞答兽扩帛AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,2,AMPL 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 l

2、ubricant_reqt: 0.2*x1 + 0.3*x2 = 0.5; subject to saudi_avail: x1 = 9; subject to venezuelan_avail: x1 = 6;,闸酮酱浴窖妨光棋璃争到皋摸署酋绍退唁浆架款恬馁抡狠冶班寇些煽纽朗AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,6,Running AMPL (2 var. LP),C:APML101ampl.exe,诱顷茵烤渭啪锹扼奴曲碧骚泊愿命沉篮柱搬糖乖楞掸蔡甄仙滤廊找剔寨须AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,7,Solv

3、ing bigger problems,Divided into two parts Model file (.mod) Consists of the mathematical model Sets Parameters Variables Objective function constraints Data file (.dat) Actual values for Sets and parameters,啪戎界盐詹澈西坛尖定嗡福佰靖辜疫蓬譬梅旦栋危博维佐辑雹哗簇其控恨AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,8,AMPL (Transportatio

4、n Problem),1400,2600,2900,900,1200,600,400,1700,1100,1000,Gary,Cleveland,Pittsburg,Steel Mills (Origin),Automobile Factories (Destination),Farmington,Detroit,Lansing,Windsor,St. Louis,Fremont,Lafayette,Supply in Tons,Demand in Tons,Total Production = Total Requirement,烦越看羽辣滔缠正妒肩粪欲艺巴芝陋挖涅剁充愈凹亡峻孺眯学纫鉴令菲

5、勇AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,9,AMPL (Transportation Problem),腾问例星矩曳首耕发叶泣哼剥确几磐策黔恩芹冤蹈纺益掏杀泡襄僵辽咀唱AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,10,AMPL (Transportation Problem),财二专谢粮纪孝萝刁硼攘杖因惜茂毫驻缝蛤污事突嚼岳褥纪惫娩络但兼谢AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,11,Model File transp.mod,set ORIG; # origins set DEST

6、; # destinations param supply ORIG = 0; # amounts available at origins param 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 unit var Trans ORIG,DEST = 0; # units to be shipped minimize Total_Cos

7、t: 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 Tutorial,12,Data File: transp.dat,data; param: ORIG: supply := #

8、 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 ;,歉摊

9、俱孙窒混怜士驹檄锰扇皑太迎扇鹏骑您聋跃噪衍涎出伴杜撰燃祷爸猪AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,13,Data File,You can also define the sets and param seperately e.g. data; set ORIG:=GARY CLEV PITT;# defines set ORIG set DEST:=FRA DET LAN WIN STL FRE LAF;# defines set DEST param supply := # defines param supply GARY 1400 CLEV 26

10、00 PITT 2900 ; param demand := # defines param demand FRA 900 DET 1200 LAN 600 WIN 400 STL 1700 FRE 1100 LAF 1000 ;,郸讶烃贡骡完胀蛾茵欲榆碍猾盯橙瞪赌登彰遭役营扩型选赦府拘扁第训偿AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,14,.mps file,MPS file format Developed by IBMs Mathematical Programming System Format for linear and integer prog

11、ramming problems Cannot be used for nonlinear problems AMPL Syntax to write .mps file write mtransp;,玉形再唉鸿友铬蜘油氓懂心窥痉汝饰搬驴拽熏网脐潮五对含丛墟笔雏龟挛AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,15,Understanding .mps,Sections NAME (title of the problem) ROWS Constraint type E(=), L(=), N (Objective) Row name COLUMNS Colum

12、n name Row name Coefficient (constraint and objective) RHS RHS value,因河穷星达副起颇徊秉打巩允沟挟致鲸拯痉展迟世俄畦惕组琵她森僧琴躯AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,16,CPLEX,Reading a file read transp optimize display solution variables -,称囊凛搭饶欢扦淮粉播脑克渝辉拄狱搂蒜史谎辽腻怪丁遏羡唐衷唉摄驹义AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,17,Interpretati

13、on of Columns,Variable Trans was indexed over the set ORIG and DEST,Defined the two sets in the following manner,楞墓阑镍呻位赚悍山凸力晚二椰故四眯泰靖种汛履袄壶蜡琴釜铰纵辞滥瞬AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,18,CPLEX,Some other commands change Used to change variable or constraint name Constraint sense Problem type RHS val

14、ue Etc display Used to view problem characteristics Sensitivity analysis Parameter settings Etc,每涡阶迄秸醛陛妇腔咯垂骇喘速侵吊情棍休守斤划象哪依旦惰确册看扎鹃AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,19,Class Assignment,Pi-Hybrids Model Construct a AMPL Model Make the corresponding data file Solve using AMPL Create a .mps file Use

15、CPLEX to read and optimize the above problem Verify both the results,茨型啦夷奖炼锹蓄网泰舀赌访瘁对凳暮很烹哦坏海湿污踊宋寿剑飞护脖戈AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,20,Script File,Script File Automatically load model file and data file Create random data Display formatted output Read from and write to text files. Etc. .scs

16、extension Executing a script file commands myscriptfile.scs;,饼炭潮基牢陷挟抬任序疫析辗莲奈东姿搬渴陪租巢嗅甫痰磷韭悦胳攫筒流AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,21,Example of script file for transportation problem,model transp.mod; data transp1.dat; solve; for i in ORIG,j in DEST if (Transi,j0) then printf %s%s%.0fn,i,j,Transi,

17、j; ,既网聚苔屁在瞬主痈杭足妊盘尊饲套元誊绢温垢汽赤况溶循见手卸况身景AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,22,Example of Script file for Pi-Hybrids problem,model 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; print

18、f 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 regions printf Region #%dn,r; forh in hybrids printf Hybrid #%d %d Bagsn,h,Yf,h,r; ,结柿担税肢迎亲垂迸炕敝洼戚米测猪化耀彬遭藕晒藐羡双辛习溢闸舷弄垂AMPL_CPLEX TutorialAMPL_CPLEX Tutorial,

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

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1