GAMS_软件介绍
《GAMS_软件介绍》由会员分享,可在线阅读,更多相关《GAMS_软件介绍(33页珍藏版)》请在装配图网上搜索。
1、GAMS简介 主要內容 agamsA统及特点 AGAMS模型整体结构 A GAMS语言分析 A工程应用实例 O GAMS系统及特点 • GAMS一 “ General Algebraic Modeling System^^ (一般桂代薮仿煮紊统)的缩写, 最早是1992年由美国的世界银行(World Bank)的 Meeraus 和 Brooke 所发展。 • GAMS是一种面向应用的构造模型的高级计 算机语言,融合了关系数据库技术与数学规 划理论,使数学模型与数据彼此独立,为用 户在模型、算法和数据之间提供了一个便捷 的接口。包含了编译器和高效能的求解引擎 • G
2、AMS提供的描述大型复杂模型的语舌 体系十分简洁,并将算法封装于系统内 部 •输入文件形式与模型描述的自然语言一 致,便于理解和掌握。 | •易于操作,封装的算法均可直接调用, 无须改变用户的模型描述。 •可求解各种类型的实际问题,女口LP (线 性规划)、NLP、ILP、MLP等 O Chemical Ensineerine: No. Name Model Type Alkylation Process Optimization 20 process nip Chemical Equilibrium Problem 21 diem nip Chemic
3、al Equilibrium Pioblem 76 wall nip Stmctiiral Optiimzation of Process Plowslieets 116 procsei miiilp Simultaneous Optimization for Hen S^itliesis 117 svnheat >1 mmlp Heat hitegiated Distillation Sequences 118 minlphi nip, imp Optimal Design for Chemical Batch Processing 119 batchd
4、es mmlp Synthesis of General Distillation Sequences 120 lions harp nip, mip Logical Infeience for Reaction path synthesis 121 reaction 1P Optimum Feed Plate Location 122 feedtrav mmlp Synthesis: Hvdrodealkvlation of Toluene 123 hda* liiinlp Chemical Equilibrium Problem as MCP 127
5、 wallmcp mcp Simplified Alkylation Process 16? alkvl ■ nip 举一个线性规划的例子 Shipping Distances Supplies Markets Plants New York Chicago Topeka Seattle 15 1.7 1.8 350 San Dieao Z5 L8 1.4 600 Demands 325 300 275 ・矩阵为供销地区的距离(单位:千公里) ・每公里运费为$90/千公里 ・Supplies一供应商的
6、生产量 • Demands一采购商的需求量 •优化曰标:运斎最低 运输问题数学语言描述 Indices: i = plants j = markets Given Data: %= supply of commodity of plant i (in cases) bj = demand for commodity at market / (cases) Qj = cost per unil shipment between plant i and market j ($/case) Decision Variables: X/j amount of comnux
7、lily Io ship from plant i to market j (casesX where t > 0, for all ij Constraints: Observe supply limit al plant i:〉.仏 < a. for all i (cases) Satisfy demand at market j\》产打 > /br all J (cases) Objective l unction: Minimi空工工儿 ($K) i canning pl ants- / E-eatt le., an-Diegi^ / j market.! / New
8、- York r Ch.icagar Topelta / ; GAMS 语言描述 FoK-3n=t>=177 a (i ] capac i Dy of pl ant ./ Seattle 2ari・ Diego in cacec 3&0 6DQ / b < j] demand at narket / York Zhiaago Top-ska in cases 325 300 2T5 / ; lV=w- York iZhicago -eattle 2・5 L •丁 S-an-Die-go 2・5 L.P Table d (i. j ] di
9、stance i n thcusands of n i Len in dz-llarc per cace per Topeka l.E 1.4 ; Scalar f freight thousand miles 790/ Parameter c ( i r j l trannpz-rt ods t in 1000s of -dollars p-=r case cCi. j) ■ f*dd, jJ/LODO ; Xr3fiablefl x(ij] shipment quantities in cases z total tranorportat
10、ion costs in lODOs of c3ollars ; Equations ods t supply l: i) di-mand (j ) Positive variable x ; z -e- sun( (i r j ). define objec:t:ive function obsein/e supply Lin it at plant i satisfy demsnd at market j - ODSt・・ supply I: i)・・ aum f j r x:i, j ] : -1- a •: i ; demand (j ) .. nun •: i ,
11、x (i r j J]・g・ b (j ); hfodel transport /all/ ; solve transport timing Ip minimizing 工 - display sc.l.工.n ; GAMS模型整体结构 Inputs • Sets (指定) • Data (Parameters, Tables, Scalar) • Variables • Equations • Model and Solve statements • Displav statement (opfionQl) GAMS模型整体结构 Outputs Echo Prin
12、t Eiror Messages Reference Maps Echo Print Reference Maps Equation Listings Model Statistics Status Reports Solution R 已 ports Remarks •先定义,再引用 •每条语句由分号结束 • GAMS编译器不区分大小写 •标注由星号引出,或将标注直接插入到 语句中 Equations包含等式和不等式约束 GAMS语言分析 • Sets 用于指定数学模型中的下标 i canning plants / Seattle, Edn-Di亡go
13、 / j markets J Hew-York. Chi cage P Topck-a /) 即定义:i代表生产地,j代表销售地 • Data (1) Lists Faraneters •a (i) of plan七 Sea t七].亡 San-Dieao in ca.5es 350 600 Q in cases 300 b (j ) demand at market j / New-York Chicago Topeka Remarks:所有参数默认初值为0 多字情况,例如,New York需要加连字符
14、 标量的定义如下: Scalar>f freight- in dollars per cass per thousand rr.iles / 9 0 / ; (2) Tables Topeka Table d( i. j 1 distance in thousands c-f riilec tfew- York iZhicago Seattle 2.5 1.7 -3n-Dii&gD 2.5 1 . E (3) Direct assignment (直接定义) Parameter c(i r j) tranopz-rt cost in IDDQs of dolliara p
15、eir cafse □ 16、 dollars ;
(3) 对自变量定义类型
Positive variable x ;
• Equations
(1)常用符号
Suit, (index of su^imationf 5t:m]T.and)
〜jXij. ―► Suir.( j , x (ir j ))
□j巧.―► prod (j r x (i< j ))
(2)定义步骤
定义等式的名称一运算的控制维一控制维的约束(可选) 一 标记“… 一^-左边表达 一符 一-右边表达式
⑶符号类型
=1=
=*3=
=e=
less than o 17、r equal to greater than or equal to equal to
(4)举例
Zquations
cost supply (i) deir.a.nd (j )
define objective function observe supply limit at plant i sa.-isfy demand at market j ;
cost. - z 二己二 suir.( (ir j ) r c (1/ j ) (iz j ));
supply (i) . . sum( j x (l,j) ) =1= a (i);
demand(j) . - sum ( 18、1f x(i z j)) =g- ;
Remark:在约束式的两边均可以出现变量,而且同一变量可以出现多次
(1) 模型定义
(2) 模型求解
(3) 求解方法
• Model And Solve
n-.odel transport /all/ ; all:包括所有的变量和等式
rr.cdel transport / ccstf supply, derriand / ;
solve transport us ing Ip z ;
lp for 19、 lineal* programming
nip for nonlinear programming mip for mixed integer programming rnip for relaxed mixed integer piogrammiiig ir.inlp for mixed integer nonlinear progranuning rrninlp for relaxed mixed mteger nonlmear progranuning ir.cp for mixed c□mpleiiieiitarify problems cns for constrained no 20、nlinear systems
• Display
(1)结果输出
display x.lr x.m ;
(2)输出类型
•丄 o = lower bound
・丄 = level or primal value
・ up = upper bound
・ m = marginal or dual value
.lo表示输出变量的下限
.1表示输出变量的最终结果
・up表示输出变量的上限
j . m表示输的边际效应
Outputs
Echo Print
Eiror Messages
Reference Maps
21、
27
Echo Print
Reference Maps
Equation Listings
Model Statistics
Status Reports
Solution Reports
Echo Prints
3
28
4
厶
sets
29
5
i canning plart5 / sestcle, san-diegc /
30
6
j markets / new-york, chicagor topeks / ;
31
7
32
8
parameters
33
22、
a
J
34
10
a(i) c&pscLty of plant i in cases
35
11
/ 3cS3tlc 35D
36
12
san-diegc GOO /
37
13
38
14
b(j) cenand a二 market ] in case3
39
15
/ new・york 325
40
16
Chicago 300
41
17
topeka 275 / ;
42
18
43
19
table d(i,j) distance i.r thousancs of ic 23、iles
44
20
new-ycrk Chicago topeka
45
21
seattlE 2.5 1.7 1.8
46
22
san・diEgo 2.5 1.8 1.4 /
47
2
48
r A 鎳
scalar z freight in collars per qasz per 100C ir.iles
“0/ ;
49
25
50
26
paxametEi c(i,j) trarspcrz cost in lOQGs cf dollars
per case;
51
c(ij)二 fM(irj)/1000 24、 ;
variables
x(if j) shipment quanin esses
z total transportution costs in 1000s of dollars;
positiv己 variable x ;
equations
cost define objictiv■己 function
supply (i) observe supply limit at plant i
demand (j) satisfy demand at market j ;
cost ・・ z =e= sum((i,j), c(1,j)(1,j));
supply(i) . 25、. sum{jr x(i,j)) =1= a(i);
demand (j)・■ 5um(ir x(ir j)) =g= b (j);
model transport /all/ ;
solve transport- using Ip zninimizing z ;
display x・l< x.m ;
27
Error Massages
set q quarterly time periods / spring, sum, allz wtr / ;
results in tlie echo
1 set. q quarterly time periods / spring, 26、 sum, fall 4 wtr / ;
**** $160
(2
\ parameter c (i,j) transport cost in 1000s of dollars per case )C (i,j) = * a(i,j)/ 1000 ;
16 parameter c (ir j) transport cost in 1000s of dollars per case
17 c(i7j) = f*d(irj)/1000
**** $97 $195$96$L94$1
ERROR MESSAGES
1 REAL NUMBER EXPECTED
96 BLANK NE 27、EDED BETWEEN IDENTIFIER AND TEXT
(-OR-ILLEGAL CHARACTER IN IDENTIFIER)
(・0R-CHECK FOR HISSING ;r ON PREVIOUS LINE)
97 EXPLANATORY TEXT CAN NOT START WITH or ■…,
(・0R-CHECK FOR MISSING ;r ON PREVIOUS LINE)
194 SYhEOL REDEFINED
195 SYMBOL REDEFINED WITH A DIFFERENT TYPE
Error Massages
⑶
4 se 28、ts
5 i canning plants /seattie, san/
6 j markets /new-york, Chicago, topeka / ;
7
7 table distance in thousand of miles
8 new-york Chicago topeka
9 seatie 2.5 1.7 1.8
**** $170
11
gan-diego 2.5
1.8
1.4
Status Reports
SOLVE
MCD5:L T RAM S PORT
TYFZ LF
SOLVER ECKL?
OBJ 29、ECTIVE Z
EIRECTZCN MINIMIZE
FROM LIKZ 49
SOLVZR STATUS
MODEL STATUS
OBJECTIVE VALUZ
1 NORMAL COMPLETION
1 OFTI2-IAL
153 • 750
RESOURCE USAGEz LIKIT
ITZRATION COUNT, LIMIT
0.1€8 1000・000
1000
」目标值
运算时间
迭代次数
下限
冃标值
上限
边际值
Solution
EQU SUPPLY
obser 30、ve supply liniT at
Massages
LOWER LEVEL UPPER >1ARG INAL
SEATTLE -INF SAN-DIEGO -INF
353.000 350.000
550.000 600.000
EQU DEMAND
satisfy demand at market j
NEW-YO^K
325
.000
325.000
+ INF
0.225
CHICAGO
300.
000
300.000
+IKF
0.153
TOPZKA
275.
000
31、275.000
+ IKF
0.126
LOW5R LEVEL
UPPZR M^RGIXAL
VAR X
shipment quantities in cases
LCGiER LEVZL •HEW-YORK ・
.CHICAGO ・ •TOPZKA •
SEATTLZ
SEAT7LZ
SEATTLE 3直卫-DIZGO ■ NEP;-YORK .SAN-DI EGO ・ CHICAGO SA2J-DIZGO. TCFEKA
UFFER MARGINAL
50・000 +INF ・
3GO ・000 +LNF ・
・ +INF 0.036
275.000 4-inf .
・ +INF 0.002
275.000 +INF ■
Thanks
Question ?
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。