0% found this document useful (0 votes)
33 views

Part A: Sets Declaration and Definition Solve The Following Questions

This document contains questions about GAMS (General Algebraic Modeling System) concepts including: 1) Defining sets, parameters, and matrices in GAMS format 2) Entering multi-dimensional data using sets, parameters, and tables 3) Performing computations on data using GAMS arithmetic, summation, and product functions 4) Declaring variables and equation types in GAMS such as supply/demand balances 5) Using GAMS programming flow control features like the dollar sign operator

Uploaded by

nada abdelrahman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Part A: Sets Declaration and Definition Solve The Following Questions

This document contains questions about GAMS (General Algebraic Modeling System) concepts including: 1) Defining sets, parameters, and matrices in GAMS format 2) Entering multi-dimensional data using sets, parameters, and tables 3) Performing computations on data using GAMS arithmetic, summation, and product functions 4) Declaring variables and equation types in GAMS such as supply/demand balances 5) Using GAMS programming flow control features like the dollar sign operator

Uploaded by

nada abdelrahman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Part A: Sets Declaration and Definition

Solve the following questions:


1. Declare and define the following sets in GAMS:
Set S = {a,b,c}
Set m  M , m = ξ{Egypt, Lebanon, Kuwait}
2. Include in the above example two approches describing or documenting
the two set.
3. Define the following sets in a compact GAMS form.
Set T = {1990,1992,1993,1994,1995}
Set MC = {MC1,MC2,…….MC10}
4. Identify illegality in the following GAMS statement:
SET
Illegale1 / A15BC*A10BC /
Illegale2 / A1X1* A9X9 /
Illegale3 / A1* B9 /;
5. A set of Egyptian universities (public and private) are defined as:
Set U = { Cairo, Alex, Ain-shams, British, October, German}
Develop a GAMS formulation for the set U as well as the subsets of
Public and private Universities.
6. Develop GAMS statement for a two dimensional set for country
Ports mapping based on the following information:
Set c = { Egypt, Italy, Nederland}
Set p = {Alexandria, Port-Said, Venis, Genewa, Amesterdam, Roterdam}
7. Multiple set names and sparse matrix. In the following input output
matrix, develop a mapping set to identify non empty cells of the matrix
using GAMS.
1
Agriculture Industry Services
Agriculture 10 20
Industry 30
Services 15 40

Part B: Data Entry and Management in GAMS

1. The demand in thousands of Honda Cars in three Egyptian cities is defined as


follows:
Cairo = 50, Alexandria = 45, and Aswan = 25
Develop two GAMS formulations to enter data using sets and
Parameter reserved words.
2. Given the following quantity of government and private sector labors by
household area (in Thousands).
Government Sector Private Sector
Urban Household area 400 1000
Rural Household Area 350 700
Enter the labor data in a GAMS model using both set, parameter and table
GAMS reserved words.
3. Given the following quantity of government and private sector labors by
household area and skill level (in Thousands).
Government Sector Private Sector
Urban Household area(Skilled) 400 1000
Rural Household Area (skilled) 350 700
Urban Household area ( unskilled) 400 1000
Rural Household Area (unskilled) 350 700

Enter the multi-dimensional labor data in a GAMS model once using using
Sets &parameter, and again using sets & table reseved GAMS words.
4. Given the time set t = 2000 to 2005 and the non-homogenious rows
Shown in the following matrix:

2000 2001 2002 2003 2004 2005


Mean 500 600 700 800 900 1000
Median 300 320 340 380 400 500

2
Variance 10 12 16 18 20 20
Maximum 800 900 1000 1200 1400 1800
Read the above matrix in GAMS format using set and table reserved words.
5. Re-write the following data entry problem using the
“ Parameter” reserved GAMS word instead of “Table”.
Sets
L Labor by category / GOV, PUB, PRIV /
H Household type / URBAN, RURAL /;
TABLE LABOR (L,H) number of workers in thousands.

URBAN RURAL
GOV 200 150
PUB 20 30
PRV 300 250 ;

Part C: Data Manipulation & Computation in GAMS

1. Given the following data items in the form of matrix, vector and scalar.
Sets
L Labor by Sector / GOV, PUB, PRIV /
H Household type / URBAN, RURAL / ;
TABLE LABOR (L,H) number of workers in thousands.
URBAN RURAL
GOV 200 150
PUB 20 30
PRV 300 250 ;
PARAMETER W(H) wage rate by household area /
URBAN 30 , RURAL 25 / ;
SCALAR GR average growth rate (in percent) of labor by sector
and Household Area / 2 / ;
a) Compute the new number of labor by Sector and Household area
Given the annual growth rate GR in perent (%).
b) Compute the total wage income by sector using the labor matrix and
the wage rate by household category.
2. Convert the following mathematical specifications or equations to a GAMS
Format:
3
TOTCm = ∑iCim

COUNT= ∑i∑j Aij

EMP= ∑t Lt Mt

{OUTPUT= ∏i INPUT(i) **SHARE(i)

Using Sets , Parameters , Tables , SUM and PROD reserved GAMS key words.

3. Define the following arethmetic functions in GAMS:

abs(x), ceil(x), exp(x), floor(x), log(x), log10(x), max(x,y,…), min(x,y,…)

sqrt(x), sqr(x).

4. Define the following random variables generating functions in GAMS:

Exponential(m), Normal(μ,σ), Uniform(m,n)

5. Given the following sets and parameters:

SETS

L Labor by category / GOV, PUB, PRV /

S Labor by Skill / SKILLED, UNSKILL /

H Household type / URBAN, RURAL / ;

PARAMETER LABOR(L,S,H) labor by category skill and household type

/ GOV.SKILLED.URBAN 100, GOV.SKILLED.RURAL 150

PUB.SKILLED. URBAN 200, PUB.SKILLED.RURAL 120

PRV.SKILLED. URBAN 250, PRV.SKILLED.RURAL 180

GOV.UNSKILL.URBAN 100, GOV.UNSKILL.RURAL 150

PUB.SKILL. URBAN 200, PUB.SKILL.RURAL 120

PRV.UNSKILL. URBAN 250, PRV.UNSKILL.RURAL 180

/ ;

Use the two GAMS reserved words “DISPLAY” and “OPTION” to design

4
a transparent output report to display the LABOR parameter.

Part D: Variables and Equations


1. Determine the type of decision variables in GAMS and the way of their
Declaration and bounding.
2. Explain the following GAMS statements:
Assignment Statement to bound Variables
Example 1:
X.UP(C,I,J) = 1000 ; PHI.UP = INF ;
XX.UP(“CAIRO”, “ALEX”) = 200 ;
Example 2:
C.LO(T) = 0.01 ;
Example 3:
C.L(T) = 4*CINIT(T)
Example 4:
C.FX(“Period-1”) = 1 ;
Example 5:
C.FX(“1985”) = 1 ; C.LO(T) = 0.01 ;
C.LO(T) = 0.01 ; C.FX(“1985”) = 1;
Other Examples:
Variable status;
Positive Variable quantity (production, markets);
quantity.up(production,markets)=1000;
Binary Variable buydecision(stocks);
Binary Variable buydecision.l(stocks) = 1;
Display quantity.l, quantity.ub, quantity.m;
Variable status.fx = 500;
3. Identify the differences between the following Equations in computing
the following cost in GAMS :
COST . . TC =E= C1+C2+C3 ;
COST . . TC =E= SUM(I, C(I)) ;
COST . . TC=E=C(“INN”)+C(“ORDER”)
+C(“short”) ;
LC . . SUM(I, L(I)*X(I)) =L= Lbar ;
4. Explain the following specific equation types:
Equations
5
SB (i) Supply balance
DB (j) Demand balance
CA(i) ;

SB (i) . . SUM (j $ MAP (i, j), X (i, j)) =L= S (i) ;


DB (j) . . SUM (j $ MAP (i, j), X (i, j)) =G= D (i) ;
CA (i) . . SUM (i $ A (i), A (i)*X (i)) =L=m
CA (i) . . SUM (i $ A (i) NE 0), A (i)*X (i)) =L=m

Part E: Programing flow Control

1. Use the dollar sign ($) operator of GAMS to implement the following
algorithms:
A) Read the scalars X,Y. ((Y=2and X=1)
If X > 1.5 then X=2
Else X = 0
B) Read R(i) and S(i), i= 1,2, …..n
If S(i) = 0 then R(i) = inf
Else R(i) = 1/S(i)
C) S(I) = V(I) $ (V(I) GE 2 AND V(I) LE 4)
Read S(i), V(i) , i=1,2,….n
If 2 <= S(i) <= 4 then S(i) = V(i)
Else S(i) = 0
D) Read A(i), i=1,2… and S(k),T(k), B(k) , k=1,2,…
If S(k) and T(k) NE 0
Then U(i) = SUM((k), A(i)*B(k))
Else U(i) = 0
2. Given the following GAMS program:
SETS R Regions
/ UPPER-EGY , LOWER-EGY /
S Cities
/ CAIRO, ALEX, ASWAN, LUXOR /
CORR(R, S) correspondence of Reg. & Cities
/ UPPER-EGY . (ASWAN, LUXOR)
LOWER-EGY . (CAIRO, ALEX) /

6
PARAMETERS
Y(R) Income of each region (m LE )
INCOME (s) Income of cities (m LE)
/ CAIRO 100 , ALEX 70
ASWAN 50 , LUXOR 30 /
For each region R compute the summation over the S citie such that
CORR(R,S) exists.

3. Given the following GAMS statements:


* Declaration and definition of set and model parameters
Set t / 2000 * 2005 /
Parameter
pop(t) / 2000 90 /
Growth(t) / 2000 2, 2001 2.1
2002 2.2, 2003 2.3
2004 2.4, 2005 2.5 / ;
Compute population size during the period (2000 – 2005) using GAMS-
LOOP statement, Given that pop(t) is the population size and Growth(t)
is the annual population growth Rate(%).

4. Develop the following algorithm using the GAMS if-elseif-else


Statement.
Mathematical Formulation (with $ Operator)
P( i ) $( f <= 0 ) = -1 ;
P( i ) $ (( f > 0) and ( f < 1 )) = P( i ) **2 ;
P( i ) $ (f > 1) = P( i ) **3 ;

Good Luck
Motaz Khorshid

You might also like