Vous êtes sur la page 1sur 25

GAMS Workshop

Energy System Integration


20th May 2016, University College Dublin

This workshop is designed to provide an introduction into the General


Algebraic Systems Modelling System (GAMS) soft ware and its
a pplications in optimization pro blems in energy system integration
s t u d i e s. T h e p a r t i c i p a n t s w i l l a c t u a l l y b u i l d t h e m o d e l s s t e p - b y - s t e p
with guidance from the instructor: from simple to com ple x structure.
The parti cipan ts will acquire e xtensive practical hands - on e xperience
in building a comple x, large - scale model. No backgrou nd in
pro g ramming i s re qu ired .
Dr. Alireza Soroudi
Senior researcher at UCD
Alireza.soroudi@ud.ie
GAMS
The General Algebraic Modelling System (GAMS) is a high -
level modelling system for mathematical programming and
optimization.

24/05/2016
Broad User Community and Network

24/05/2016
Broad Range of Application Areas

24/05/2016
How to get the software?
www.gams.com

24/05/2016
GAMS Basics
oIt consists of a language compiler and a stable of integrated high-performance solvers

oGAMS is tailored for complex, large scale modeling applications, and allows you to build large
maintainable models that can be adapted quickly to new situations

24/05/2016
Features

database
management
system (DBMS)

24/05/2016
GAMS code components
Set : used to indicate the name of indices

SCALAR : used to declare scalars

Parameters : used to declare constant values with /without sets

Table: declare the known values

Variables : declare variables

Equations: Defines the constraints

Models: Which constraints should be considered ?

Solve : ask GAMS to minimize/maximize the model

Display : show the output

24/05/2016
GAMS Environment

24/05/2016
Create New GAMS Code File
oSelect: File  New
oYou should see the new file “Untitled_1.gms”

24/05/2016
Enter GAMS Code
oThe Model

oThe code

24/05/2016
Run the Model
oSelect: File  Run, or Press the red arrow button

24/05/2016
GAMS Model Results

oResults are in file:


HW41.txt
oDouble Click this
line to open results
file

24/05/2016
TRANSPORTATION EXAMPLE

o2 supply plants, 3 markets, and 1


commodity.
oGiven: unit costs of shipping.
oHow much to ship to minimize total
transportation cost

24/05/2016
TRANSPORTATION EXAMPLE

325 New York


San Diego 600

275 Topeka
350
Seattle
300 Chicago
Minimize: Transportation cost Shipping costs are assumed to be $90 per case per kMile.

Subject to: Demand satisfaction and supply constraints


24/05/2016
Transportation Example:
ALGEBRAIC REPRESENTATION

Indices (or sets):


i = plants Distances
Markets
j = markets
Plants New York Chicago Topeka Supply

Given Data (or parameters): Seattle 2.5 1.7 1.8 350


ai = supply of commodity of plant i (in cases)
San Diego 2.5 1.8 1.4 600
bj = demand for commodity at market j (cases)
Demand 325 300 275
cij = cost per unit shipment between plant i and market j ($/case)

24/05/2016
Transportation Example:
ALGEBRAIC REPRESENTATION

Decision Variables:
xij = amount to ship from plant i to market j (cases),
where xij≥ 0, for all i, j

Constraints:
Observe supply limit at plant i: ∑j xij ≤ ai , for all i (cases)
Satisfy demand at market j: ∑i xij ≥ bj , for all j (cases)

Objective Function:
Minimize ∑i ∑j c xij ($K)

24/05/2016
Transportation Example:
THE GAMS MODEL

24/05/2016
Transportation Example:
ALGEBRAIC REPRESENTATION
FREE, POSITIVE, NEGATIVE, BINARY, or
INTEGER.

Model transport /cost, supply, demand/;

MAXIMIZING

24/05/2016
Solve Messages
MODEL STATISTICS

BLOCKS OF EQUATIONS 3 SINGLE EQUATIONS 6


BLOCKS OF VARIABLES 2 SINGLE VARIABLES 7
NON ZERO ELEMENTS 19

GENERATION TIME = 0.017 SECONDS


EXECUTION TIME = 0.033 SECONDS

S O L V E S U M M A R Y
MODEL TRANSPORT OBJECTIVE Z
TYPE LP DIRECTION MINIMIZE
SOLVER BDMLP FROM LINE 47
**** SOLVER STATUS 1 NORMAL COMPLETION
**** MODEL STATUS 1 OPTIMAL
**** OBJECTIVE VALUE 153.6750
RESOURCE USAGE, LIMIT 0.184 1000.000
ITERATION COUNT, LIMIT 4 1000

24/05/2016
Output
Display x.l, x.m ;

---- 68 VARIABLE x.L shipment quantities in cases

new-york chicago topeka

seattle 50.000 300.000


san-diego 275.000 275.000

---- 68 VARIABLE x.M shipment quantities in cases

chicago topeka

seattle 0.036
san-diego 0.009

24/05/2016
Diet Problem Example
oEnergy requirement : 2000 kcal
oProtein requirement : 55 g
oCalcium requirement : 800 mg

Food Energy Protein Calcium Price per


(kcal) (g) (mg) serving($)

Oatmeal 110 4 2 3
Chicken 205 32 12 24
Eggs 160 13 54 13
Milk 160 8 285 9
Pie 420 4 22 24
Pork 260 14 80 13

24/05/2016
Example of LP : Diet Problem

ooatmeal: at most 4 servings/day


ochicken: at most 3 servings/day
oeggs: at most 2 servings/day
omilk: at most 8 servings/day
opie: at most 2 servings/day
opork: at most 2 servings/day

Design an optimal diet plan


which minimizes the cost per day
24/05/2016
Paper Company
oA paper manufacturer can produce four different types of paper on three different
machines. Given a fixed demand schedule the objective is to find a production plan that
maximizes monthly profits.

24/05/2016
Some GAMS References
1 . w w w. g a m s.c o m
2 . h t t p s://w w w. y o u t u b e.c o m /w a tc h ? v = 9 8 w J K I u R L P I
3 . GA M S o n M a c h t t p ://w w w. g a m s.c o m /d o c s/ m a c - i n s ta l l . h t m l
4 . H o w t o I n s t a l l t h e N a t i v e GA M S Ve r s i o n o n a M a c
h t t p s://w w w. y o u t u b e.c o m /w a tc h ? v = O L t v j c OZ k T M
5 . I n s t a l l t h e Wi n d o w s Ve r s i o n o f GA M S o n a M a c b y U s i n g Wi n e
h t t p s://w w w. y o u t u b e.c o m /w a tc h ? v = N _ Z 0 u S 1 p - U U
6 . H o w t o I n s ta l l t h e N a t i v e G A M S Ve r s i o n o n L i n u x
h t t p s://w w w. y o u t u b e.c o m /w a tc h ? v = M x _ t Y I 3 w y P 4

24/05/2016

Vous aimerez peut-être aussi