Professional Documents
Culture Documents
Lutz Westermann, Gams Software GMBH
Lutz Westermann, Gams Software GMBH
I www.gams.com
GAMS
Company Background
GAMS Development
Corporation
(Washington)
Tool Provider:
General Algebraic
Modeling System
Agenda
What is GAMS?
Algebraic Modeling Languages - A Success
Story
GAMS - Highlights and Design Principles
Striving for Innovation and Compatibility
New Modeling and Solution Concepts
Software Quality Assurance
A Simple Example
GAMS
GAMS
ANALYST
GENERAL ALGEBRAIC
MODELING SYSTEM
OLUTIO
RESULT:
of models
GAMS
-,
.... .. .
..
. ..
-,
.j
.. . .
M!JJlJ!"!~f
/ . . IGAM~.\
\..
..
.... ... .\
\. D
. ..
LINDO SYSTEMS)
G)s
..
Do not solve problems directly, but offer links to state-ofthe-art algorithms {"solver-links"}
GAMS
GAMS
1
Important vehicle to
make mathematical
optimization available
to a broader audience,
e.g. domain specific
experts
Simplified model
development, changes,
and transfer
Increased productivity,
quality, reliability and
maintainability
Problem
2.
Mathematics
3.
Programming
4.
Performance
5.
Scalability
6.
Connectivity
7.
Deployment
8.
9.
GAMS
GAMS
GAMS
vllllllll
66
6666 666l~
~1Jllllllll
II
II
II
II
GAMS
G)11(B
GAMS
Help
The
-n
-n
'" GAMS
-n
$:;;title
l~~.uieter
gen"'rted
gd;,
Oi'!Vi'!lopmnt:
data
for
-File
c5n
be
Corporl'llrion.
single
t:o
usd
te~tc~tgch
11 c. :_:, ~
-Fo ~~-----~-----------------
rQ
I) I ~
FormulJJt:io
lines,
bar,-,
pic'I)
~~:~~a{at1i~~~noo~e~~DataB
(year
TypelDimlNr Elem
136.000
Iii
2.500
--Job chartdat.gn,s
Start
05/05/06
GAMSR"v 145
Copyright
(C) 1987-l006
Licens.ee:
------------------------------------------------11:::
-----------
13:06:00
GAMSDt,vrlopment.
~~zs~f~~~~nG,nbH
All
rightl
5051012/
St:art-ing
compilation
cha.rtdat.9ms(1ll)
l Mb
Starting
execution
chartdat.l)m5(1l6)
7 Mb
Putf'ile
-f D:\suppor-t\testchart.gch
~;bt~h~r~d;';~~,,.~~~~;t~~/o>/06.11:08,0l
rlap:;;ed
o,oo:Ol.4ll
~~::;;~~======~~
G)12(B
GAMS
GAMS
Design Principles
G)14(B
GAMS
G)1s(B
GAMS
G)16(B
GAMS
//
. .....
~)J,~.\
""
t.. so La ns:. .
.. .
......
G)17(B
GAMS
GAMS
Declarative Modeling
ASCII: Initial model development
GDX: Data layer {"contract"}
between GAMS and
applications
- Platform independent
- No license required
- Direct GDX interfaces and
general API
GAMS
SOLVER
G)1g(B
GAMS
AP l's
Low Level
Python
No modeling capability:
Model is written in GAMS
Wrapper class that
encapsulates a GAMS model
G)2o(B
GAMS
G)21(B
GAMS
4 [Coal
ILM
-17.62 -35.24
36.43
5 JWasteHeat
5.5
6 !Steam
7 Exhaust
11
-53.2
10.72
MWh
kg/s
kg/s
-16.7
16.7 -16.7
8 !Heat
9 Electricity
18
-0.25
N
MWh
-0.5
8.6184
13.77
39.84
29.55
MWh
MWh
10.39
10
11
1:
40
35
1
1
30
25
2
2
2
2
2~
20
15
10
5
0
rl
~
I~
N
I~
rl
I~
I~
rl
I~
mm
I~
~ m
MM
M
N
~
N
~
N
00 Mm~
Nm
mm
~~~~MM
I~
rl
I~
mm
I~
rl
I~
00
Om
I~
00
ON
mm
I~
I~
I~
rl I~
ON~
m ~ ~ ~ ~ ,~ ,~ ,~ ,~ ~ ~ ~
~~~~~~~~~~~~~~~~~~~~~~~
G)22(B
GAMS
r-~~~~~~~~~-=---_::_:_=---.-~~~~~~15
12
10
15
Dollar Short
G)23(B
GAMS
for (j in c Cf i n )"
solSeq[j] <k <- nxt[k]
}
solSeq[n + 1] <if (k != 1) stop1
loc <- cmdscale(,
rx <- range(x <ry <- range(y <tspres <- loc[sol
s <- seq(n)
G)24(B
GAMS
Advancing hardware
Platforms
New
1
1------1
1------1
1------1
--
Backward Compatibility
--
--
G)2s(B
GAMS
Issues:
Breakouts of traditional Mathematical Programming classes
No conventional syntax
Limited support with common model representation
Incomplete/experimental solution approaches
Lack of reliable/any software
G)26(B
GAMS
G)27(B
GAMS
EMP
Information
(uncertain Par.)
Deterministic
Model
t--
Translation
c
Q)
0
:+::i
en
Cf)
cu
cu
::J c..
Reformulated
Model
(viewable)
Solve with
established Algorithms
0>c C)
c.. L..
c.. 0
CU O
~c
Solution
G)2s(B
GAMS
><
Windowi ~
Windows 64bit
GUROBI
CPL EX
Perspectives:
What is the impact of new features?
What is the impact of updated or new solvers?
Is the new distribution backward compatible?
D
G)2g(B
GAMS
Builds
Alpha Builds
Beta Bui'lds
NightJly Builds
Sunday
23Mar14
Gloss<1ry ]
04:52
(UTC)
Corn me 11ts?
NOTE: The (nightly) aJpba buds are internal development verslons of'ihe GAMS sy1tem. They may have known bugs, unfinished features, beta versions of third-party software, or may not function at aU! Not for
production use!
Libraries
Build
Rev
status
Full Tests
nightly
a system
F~iday
lnx
Test done
22Mar2014
12:42:54
I11itial Tests
805 runs O failures
(q=O,s=O)
Report
Saturday
jg_g
Test done
22Mar2014
22:03:49
F~iday
vs8
Test
started
22Mar2014
01:12:52
Friday
wei
Test
started
22Mar2014
03:47: 14
o failur;es
Report
Report
G)3o(B
GAMS
Why GAMS?
G)31(B
GAMS
Agenda
G)32(B
GAMS
G)33
GAMS
MINLP
Allows non-linearity,
e.g. a smooth decrease in unit cost when
shipping volumes grows
Allows uncertainty,
e.g. uncertain demand
G)34
GAMS
shipments
(Number of cases)
G)3s(B
GAMS
A Transportation Model
Supply
Distance
Demand
(cases)
(thousand miles)
(cases)
Topeka
Seattle
Chicago
San Diego
2....5
Minimize
Transportation cost
subject to
New York
G)36
Mathematical
Indices:
J
Decision variables:
xij
Data:
cij
ai
bi
min La
~ LlJ
~ c-LJ x LJ
subject to
~-X<
Llj
lj -
al
~-X>
Lli
lj
b'l
X>
lj -
GAMS
Model Formulation
(Canning plants)
(Markets)
(Number of cases to ship)
(Transport cost per case)
(Capacity in cases)
(Demand in cases)
(Minimize total transportation cost)
'if i
i,j E N
G)37
GAMS
--=
~ gamside: C:\Users\Tonil..aoTon\.ll,vuments\aamsdir\proidir\Transoort\trnD.QDr-
~~~:!J~lp4
File
Edit
Search
Windows
Utilities
Model Libraries
[C.'\Users\Tonil.apTop\. ..
T c::::i 'l'l:Jll~I
r:l~~
Help
~~~~I
li1li
Variables
x(i,j),
z
..
=e=
su.m((i,j), c ( i, j J, "'x ( i, j J, J,
supply(i),
..
su.m(j, x(i,j))
=I=
at
demand(j),
..
su.m(i, x(i,j)J
=g=
b(j)
Model modelLP
;
;
~ I
.I
"'
1: 1
~
Jlnserl
I
--
Hands-On
G)3s(B
GAMS
~ ,gamside: C:\prentatiorn\2014_0R_Aachen\demo\or14.gpr
-
Eile
;;earch
!;dit
~indows
Utilities
Model Libraries
~~~~~I
~
!::!elp
..:J Ii
~~~~I
..
~1011~1
~ C:\presentat,on\2014_0R_Aachen\demo\data.gms
data.gms
Sets
canning
markets
i
j
plants
I seattle, san-diega
I new-york, chicago,
-"'
I
I
topeka
Parameters
a(i)
b(j)
Table
capacity of plant
seattle
350
san-diego
600
d (i, j J
Scalar
Parameter
seattle
san-diego
i in cases
distance
in thousands
of miles
chicago
new-york
2.5
1. 7
2.5
1.8
freight
in dollars
c(i,j)
transport
per
cost
case
per
topeka
1.8
1.<!
thousand
in thousands
----'
;
miles
of dollars
/90/ ;
per
case
~
c(i,j)
~ I
= f
~ d(i,j)
I aoou
~I~
100
..
$include
data.gms
Variables
x(i,j)
23: 74 I
I Insert
s'hipment quantities
in cases
G)39
GAMS
l.rl.E:
~
~Ei
1~r,
qarnside; C:\pres<enlation\2014_0R_Aachen\demo\or14.gpr
Eile
~earch
~dit
1/tilities
:'h!indows
Model Libraries
~~~~~I
I I ~
11
=I
@]
lilith
!::!elp
..:J I
~~~~I
~I~
C:\presentation\2014_0R_Aachen\demo\trnsport.gms
data. gms
II.Ea.I
trnsport. gms
A
Sets
canning
markets
i
j
Parameters
a(i)
b(j)
dli,j)
Parameter
plants
;
capacity
of plant i in cases
demand at market j in cases
distance
in thousands
of miles
transport
c(i,j)
cost
Positive
~ I.
Variable
Equations
cost
supply(i)
demand(i)
of dollars
per
case
Data
in cases
costs in thousands
of dollars
x;
define objective
function
observe supply limit at plant
satisfy demand at market i ;
in thousands
preparing
shipment
quantities
total transportation
..
17: 45
23: 74
I Insert
I Insert
I
I
Ill
G)4o(B
GAMS
Sets
i
j
canning plants
markets
Parameters
a(i)
b(j)
d(i,j)
$call gdxxr-w data.xlsx par=d rng=Al par=a rng=G2 dim=1 rdim=1 par=b rng=B6 dim=l
$if errorlevel 1 $abort Error preparing Da.ta
$gdxin data. gdx
I,;, data.xlsx - Microsoft
$load i<d.dim1 j<d.dim2 dab
Ho1
Function
Library
Ins,
I Defined I
Names
>
Equations
cost
supply(i)
~I
"'
II
For
Re~
Vie
De,
A~'
I .:::.
Calcujation
>
Seattle
San-Diego,
17: 45
23: 74 j
!Insert
Insert
]Insert
= ~ zs
I~ ~ ~ ~I
15: 1
R9
t.boue a
Pa
Formula
Auditinq
A
Positiv,e VariabLe
= 1@1
Excel
Ready
I Sheet!
I ~ I
Sheet2 / Sheet3 A I~
I f[Q] [!:!]
100%
1111
GAMS
Solution to LP model
shipments
Markets ( demand)
(Number of cases)
G)42(B
GAMS
{continuous variable}
Discrete decision:
ship
{binary variable}
Cost($)
ship= 0
Not possible
ship= 1
x (Number of cases)
100
add constraints:
xi,j > 100 shiPi,j
t/ i, j
x,L,] <
- bigM shipL,] t/ i 1
I
shiPi,j E {0,1}
I.
Hands-On
G)43
GAMS
~~~~~lp4
1~1~"
...
1-1~01
Help
~ II
~~~~I
-1
trnsport_LP_MIP_MINLP gms
..
Scalar
bigm
rat.ne
bigm
miniimillll sb.ipment
big-M 1:ela.xatian
Binary
variables
volame
;
(numoez; of
cases)
/100/
smax (j ,b (j ), ) ), ;
sb.ip(i,j);
Equations
minship(i,j)
ru,a,xship(i,j)
miniimillll sihipment
ma.xiro.illll.
sihipment;
nrinship ( i, j ) ..
mnaxship ( i, j ) ..
x(i,j),
=sg= mins"'sii:llip(i,j);
(i, j ), =l= big]Ill"'si:llip (i, j);
Model
m.adelMIP /modelLP,
So,lve
m.adelMIP using
mioship,
IlldXSb.ip/
mip mil:mrizing
z ;
..
~ I
I
I
1: 1
jlnsert
G)44
GAMS
I Markets ( demand)
(Number of cases)
G)4s(B
GAMS
ship= 0
Not possible
ship= 1
volume
I
I
I
x (Number of cases)
Replace:
Hands-On
G)46
GAMS
Eile
dit
~earch
Windows
Model Libraries
1J.til ities
[=l@JI~
!::!elp
..:.]
~~~~I
~~~~~I
~I
j ] ~ C:\presentation\2014_0R_Aac.hen\demo\trnsport.gms
I trnsport.gms
~ ll-t3-I ' I
'
A
Scalar
beta
..
beta
cost
supply (i),
demand(j)
..
minship (i, j ), ..
maxship (i, j ), ..
-I
..
I 0.95
factor
z =e=
sum ( j ,
sum ( i ,
x (i, j ),
x (i, j)
Model
transport
/all/;
So,l ve
transport
using
Display
x.l,
/;
minlp
'I lj
DllliniDlll:izing
z ;
x.m;
~
...
1- I
f
"'
.I
1: 1 I Modified
I Insert
G)47
GAMS
shipments
I Markets ( demand)
(Number of cases)
I thousand miles
G)4s(B
GAMS
Uncertain Demand
Prob: 0.3
Val: 0.90
Prob: 0.5
Val: 1.00
Prob: 0.2
Val: 1.10
Decisions to make:
How many units should be shipped "here and
now" (without knowing the outcome of the uncertain demand)?
7 First-stage decision
What can be done after the outcome becomes known and we did not
ship enough?
7 Second-stage or recourse decision
Recourse decisions can be seen as
penalties for bad first-stage decisions
variables to keep the problem feasible
Hands-On
G)49
GAMS
l[,=r,l,@~I
gamside:C:\presentation\2014_0R_Aachen\demo\or14.gpr
file
_Edit
ModelLibraries
!:::!elp
~~~~I
~ ~~~.:!J~I
..:.J
~1~11~1
' ~ C:\presentation\2014_0R_Aachen\demo\trnsport.gms
trnsport.qrns
..
file
emp I '%emp. info%'
$onput
randvar
bf discrete
0.3
0.5
0. 2
sta.ge 2 bf demand u
$offput
putclos,e
emp;
bf
X
u
So,l ve transport
Display
~I
s_bf,
I sl~s3
demand factor
sihipment per
cases bought
I seen
diet
.scendrio.
.randvar
.level
.level
using
s_x
0.9
1.0
1.1
scenarios
Set seen
Parameter
s_bf(scen)
s_x(scen,i,j)
s_u(scen,j),
Set
/; put
/;
realization
scenario
per scenario;
I I
.s
bf
.S X
. e u I:
emp minimizing
79: 41
z scena.rio
diet;
..
s u;
~-
by scenario
!lnserl
-1
G)so(B
GAMS
Solution to SP model
shipments
Markets ( demand)
(Number of cases)
New York
(-325)
.5
G)s1(B
GAMS
More information:
http://www.gams.com/dd/docs/solvers/empsp.pdf
52
G)s2(B
GAMS
B
New-York
San-Diego
Freight cost
0 ~HIP'MENl
1 Seattle
Chicago Topeka
2.5
2.5
1.7
1.8
1.8
1.4
325
300
275
~
t
New-York
I LIMI
Supply
~:
i
se~ttle
Scin-Dieg;o
Chicago Topeka
llfe~v-York Chicago
2 San-Diego
3
4
.5
5
7
Topeka
l-
Clear Solution
'--~~~~~~-....-~~~~~~~~~~~~~~~~....
8 GAMS Directory:
9, Working Directory:
O Solver:
c:\program files\GAMS23.2\
c:\tmp\
1--~----~~~~~~~~~~~~~----1
CPLEX
SOLVE LP
11
SOLVE MllP
Solver: CPLEX
quations: 6 Variables: 7
Model Status: 1 Optimal
Solver Status: 1 Normal Completion
Iterations: 4 Solve Time: 0.00
Objective Value: 153.675
Hands-On
53
G)s3(B
GAMS
Europe
GAMS Software GmbH
P.O. Box 40 59
50216 Frechen, Germany
Phone: +49 221 949 9170
Fax:
+49 221 949 9171
info@gams.de
USA
GAMS Development Corp. 1217 Potomac
Street, NW Washington, DC 20007
USA
Phone: +1 202 342 0180
Fax:
+1 202 342 0181
sales@gams.com
I www.gams.com