Digest for gamsworld@googlegroups.com - 17 Messages in 6 Topics

Dear colleagues

I’m working on a two-objective model where one of the objectives is non-linear.
How can I implement epsilon constraint method on my model?
Which solver is appropriate for my model?
I would be really appreciated if someone send me an example code with
GAMS implementing epsilon constraint method on a two-objective model

Reza Kia, PhD candidate of industrial engineering

Regards

On 4/10/12, gamsworld@googlegroups.com wrote:

=============================================================================
Today’s Topic Summary

Group: gamsworld@googlegroups.com
Url: http://groups.google.com/group/gamsworld/topics

=============================================================================
Topic: import data from Excel to GAMS
Url: http://groups.google.com/group/gamsworld/t/ba3c7bb5663a5fde

---------- 1 of 5 ----------
From: “D.Dileep”
Date: Apr 10 07:23AM -0700
Url: http://groups.google.com/group/gamsworld/msg/3f9bff7cfceb4bdc

Hi all,

Plz, can any one tell me how to import data from Excel to GAMS?

---------- 2 of 5 ----------
From: Paul Van der Eijk
Date: Apr 10 11:19AM -0400
Url: http://groups.google.com/group/gamsworld/msg/985b2d9b94f321b8

Look for GDXXRW in gdxutils.pdf and mccarlgamsusersguide.pdf in the docs
directory.

–Paul


Paul van der Eijk
GAMS Development Corporation
Tel : (202) 342-0180 Fax : (202) 342-0181
Email: pvandereijk@gams.com
Web : http://www.gams.com

---------- 3 of 5 ----------
From: “A.R. Bahari”
Date: Apr 10 07:39PM +0330
Url: http://groups.google.com/group/gamsworld/msg/b6e7aca294cc2e05

Hi
Download the latest version of gams from www.gams.com
First locate the .xls file in the following path:
E:\Data\MatrixInputs.XLS
Now its ready to run.
Have a look at the sheet named “index” and at the 17 first rows of my cod
To know how importing data fromexcel is performed.
the 5 last rows export data to Excel
Close the excel file when GAMS is runing.

---------- 4 of 5 ----------
From: Krishna Prasad
Date: Apr 10 10:52PM +0530
Url: http://groups.google.com/group/gamsworld/msg/1398381a5dc6b653

Hi,

Let us suppose example.xls file you want to read and it has row name as
x1,x2,x3 ,…x10 and column name as y1,y2,…y20 and let us suppose you
want to save it in a parameter of name xydata then you can read in gams as
follow:

Set i /x1x10/;
Set j /y1
y20/;

PARAMETER xydata(i,j)
$CALL GDXXRW example.xls par=xydata rng=sheet_name!A1:U10 Cdim=1 Rdim=1
$GDXIN example.gdx
$LOAD xydata
$GDXIN
Display xydata;

You can see the attached file. one thing is that you must save the .xls in
2003-2007 format

Best Regards
Krishna Prasad

---------- 5 of 5 ----------
From: Dileep Damayyawar
Date: Apr 10 11:22PM +0530
Url: http://groups.google.com/group/gamsworld/msg/1e1ea110e4b62cc

Thank you very much Paul and Bahari…


Regards
Dileep Damayyawar

=============================================================================
Topic: $ conditional evaluation: efficient code question
Url: http://groups.google.com/group/gamsworld/t/a0a20e70592d1511

---------- 1 of 1 ----------
From: Steven Dirkse
Date: Apr 10 12:14PM -0400
Url: http://groups.google.com/group/gamsworld/msg/c27037169b06d8a7

Andy,

I’m just back in the office after a week’s vacation, and surprised to
see no answer to this question. I would have guessed that GAMS is
doing short-circuit evaluation of boolean AND and OR operators, but I
thought I’d write a little model to check it out. The test (included
below) shows we do not do short-circuit evals. Run with “profile=1”
on the command line to get timing outputs.

-Steve

set I / i1 * i120 /;
set T 'trips through the loop ’ / t1 * t30 /;

alias (I,J,K);
parameter A(I,J,K);
a(I,J,K) = 1;

scalars continue, hits;

hits = 0;

loop {T$[sum{(I,J,K), a(I,J,K)} >= ord(T) * power(card(I),3)],
hits = hits + 1;
};

display hits;

continue = 1;
hits = 0;

loop {T$[continue and (sum{(I,J,K), a(I,J,K)} >= ord(T) *
power(card(I),3))],
continue = 0;
hits = hits + 1;
};

display continue, hits;

continue = 1;
hits = 0;

loop {T$continue,
if {[sum{(I,J,K), a(I,J,K)} >= ord(T) * power(card(I),3)],
continue = 0;
hits = hits + 1;
};
};

display continue, hits;


Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

=============================================================================
Topic: got hell of errors----plz help
Url: http://groups.google.com/group/gamsworld/t/28016ac3888fd0c1

---------- 1 of 4 ----------
From: sara sohail
Date: Apr 07 03:38PM +0500
Url: http://groups.google.com/group/gamsworld/msg/8b5cba1243a8b946

hi All

I am a beginner can anyone diagnose error in my coding in gams. its an
economics model.i have attached the coding in world file because i dont
know how to attach directly from GAMS.

Thanks to anyone who could answer me soon.

waiting,

Sara

---------- 2 of 4 ----------
From: sara sohail
Date: Apr 09 09:30PM -0700
Url: http://groups.google.com/group/gamsworld/msg/9bb8b1f9acd407c1

---------- Forwarded message ----------
From: sara sohail
Date: Sat, Apr 7, 2012 at 3:38 AM
Subject: got hell of errors----plz help
To: gamsworld@googlegroups.com

hi All

I am a beginner can anyone diagnose error in my coding in gams. its an
economics model.i have attached the coding in world file because i dont
know how to attach directly from GAMS.

Thanks to anyone who could answer me soon.

waiting,

Sara

---------- 3 of 4 ----------
From: Destin Zed
Date: Apr 10 10:22AM +0200
Url: http://groups.google.com/group/gamsworld/msg/7950a50fe6aa6f11

Hi Sara,

I went through your GAMS code. It seems to me that the reasons why you are
getting errors are:

(1) you misplaced the asterisk (*) on your code; it should be placed at the
first character position of a line of comment.

(2) Your data entries in the tables are disorganized. Remember the
following rules while using Table in GAMS (Source GAMS User Manual):
=> The relative positions of all entries in a table are significant. This
is the only statement where end of line (EOL) has meaning. The character
positions of the numeric table entries must overlap the character positions
of the column headings.
=> The column section has to t on one line.
=> The sequence of signed numbers forming a row must be on the same line.
=> The element definition of a row can span more than one line.
=> A specific column can appear only once in the entire table.

I hope this helps.
Desta

---------- 4 of 4 ----------
From: “hervé guene”
Date: Apr 10 03:32PM
Url: http://groups.google.com/group/gamsworld/msg/d78cbe1385e5ce5c

Hi sara, your final code should look like attached!

Cheers, Hervé

Tel : (226) 75503803 / 78357776 / 71315352

De : gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] De la
part de Destin Zed
Envoyé : mardi 10 avril 2012 08:23
À : gamsworld@googlegroups.com
Objet : Re: got hell of errors----plz help

Hi Sara,

I went through your GAMS code. It seems to me that the reasons why you are
getting errors are:

(1) you misplaced the asterisk (*) on your code; it should be placed at the
first character position of a line of comment.

(2) Your data entries in the tables are disorganized. Remember the following
rules while using Table in GAMS (Source GAMS User Manual):
=> The relative positions of all entries in a table are significant. This is
the only statement where end of line (EOL) has meaning. The character
positions of the numeric table entries must overlap the character positions
of the column headings.
=> The column section has to
t on one line.
=> The sequence of signed numbers forming a row must be on the same line.
=> The element definition of a row can span more than one line.
=> A specific column can appear only once in the entire table.

I hope this helps.
Desta

On Tue, Apr 10, 2012 at 6:30 AM, sara sohail wrote:

---------- Forwarded message ----------
From: sara sohail
Date: Sat, Apr 7, 2012 at 3:38 AM
Subject: got hell of errors----plz help
To: gamsworld@googlegroups.com

hi All

I am a beginner can anyone diagnose error in my coding in gams. its an
economics model.i have attached the coding in world file because i dont know
how to attach directly from GAMS.

Thanks to anyone who could answer me soon.

waiting,

Sara


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


“gamsworld” group.
To post to this group, send email to
gamsworld@googlegroups.com.
To unsubscribe from this group, send email to

gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at

http://groups.google.com/group/gamsworld?hl=en.

=============================================================================
Topic: Matlab-GAMS loop error
Url: http://groups.google.com/group/gamsworld/t/80551239ac423be2

---------- 1 of 3 ----------
From: tjjjc
Date: Apr 09 07:34AM -0700
Url: http://groups.google.com/group/gamsworld/msg/9b4d657f2e6641ac

Gentlemen,

I have to call GAMS in a loop from Matlab but I get irregular errors.
I use a calculated value of the previous GAMS execution and use it in
the next execution.
I do this for 96 times (96 quarters in a day)

Very seldom Matlab completes this loop (96running times of GAMS),
often it breaks somewhere irregularly with the error appended below.
If I continue the loop manually from the 2nd last iteration of the
error till the end, it works. So I don’t think it depends on the
values in the model since I use the second last value which was
calculated by the loop which ended up throwing an error.

In short, with the same data, GAMS throws an error for a different
progression in the loop!

for index = 1:length_RT_schedule
loadxls_realtime(index+startpoint-1, e_bufferRT(index),pricedata);
tic
index
a = gams(‘real_time’);
toc
e_bufferRT(index+1) = a.val(2,2);
end

to get an output with the “gams()” commando, I used these lines in
GAMS:

$set matout "‘realtimeout.gdx’, e_buffer ";
$if exist matdata.gms $include matdata.gms

execute_unload %matout%;

the error:

Microsoft Visual C++ Runtime Library
Runtime Error!

Program: C:\Program Files\GAMS23.7\gams.exe

This application has requested the Runtime to terminate it in an
unusual way.

Another error I sometimes get is a.val(2.2) is empty. If I look in
the .lst file, I find a SOLVER & MODEL error no. 13

Thank you very much

---------- 2 of 3 ----------
From: Muhajir
Date: Apr 10 10:28AM +0200
Url: http://groups.google.com/group/gamsworld/msg/b192433f8a3e73f2

Hi Thomas,

A workaround for your problem is provided at:

http://support.gams-software.com/doku.php?id=matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities

Hope this helps!

---------- 3 of 3 ----------
From: tjjjc
Date: Apr 10 03:48AM -0700
Url: http://groups.google.com/group/gamsworld/msg/3b08822146e46de

Thank you very much,

I finally got it working properly after 2 days of mystery!

On Monday, April 9, 2012 4:34:47 PM UTC+2, tjjjc wrote:

=============================================================================
Topic: please see errors in my coding—can anyone help?
Url: http://groups.google.com/group/gamsworld/t/54900ee83b2da4ba

---------- 1 of 3 ----------
From: sara sohail
Date: Apr 07 03:50PM +0500
Url: http://groups.google.com/group/gamsworld/msg/c9ea5a29a03868be

hi All,

I am a beginner and could not eliminate the simple errors in gam coding my
coding is as under (after running it i get many errors)
please can anyone help me?

$Title Generic Small Open Economy Model – “SOEM”

$STitle Version 1 with:

  • 2 goods, 2 activities, 2 households;

  • no market power in the world markets;

  • no firms amongst institutions.

  • SETS ===========================================================

SETS

AC the global set including all items

  • Since there are no Firms in this exercise, they are excluded from the sets

/

AGR-A agricultural activity

NAGR-A non-agricultural activity

AGR-C agricultural commodity

NAGR-C non-agricultural commodity

LAB labour

CAP capital

U-HHD urban household

R-HHD rural household

GOV government

ROW rest of world

S-I savings-investment

YTAX income tax

STAX sales tax

TAR import tariff

TOTAL total account in SAM

/

  • Generating the specific sets and subsets

ACNT(AC) all elements in AC except total

A(AC) activities /AGR-A, NAGR-A/

C(AC) commodities /AGR-C, NAGR-C/

CE(C) exported commodities /AGR-C/

CNE(C) non-exported commodities /NAGR-C/

CM(C) imported commodities /NAGR-C/

CNM(C) non-imported commodities /AGR-C/

F(AC) factors /LAB, CAP/

I(AC) institutions /U-HHD, R-HHD, GOV, ROW/

H(I) households /U-HHD, R-HHD/

;

  • To exclude TOTAL from ACNT:

ACNT(AC) = YES;

ACNT(‘TOTAL’) = NO;

  • Alias sets to be used when we want to distinguish between two versions,
    e.g.

  • when summing y(F,F) over columns, we can write SUM(F y(F,FAL))

ALIAS ( AC , ACAL);

ALIAS (C, CAL);

ALIAS (F,FAL);

ALIAS (I,IAL);

ALIAS (ACNT,ACNTAL);

  • PARAMETERS ======================================================

PARAMETERS

ad(A) shift in the production fn for activity a

alpha(F,A) elasticity of factor f in the production fn for
activity a

aq(C) shift parameter in CES aggregation for commodity
c

ax(C) shift parameter in CES transformation for
commodity c

beta(C,H) share of households total spending on commodity c

consumer price index

cwts(C) weight of commodity c in the CPI

deltaq(C) share parameter in CES aggregation for commodity c

deltax(C) share parameter in CES transformation for
commodity c

ir(C,A) IO coeff: qnty of c as intermediate input per unit of
activity a

INV(C) base-year qnty of investment demand for commodity
c

PWE(C) export (world) price for c (foreign currency)

PWM(C) import (world) price for c (foreign currency)

QFS(F) total supply of factor f

QG(C) government demand for commodity c (in quantity)

rhoq(C) exponent parameter in the CES aggregation for
commodity c

rhox(C) exponent parameter in the CES transformation for
commodity c

shry(H,F) share of household i in income of factor f

te(C) export subsidy or tax rate for commodity c

theta(A,C) yield coeff: yield of output c per unit of activity a

tm(C) import tariff rate for commodity c

tq(C) sales tax rate for commodity c

TR(I,IAL) transfer from institution ial to institution i

ty(H) income tax rate for household h

;

  • VARIABLES =======================================================

VARIABLES

*FREE VARIABLES

BOP balance of payment (foreign savings) in foreign
currency)

GBS government budget surplus (or deficit)

QE(C) quantity of exports for commodity c (can be import
if >
QFU(F) excess sup. of factor f (e.g. unemployment. > excess demand)

QM(C) quantity of imports of commodity c (can be export if

WALR dummy variable (zero at equilibrium)

*POSITIVE VARIABLES

EXR exchange rate (dom. currency per unit of for.
currency)

FPD(F,A) wage distortion factor for factor f in activity a

IADJ investment adjustment factor

MPS(H marginal (and average) propensity to save for
household h

PA(A) price of activity a

PD(C) domestic price of domestic output c

PE(C) export price for c (domestic currency)

PF(F) average price of factor f

PM(C) import price for c (domestic currency)

PQ(C) composite commodity price for c

PVA(A) value-added price for activity a

PX(C) producer price for commodity c

QA(A) level of activity a

QD(C) quantity sold domestically of domestic output c

QF(F,A) quantity demanded of factor f from activity a

QH(C,H) quantity consumed of commodity c by household h

QINT(C,A) quantity of commodity c as intermediate input to
activity a

QINV(C) quantity of investment demand for commodity c

QQ(C) quantity of goods supplied domestically (composite
supply)

QX(C) quantity of domestic output of commodity c

YF(H,F) transfer of income to institutions i from factor f

YH(H) income of household h

;

  • EQUATIONS =======================================================

  • EQUATION NAME ###############

EQUATIONS

  • PRICE BLOCK +++++++++++++++++++++++++++

PMDEF(C) import price for commodity c (domestic
currency)

PEDEF(C) export price for commodity c (domestic
currency)

ABSORB(C) absorption for commodity c

OUTVAL(C) output value for commodity c

PADEF(A) price for activity a

PVADEF(A) value-added price for activity a

PNORM CPI and the price normalization rule

  • PRODUCTION AND COMMODITY BLOCK ++++++++

PRODFN (A) Cobb-Douglas production function for
activity a

FACDEM (F, A) demand for factor f by activity a

INTDEM(C , A) intermediate demand for commodity c by
activity a

OUTPUTFN(C) output of commodity c

CESQ(C) CES aggregation of QD and QM into QQ

CESX(C) CES transformation of QD and QE into QX

ESUBMD(C) import-domestic demand ratio for commodity
c

ESUBED(C) export-domestic supply ratio for
commodity c

NMQD(C) composite version for non-imported
commodity c

NEXD(C) transformation for non-exported
commodity c

  • INSTITUTION BLOCK +++++++++++++++++++++

FACTTRNS(H,F) transfer of income from factor f to
household h

HHDINC(H) income of household h

HHDCON(C,H) consumption demand by household h for
commodity c

INVDEM(C) investment demand for commodity c

GBC government budget surplus

  • SYSTEM CONSTRAINT BLOCK +++++++++++++++

FACTMEQ(F) market equilibrium condition for factor f

GOODMEQ(C) market equilibrium condition for composite
commodity c

BOPEQ current account balance for ROW

WALREQ savings-investment balance with WALR
dummy to be zero

;

  • EQUATION DESCRIPTION ###############

  • PRICE BLOCK +++++++++++++++++++++++++++

PMDEF(C)$CM(C)… PM(C) =E= (1 + tm(C))EXRPWM(C);

PEDEF(C)$CE(C)… PE(C) =E= (1-te(C))EXRPWE(C);

ABSORB(C)… PQ(C)*QQ(C)=E= (PD(C)*QD(C) + (PM(C)QM(C))$CM(C))(1 + tq(C));

OUTVAL(C)… PX(C)*QX(C) =E= PD(C)*QD(C) + (PE(C)*QE(C))$CE(C);

PADEF(A)… PA(A) =E= SUM(C, PX(C)*theta(A,C));

PVADEF(A)… PVA(A) =E= PA(A)-SUM(C, PQ(C)*ir(C,A));

PNORM… SUM(C, PQ(C)*cwts(C)) =E= CPI;

  • PRODUCTION AND COMMODITY BLOCK++++++++

PRODFN(A)… QA(A) =E= ad(A)*PROD(F, QF(F,A)**alpha(F,A));

FACDEM(F,A)… PF(F)*FPD(F,A) =E= alpha(F,A)*PVA(A)*QA(A)/QF(F,A);

INTDEM(C,A)… QINT(C,A) =E= ir(C,A)*QA(A);

OUTPUTFN(C)… QX(C) =E= SUM(A, theta(A,C)*QA(A));

CESQ(C)$CM(C)… QQ(C) =E= aq(C)*(deltaq(C)*QM(C)**(-rhoq(C))

  • (1-deltaq(C))*QD(C)(-rhoq(C)))(-1/rhoq(C));

CESX(C)$CE(C)… QX(C) =E= ax(C)*(deltax(C)*QE(C)**(rhox(C))

  • (1-deltax(C))*QD(C)(rhox(C)) )(1/rhox(C));

ESUBMD(C)$CM(C)… QM(C)/QD(C) =E=

( (deltaq(C)/(1-deltaq(C))) * (PD(C)/PM(C)) )**(1/(1+rhoq(C)));

ESUBED(C)$CE(C)… QE(C)/QD(C) =E= ( PE(C)/PD(C)*(1-deltax(C))

/deltax(C) )**(1/(rhox(C)-1) );

NMQD(C)$CNM(C)… QQ(C) =E= QD(C);

NEXD(C)$CNE(C)… QX(C) =E= QD(C);

  • INSTITUTION BLOCK +++++++++++++++++++++

FACTTRNS(H,F)… YF(H,F) =E= shry(H,F)*SUM(A, PF(F)*FPD(F,A)*QF(F,A));

HHDINC(H)… YH(H) =E= SUM(F, YF(H,F)) + CPITR(H,‘GOV’) + EXRTR(H,‘ROW’);

HHDCON(C,H)… QH(C,H) =E= beta(C,H)(1-MPS(H))(1-ty(H))*YH(H)/PQ(C);

INVDEM(C)… QINV(C) =E= inv(C)*IADJ;

GBC… GBS =E=

( SUM(H, ty(H)*YH(H))

  • SUM(C, tq(C)*(PD(C)*QD(C) + (PM(C)*QM(C))$CM(C)))

  • SUM(C$CM(C), tm(C)EXRPWM(C)*QM(C))

  • SUM(C$CE(C), te(C)EXRPWE(C)*QE(C))

  • EXR*TR(‘GOV’,‘ROW’)

) -( SUM(C, PQ(C)*QG(C))

  • SUM(I, CPI*TR(I,‘GOV’)$H(I))

);

  • SYSTEM CONSTRAINT BLOCK +++++++++++++++

FACTMEQ(F)… SUM(A, QF(F,A)) + QFU(F) =E= QFS(F);

GOODMEQ(C)… QQ(C) =E= SUM(A, QINT(C,A)) + SUM(H, QH(C,H))+ QG(C) +
QINV(C);

BOPEQ… BOP =E= SUM(C$CM(C), PWM(C)*QM(C))

-( SUM(C$CE(C), PWE(C)*QE(C))

  • SUM(I, TR(I,‘ROW’)$H(I))

  • TR(‘GOV’,‘ROW’)

);

WALREQ… WALR =E=

( SUM(H, MPS(H)*(1-ty(H))*YH(H))

    • YFRM
  • GBS + EXR*BOP )
  • ( SUM(C, PQ(C)*QINV(C)) );
  • MODEL ===========================================================

MODELS SOEMV1 “Small Open Economy Model Ver1” /ALL/ ;

  • use hold fix to speed up the solution

  • This attribute tells GAMS whether to generate and send to the solver the

  • variables that are being held fixed by the .fx

SOEMV1.HOLDFIXED = 1;

*#############################################################################

  • SOCIAL ACCOUNTING MATRIX =======================================

TABLE SAM(AC,ACAL) social accounting matrix

            AGR-A                 NAGR-A               AGR-C   NAGR-C
         LAB        CAP       U-HHD                 R-HHD

AGR-A 0 0 279
0 0 0
0 0

NAGR-A 0 0
0 394 0 0 0
0

AGR-C 84 55
0 0 0 0
30 49

NAGR-C 50 99 0
0 0 0 165
92

LAB 72 105 0
0 0 0
0 0

CAP 73 135 0
0 0 0
0 0

U-HHD 0 0 0
0 95 125 0
0

R-HHD 0 0
0 0 82 83
0 0

GOV 0 0 0
0 0 0
0 0

ROW 0 0 0
105 0 0
0 0

YTAX 0 0
0 0 0 0 20
5

STAX 0 0 10
20 0 0
0 0

TAR 0 0 0
39 0 0
0 0

S-I 0 0
0 0 0 0
70 40

  •        GOV                      ROW                    YTAX
    

STAX TAR S-I

AGR-A 0 0
0 0 0 0

NAGR-A 0 0 0
0 0 0

AGR-C 13 30
0 0 0 28

NAGR-C 67 0 0
0 0 85

LAB 0 0 0
0 0 0

CAP 0 0
0 0 0 0

U-HHD 25 40 0
0 0 0

R-HHD 5 16 0
0 0 0

GOV 0 15
25 30 39 0

ROW 0 0 0
0 0 0

YTAX 0 0 0
0 0 0

STAX 0 0 0
0 0 0

TAR 0 0 0
0 0 0

S-I 1 4
0 0 0 0

;

  • GENERATING THE TOTAL COLUMN AND ROW FOR SAM

  • note the use of ALIAS SET ACNTAL

SAM(‘TOTAL’,ACNTAL) = SUM(ACNT, SAM(ACNT,ACNTAL));

SAM(ACNT,‘TOTAL’) = SUM(ACNTAL, SAM(ACNT,ACNTAL));

  • CHECKING THE CONSISTENCY: tdiff should be zero

PARAMETER tdiff(AC) “(column total - row total) for account AC”;

tdiff(ACNT) = SAM(‘TOTAL’,ACNT)-SAM(ACNT,‘TOTAL’);

DISPLAY SAM, tdiff;

---------- 2 of 3 ----------
From: Hasan Dudu
Date: Apr 10 11:10AM +0300
Url: http://groups.google.com/group/gamsworld/msg/7a5f1e9292023f9

most of the problems in your code is due to misaligned SAM table. first
correct it. headers of the columns should be inline with the numbers in the
column. After that, following errors remains.

line 99: MPS(H => MPS(H) (missing paranthesis)
line 88: add CPI as variable (CPI is not added as a variable)
line 382: CPI => CPI.FX (CPI is a variable)
line 384: CPI => CPI.L (CPI is a variable)
line 676: delete 0 (unnecessary zero)

hasan

---------- 3 of 3 ----------
From: sara sohail
Date: Apr 10 01:24AM -0700
Url: http://groups.google.com/group/gamsworld/msg/bba2bdc16f19a5a3

Thank you Hasan!

I ll work on it accordingly. But you know its difficult for me to
understand GAMS. Can you plese tell any link except gams.com to learn GAMS
coding easily. I have a few but may be you can recommend something better.

Regards,

Sara

=============================================================================
Topic: Can I get append set element name/text dynamically into * set, eg
“abc”
Url: http://groups.google.com/group/gamsworld/t/17b8b154ba212f3b

---------- 1 of 1 ----------
From: AC
Date: Apr 09 04:10PM -0700
Url: http://groups.google.com/group/gamsworld/msg/688cad4ae708f08e

Hi

There is an existing report in a model we help maintain which is set
up something like:

parameter MY_REPORT(*);

MY_REPORT(‘discounted value in 2010’) = SOME_VALUE;
MY_REPORT(‘discounted value in 2011’) = SOME_VALUE;
etc

We want to keep the “discounted value in” prefix text (used by other
things elsewhere). What I want to do is loop over our years set and
append the year set element’s text to that prefix.

So something along the lines of

loop years do
MY_REPORT(‘discounted value in’ ) = SOME_VALUE;
endloop

Is there a way to do this? Ideally I would like it done without using
some external $batinclude file, or an echo statement which writes it
out and then reads it back in again. Is this possible to do?

Thanks in advance
Andy


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


\

Hi Reza Kia,

You can see the eps-constraint method implementation in the following link :
http://www.gams.com/modlib/libhtml/epscm.htm

It is for LP, you can modify accordingly.


Regards
Krishna Prasad



On Wed, Apr 11, 2012 at 11:22 PM, reza kia wrote:

Dear colleagues

I’m working on a two-objective model where one of the objectives is non-linear.
How can I implement epsilon constraint method on my model?
Which solver is appropriate for my model?
I would be really appreciated if someone send me an example code with
GAMS implementing epsilon constraint method on a two-objective model

Reza Kia, PhD candidate of industrial engineering

Regards

On 4/10/12, gamsworld@googlegroups.com wrote:

=============================================================================
Today’s Topic Summary

Group: gamsworld@googlegroups.com
Url: http://groups.google.com/group/gamsworld/topics

=============================================================================
Topic: import data from Excel to GAMS
Url: http://groups.google.com/group/gamsworld/t/ba3c7bb5663a5fde

---------- 1 of 5 ----------
From: “D.Dileep”
Date: Apr 10 07:23AM -0700
Url: http://groups.google.com/group/gamsworld/msg/3f9bff7cfceb4bdc

Hi all,

Plz, can any one tell me how to import data from Excel to GAMS?

---------- 2 of 5 ----------
From: Paul Van der Eijk
Date: Apr 10 11:19AM -0400
Url: http://groups.google.com/group/gamsworld/msg/985b2d9b94f321b8

Look for GDXXRW in gdxutils.pdf and mccarlgamsusersguide.pdf in the docs
directory.

–Paul


Paul van der Eijk
GAMS Development Corporation
Tel : (202) 342-0180 Fax : (202) 342-0181
Email: pvandereijk@gams.com
Web : http://www.gams.com

---------- 3 of 5 ----------
From: “A.R. Bahari”
Date: Apr 10 07:39PM +0330
Url: http://groups.google.com/group/gamsworld/msg/b6e7aca294cc2e05

Hi
Download the latest version of gams from www.gams.com
First locate the .xls file in the following path:
E:\Data\MatrixInputs.XLS
Now its ready to run.
Have a look at the sheet named “index” and at the 17 first rows of my cod
To know how importing data fromexcel is performed.
the 5 last rows export data to Excel
Close the excel file when GAMS is runing.

---------- 4 of 5 ----------
From: Krishna Prasad
Date: Apr 10 10:52PM +0530
Url: http://groups.google.com/group/gamsworld/msg/1398381a5dc6b653

Hi,

Let us suppose example.xls file you want to read and it has row name as
x1,x2,x3 ,…x10 and column name as y1,y2,…y20 and let us suppose you
want to save it in a parameter of name xydata then you can read in gams as
follow:

Set i /x1x10/;
Set j /y1
y20/;

PARAMETER xydata(i,j)
$CALL GDXXRW example.xls par=xydata rng=sheet_name!A1:U10 Cdim=1 Rdim=1
$GDXIN example.gdx
$LOAD xydata
$GDXIN
Display xydata;

You can see the attached file. one thing is that you must save the .xls in
2003-2007 format

Best Regards
Krishna Prasad

---------- 5 of 5 ----------
From: Dileep Damayyawar
Date: Apr 10 11:22PM +0530
Url: http://groups.google.com/group/gamsworld/msg/1e1ea110e4b62cc

Thank you very much Paul and Bahari…


Regards
Dileep Damayyawar

=============================================================================
Topic: $ conditional evaluation: efficient code question
Url: http://groups.google.com/group/gamsworld/t/a0a20e70592d1511

---------- 1 of 1 ----------
From: Steven Dirkse
Date: Apr 10 12:14PM -0400
Url: http://groups.google.com/group/gamsworld/msg/c27037169b06d8a7

Andy,

I’m just back in the office after a week’s vacation, and surprised to
see no answer to this question. I would have guessed that GAMS is
doing short-circuit evaluation of boolean AND and OR operators, but I
thought I’d write a little model to check it out. The test (included
below) shows we do not do short-circuit evals. Run with “profile=1”
on the command line to get timing outputs.

-Steve

set I / i1 * i120 /;
set T 'trips through the loop ’ / t1 * t30 /;

alias (I,J,K);
parameter A(I,J,K);
a(I,J,K) = 1;

scalars continue, hits;

hits = 0;

loop {T$[sum{(I,J,K), a(I,J,K)} >= ord(T) * power(card(I),3)],
hits = hits + 1;
};

display hits;

continue = 1;
hits = 0;

loop {T$[continue and (sum{(I,J,K), a(I,J,K)} >= ord(T) *
power(card(I),3))],
continue = 0;
hits = hits + 1;
};

display continue, hits;

continue = 1;
hits = 0;

loop {T$continue,
if {[sum{(I,J,K), a(I,J,K)} >= ord(T) * power(card(I),3)],
continue = 0;
hits = hits + 1;
};
};

display continue, hits;


Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

=============================================================================
Topic: got hell of errors----plz help
Url: http://groups.google.com/group/gamsworld/t/28016ac3888fd0c1

---------- 1 of 4 ----------
From: sara sohail
Date: Apr 07 03:38PM +0500
Url: http://groups.google.com/group/gamsworld/msg/8b5cba1243a8b946

hi All

I am a beginner can anyone diagnose error in my coding in gams. its an
economics model.i have attached the coding in world file because i dont
know how to attach directly from GAMS.

Thanks to anyone who could answer me soon.

waiting,

Sara

---------- 2 of 4 ----------
From: sara sohail
Date: Apr 09 09:30PM -0700
Url: http://groups.google.com/group/gamsworld/msg/9bb8b1f9acd407c1

---------- Forwarded message ----------
From: sara sohail
Date: Sat, Apr 7, 2012 at 3:38 AM
Subject: got hell of errors----plz help
To: gamsworld@googlegroups.com

hi All

I am a beginner can anyone diagnose error in my coding in gams. its an
economics model.i have attached the coding in world file because i dont
know how to attach directly from GAMS.

Thanks to anyone who could answer me soon.

waiting,

Sara

---------- 3 of 4 ----------
From: Destin Zed
Date: Apr 10 10:22AM +0200
Url: http://groups.google.com/group/gamsworld/msg/7950a50fe6aa6f11

Hi Sara,

I went through your GAMS code. It seems to me that the reasons why you are
getting errors are:

(1) you misplaced the asterisk (*) on your code; it should be placed at the
first character position of a line of comment.

(2) Your data entries in the tables are disorganized. Remember the
following rules while using Table in GAMS (Source GAMS User Manual):
=> The relative positions of all entries in a table are significant. This
is the only statement where end of line (EOL) has meaning. The character
positions of the numeric table entries must overlap the character positions
of the column headings.
=> The column section has to t on one line.
=> The sequence of signed numbers forming a row must be on the same line.
=> The element definition of a row can span more than one line.
=> A specific column can appear only once in the entire table.

I hope this helps.
Desta

---------- 4 of 4 ----------
From: “hervé guene”
Date: Apr 10 03:32PM
Url: http://groups.google.com/group/gamsworld/msg/d78cbe1385e5ce5c

Hi sara, your final code should look like attached!

Cheers, Hervé

Tel : (226) 75503803 / 78357776 / 71315352

De : gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] De la
part de Destin Zed
Envoyé : mardi 10 avril 2012 08:23
À : gamsworld@googlegroups.com
Objet : Re: got hell of errors----plz help

Hi Sara,

I went through your GAMS code. It seems to me that the reasons why you are
getting errors are:

(1) you misplaced the asterisk (*) on your code; it should be placed at the
first character position of a line of comment.

(2) Your data entries in the tables are disorganized. Remember the following
rules while using Table in GAMS (Source GAMS User Manual):
=> The relative positions of all entries in a table are significant. This is
the only statement where end of line (EOL) has meaning. The character
positions of the numeric table entries must overlap the character positions
of the column headings.
=> The column section has to
t on one line.
=> The sequence of signed numbers forming a row must be on the same line.
=> The element definition of a row can span more than one line.
=> A specific column can appear only once in the entire table.

I hope this helps.
Desta

On Tue, Apr 10, 2012 at 6:30 AM, sara sohail wrote:

---------- Forwarded message ----------
From: sara sohail
Date: Sat, Apr 7, 2012 at 3:38 AM
Subject: got hell of errors----plz help
To: gamsworld@googlegroups.com

hi All

I am a beginner can anyone diagnose error in my coding in gams. its an
economics model.i have attached the coding in world file because i dont know
how to attach directly from GAMS.

Thanks to anyone who could answer me soon.

waiting,

Sara


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


“gamsworld” group.
To post to this group, send email to
gamsworld@googlegroups.com.
To unsubscribe from this group, send email to

gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at

http://groups.google.com/group/gamsworld?hl=en.

=============================================================================
Topic: Matlab-GAMS loop error
Url: http://groups.google.com/group/gamsworld/t/80551239ac423be2

---------- 1 of 3 ----------
From: tjjjc
Date: Apr 09 07:34AM -0700
Url: http://groups.google.com/group/gamsworld/msg/9b4d657f2e6641ac

Gentlemen,

I have to call GAMS in a loop from Matlab but I get irregular errors.
I use a calculated value of the previous GAMS execution and use it in
the next execution.
I do this for 96 times (96 quarters in a day)

Very seldom Matlab completes this loop (96running times of GAMS),
often it breaks somewhere irregularly with the error appended below.
If I continue the loop manually from the 2nd last iteration of the
error till the end, it works. So I don’t think it depends on the
values in the model since I use the second last value which was
calculated by the loop which ended up throwing an error.

In short, with the same data, GAMS throws an error for a different
progression in the loop!

for index = 1:length_RT_schedule
loadxls_realtime(index+startpoint-1, e_bufferRT(index),pricedata);
tic
index
a = gams(‘real_time’);
toc
e_bufferRT(index+1) = a.val(2,2);
end

to get an output with the “gams()” commando, I used these lines in
GAMS:

$set matout "‘realtimeout.gdx’, e_buffer ";
$if exist matdata.gms $include matdata.gms

execute_unload %matout%;

the error:

Microsoft Visual C++ Runtime Library
Runtime Error!

Program: C:\Program Files\GAMS23.7\gams.exe

This application has requested the Runtime to terminate it in an
unusual way.

Another error I sometimes get is a.val(2.2) is empty. If I look in
the .lst file, I find a SOLVER & MODEL error no. 13

Thank you very much

---------- 2 of 3 ----------
From: Muhajir
Date: Apr 10 10:28AM +0200
Url: http://groups.google.com/group/gamsworld/msg/b192433f8a3e73f2

Hi Thomas,

A workaround for your problem is provided at:

http://support.gams-software.com/doku.php?id=matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities

Hope this helps!

---------- 3 of 3 ----------
From: tjjjc
Date: Apr 10 03:48AM -0700
Url: http://groups.google.com/group/gamsworld/msg/3b08822146e46de

Thank you very much,

I finally got it working properly after 2 days of mystery!

On Monday, April 9, 2012 4:34:47 PM UTC+2, tjjjc wrote:

=============================================================================
Topic: please see errors in my coding—can anyone help?
Url: http://groups.google.com/group/gamsworld/t/54900ee83b2da4ba

---------- 1 of 3 ----------
From: sara sohail
Date: Apr 07 03:50PM +0500
Url: http://groups.google.com/group/gamsworld/msg/c9ea5a29a03868be

hi All,

I am a beginner and could not eliminate the simple errors in gam coding my
coding is as under (after running it i get many errors)
please can anyone help me?

$Title Generic Small Open Economy Model – “SOEM”

$STitle Version 1 with:

  • 2 goods, 2 activities, 2 households;

  • no market power in the world markets;

  • no firms amongst institutions.

  • SETS ===========================================================

SETS

AC the global set including all items

  • Since there are no Firms in this exercise, they are excluded from the sets

/

AGR-A agricultural activity

NAGR-A non-agricultural activity

AGR-C agricultural commodity

NAGR-C non-agricultural commodity

LAB labour

CAP capital

U-HHD urban household

R-HHD rural household

GOV government

ROW rest of world

S-I savings-investment

YTAX income tax

STAX sales tax

TAR import tariff

TOTAL total account in SAM

/

  • Generating the specific sets and subsets

ACNT(AC) all elements in AC except total

A(AC) activities /AGR-A, NAGR-A/

C(AC) commodities /AGR-C, NAGR-C/

CE(C) exported commodities /AGR-C/

CNE(C) non-exported commodities /NAGR-C/

CM(C) imported commodities /NAGR-C/

CNM(C) non-imported commodities /AGR-C/

F(AC) factors /LAB, CAP/

I(AC) institutions /U-HHD, R-HHD, GOV, ROW/

H(I) households /U-HHD, R-HHD/

;

  • To exclude TOTAL from ACNT:

ACNT(AC) = YES;

ACNT(‘TOTAL’) = NO;

  • Alias sets to be used when we want to distinguish between two versions,
    e.g.

  • when summing y(F,F) over columns, we can write SUM(F y(F,FAL))

ALIAS ( AC , ACAL);

ALIAS (C, CAL);

ALIAS (F,FAL);

ALIAS (I,IAL);

ALIAS (ACNT,ACNTAL);

  • PARAMETERS ======================================================

PARAMETERS

ad(A) shift in the production fn for activity a

alpha(F,A) elasticity of factor f in the production fn for
activity a

aq(C) shift parameter in CES aggregation for commodity
c

ax(C) shift parameter in CES transformation for
commodity c

beta(C,H) share of households total spending on commodity c

consumer price index

cwts(C) weight of commodity c in the CPI

deltaq(C) share parameter in CES aggregation for commodity c

deltax(C) share parameter in CES transformation for
commodity c

ir(C,A) IO coeff: qnty of c as intermediate input per unit of
activity a

INV(C) base-year qnty of investment demand for commodity
c

PWE(C) export (world) price for c (foreign currency)

PWM(C) import (world) price for c (foreign currency)

QFS(F) total supply of factor f

QG(C) government demand for commodity c (in quantity)

rhoq(C) exponent parameter in the CES aggregation for
commodity c

rhox(C) exponent parameter in the CES transformation for
commodity c

shry(H,F) share of household i in income of factor f

te(C) export subsidy or tax rate for commodity c

theta(A,C) yield coeff: yield of output c per unit of activity a

tm(C) import tariff rate for commodity c

tq(C) sales tax rate for commodity c

TR(I,IAL) transfer from institution ial to institution i

ty(H) income tax rate for household h

;

  • VARIABLES =======================================================

VARIABLES

*FREE VARIABLES

BOP balance of payment (foreign savings) in foreign
currency)

GBS government budget surplus (or deficit)

QE(C) quantity of exports for commodity c (can be import
if
QFU(F) excess sup. of factor f (e.g. unemployment. excess demand)

QM(C) quantity of imports of commodity c (can be export if

WALR dummy variable (zero at equilibrium)

*POSITIVE VARIABLES

EXR exchange rate (dom. currency per unit of for.
currency)

FPD(F,A) wage distortion factor for factor f in activity a

IADJ investment adjustment factor

MPS(H marginal (and average) propensity to save for
household h

PA(A) price of activity a

PD(C) domestic price of domestic output c

PE(C) export price for c (domestic currency)

PF(F) average price of factor f

PM(C) import price for c (domestic currency)

PQ(C) composite commodity price for c

PVA(A) value-added price for activity a

PX(C) producer price for commodity c

QA(A) level of activity a

QD(C) quantity sold domestically of domestic output c

QF(F,A) quantity demanded of factor f from activity a

QH(C,H) quantity consumed of commodity c by household h

QINT(C,A) quantity of commodity c as intermediate input to
activity a

QINV(C) quantity of investment demand for commodity c

QQ(C) quantity of goods supplied domestically (composite
supply)

QX(C) quantity of domestic output of commodity c

YF(H,F) transfer of income to institutions i from factor f

YH(H) income of household h

;

  • EQUATIONS =======================================================

  • EQUATION NAME ###############

EQUATIONS

  • PRICE BLOCK +++++++++++++++++++++++++++

PMDEF(C) import price for commodity c (domestic
currency)

PEDEF(C) export price for commodity c (domestic
currency)

ABSORB(C) absorption for commodity c

OUTVAL(C) output value for commodity c

PADEF(A) price for activity a

PVADEF(A) value-added price for activity a

PNORM CPI and the price normalization rule

  • PRODUCTION AND COMMODITY BLOCK ++++++++

PRODFN (A) Cobb-Douglas production function for
activity a

FACDEM (F, A) demand for factor f by activity a

INTDEM(C , A) intermediate demand for commodity c by
activity a

OUTPUTFN(C) output of commodity c

CESQ(C) CES aggregation of QD and QM into QQ

CESX(C) CES transformation of QD and QE into QX

ESUBMD(C) import-domestic demand ratio for commodity
c

ESUBED(C) export-domestic supply ratio for
commodity c

NMQD(C) composite version for non-imported
commodity c

NEXD(C) transformation for non-exported
commodity c

  • INSTITUTION BLOCK +++++++++++++++++++++

FACTTRNS(H,F) transfer of income from factor f to
household h

HHDINC(H) income of household h

HHDCON(C,H) consumption demand by household h for
commodity c

INVDEM(C) investment demand for commodity c

GBC government budget surplus

  • SYSTEM CONSTRAINT BLOCK +++++++++++++++

FACTMEQ(F) market equilibrium condition for factor f

GOODMEQ(C) market equilibrium condition for composite
commodity c

BOPEQ current account balance for ROW

WALREQ savings-investment balance with WALR
dummy to be zero

;

  • EQUATION DESCRIPTION ###############

  • PRICE BLOCK +++++++++++++++++++++++++++

PMDEF(C)$CM(C)… PM(C) =E= (1 + tm(C))EXRPWM(C);

PEDEF(C)$CE(C)… PE(C) =E= (1-te(C))EXRPWE(C);

ABSORB(C)… PQ(C)*QQ(C)=E= (PD(C)*QD(C) + (PM(C)QM(C))$CM(C))(1 + tq(C));

OUTVAL(C)… PX(C)*QX(C) =E= PD(C)*QD(C) + (PE(C)*QE(C))$CE(C);

PADEF(A)… PA(A) =E= SUM(C, PX(C)*theta(A,C));

PVADEF(A)… PVA(A) =E= PA(A)-SUM(C, PQ(C)*ir(C,A));

PNORM… SUM(C, PQ(C)*cwts(C)) =E= CPI;

  • PRODUCTION AND COMMODITY BLOCK++++++++

PRODFN(A)… QA(A) =E= ad(A)*PROD(F, QF(F,A)**alpha(F,A));

FACDEM(F,A)… PF(F)*FPD(F,A) =E= alpha(F,A)*PVA(A)*QA(A)/QF(F,A);

INTDEM(C,A)… QINT(C,A) =E= ir(C,A)*QA(A);

OUTPUTFN(C)… QX(C) =E= SUM(A, theta(A,C)*QA(A));

CESQ(C)$CM(C)… QQ(C) =E= aq(C)*(deltaq(C)*QM(C)**(-rhoq(C))

  • (1-deltaq(C))*QD(C)(-rhoq(C)))(-1/rhoq(C));

CESX(C)$CE(C)… QX(C) =E= ax(C)*(deltax(C)*QE(C)**(rhox(C))

  • (1-deltax(C))*QD(C)(rhox(C)) )(1/rhox(C));

ESUBMD(C)$CM(C)… QM(C)/QD(C) =E=

( (deltaq(C)/(1-deltaq(C))) * (PD(C)/PM(C)) )**(1/(1+rhoq(C)));

ESUBED(C)$CE(C)… QE(C)/QD(C) =E= ( PE(C)/PD(C)*(1-deltax(C))

/deltax(C) )**(1/(rhox(C)-1) );

NMQD(C)$CNM(C)… QQ(C) =E= QD(C);

NEXD(C)$CNE(C)… QX(C) =E= QD(C);

  • INSTITUTION BLOCK +++++++++++++++++++++

FACTTRNS(H,F)… YF(H,F) =E= shry(H,F)*SUM(A, PF(F)*FPD(F,A)*QF(F,A));

HHDINC(H)… YH(H) =E= SUM(F, YF(H,F)) + CPITR(H,‘GOV’) + EXRTR(H,‘ROW’);

HHDCON(C,H)… QH(C,H) =E= beta(C,H)(1-MPS(H))(1-ty(H))*YH(H)/PQ(C);

INVDEM(C)… QINV(C) =E= inv(C)*IADJ;

GBC… GBS =E=

( SUM(H, ty(H)*YH(H))

  • SUM(C, tq(C)*(PD(C)*QD(C) + (PM(C)*QM(C))$CM(C)))

  • SUM(C$CM(C), tm(C)EXRPWM(C)*QM(C))

  • SUM(C$CE(C), te(C)EXRPWE(C)*QE(C))

  • EXR*TR(‘GOV’,‘ROW’)

) -( SUM(C, PQ(C)*QG(C))

  • SUM(I, CPI*TR(I,‘GOV’)$H(I))

);

  • SYSTEM CONSTRAINT BLOCK +++++++++++++++

FACTMEQ(F)… SUM(A, QF(F,A)) + QFU(F) =E= QFS(F);

GOODMEQ(C)… QQ(C) =E= SUM(A, QINT(C,A)) + SUM(H, QH(C,H))+ QG(C) +
QINV(C);

BOPEQ… BOP =E= SUM(C$CM(C), PWM(C)*QM(C))

-( SUM(C$CE(C), PWE(C)*QE(C))

  • SUM(I, TR(I,‘ROW’)$H(I))

  • TR(‘GOV’,‘ROW’)

);

WALREQ… WALR =E=

( SUM(H, MPS(H)*(1-ty(H))*YH(H))

    • YFRM
  • GBS + EXR*BOP )
  • ( SUM(C, PQ(C)*QINV(C)) );
  • MODEL ===========================================================

MODELS SOEMV1 “Small Open Economy Model Ver1” /ALL/ ;

  • use hold fix to speed up the solution

  • This attribute tells GAMS whether to generate and send to the solver the

  • variables that are being held fixed by the .fx

SOEMV1.HOLDFIXED = 1;

*#############################################################################

  • SOCIAL ACCOUNTING MATRIX =======================================

TABLE SAM(AC,ACAL) social accounting matrix

            AGR-A                 NAGR-A               AGR-C   NAGR-C
         LAB        CAP       U-HHD                 R-HHD

AGR-A 0 0 279
0 0 0
0 0

NAGR-A 0 0
0 394 0 0 0
0

AGR-C 84 55
0 0 0 0
30 49

NAGR-C 50 99 0
0 0 0 165
92

LAB 72 105 0
0 0 0
0 0

CAP 73 135 0
0 0 0
0 0

U-HHD 0 0 0
0 95 125 0
0

R-HHD 0 0
0 0 82 83
0 0

GOV 0 0 0
0 0 0
0 0

ROW 0 0 0
105 0 0
0 0

YTAX 0 0
0 0 0 0 20
5

STAX 0 0 10
20 0 0
0 0

TAR 0 0 0
39 0 0
0 0

S-I 0 0
0 0 0 0
70 40

  •        GOV                      ROW                    YTAX
    

STAX TAR S-I

AGR-A 0 0
0 0 0 0

NAGR-A 0 0 0
0 0 0

AGR-C 13 30
0 0 0 28

NAGR-C 67 0 0
0 0 85

LAB 0 0 0
0 0 0

CAP 0 0
0 0 0 0

U-HHD 25 40 0
0 0 0

R-HHD 5 16 0
0 0 0

GOV 0 15
25 30 39 0

ROW 0 0 0
0 0 0

YTAX 0 0 0
0 0 0

STAX 0 0 0
0 0 0

TAR 0 0 0
0 0 0

S-I 1 4
0 0 0 0

;

  • GENERATING THE TOTAL COLUMN AND ROW FOR SAM

  • note the use of ALIAS SET ACNTAL

SAM(‘TOTAL’,ACNTAL) = SUM(ACNT, SAM(ACNT,ACNTAL));

SAM(ACNT,‘TOTAL’) = SUM(ACNTAL, SAM(ACNT,ACNTAL));

  • CHECKING THE CONSISTENCY: tdiff should be zero

PARAMETER tdiff(AC) “(column total - row total) for account AC”;

tdiff(ACNT) = SAM(‘TOTAL’,ACNT)-SAM(ACNT,‘TOTAL’);

DISPLAY SAM, tdiff;

---------- 2 of 3 ----------
From: Hasan Dudu
Date: Apr 10 11:10AM +0300
Url: http://groups.google.com/group/gamsworld/msg/7a5f1e9292023f9

most of the problems in your code is due to misaligned SAM table. first
correct it. headers of the columns should be inline with the numbers in the
column. After that, following errors remains.

line 99: MPS(H => MPS(H) (missing paranthesis)
line 88: add CPI as variable (CPI is not added as a variable)
line 382: CPI => CPI.FX (CPI is a variable)
line 384: CPI => CPI.L (CPI is a variable)
line 676: delete 0 (unnecessary zero)

hasan

---------- 3 of 3 ----------
From: sara sohail
Date: Apr 10 01:24AM -0700
Url: http://groups.google.com/group/gamsworld/msg/bba2bdc16f19a5a3

Thank you Hasan!

I ll work on it accordingly. But you know its difficult for me to
understand GAMS. Can you plese tell any link except gams.com to learn GAMS
coding easily. I have a few but may be you can recommend something better.

Regards,

Sara

=============================================================================
Topic: Can I get append set element name/text dynamically into * set, eg
“abc”
Url: http://groups.google.com/group/gamsworld/t/17b8b154ba212f3b

---------- 1 of 1 ----------
From: AC
Date: Apr 09 04:10PM -0700
Url: http://groups.google.com/group/gamsworld/msg/688cad4ae708f08e

Hi

There is an existing report in a model we help maintain which is set
up something like:

parameter MY_REPORT(*);

MY_REPORT(‘discounted value in 2010’) = SOME_VALUE;
MY_REPORT(‘discounted value in 2011’) = SOME_VALUE;
etc

We want to keep the “discounted value in” prefix text (used by other
things elsewhere). What I want to do is loop over our years set and
append the year set element’s text to that prefix.

So something along the lines of

loop years do
MY_REPORT(‘discounted value in’ ) = SOME_VALUE;
endloop

Is there a way to do this? Ideally I would like it done without using
some external $batinclude file, or an echo statement which writes it
out and then reads it back in again. Is this possible to do?

Thanks in advance
Andy


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

hi everybody
i have same problem i will appropriate u can help me
thanks

On Thu, Apr 12, 2012 at 7:41 PM, Krishna Prasad wrote:

Hi Reza Kia,

You can see the eps-constraint method implementation in the following link :
http://www.gams.com/modlib/libhtml/epscm.htm

It is for LP, you can modify accordingly.


Regards
Krishna Prasad



On Wed, Apr 11, 2012 at 11:22 PM, reza kia wrote:

Dear colleagues

I’m working on a two-objective model where one of the objectives is non-linear.
How can I implement epsilon constraint method on my model?
Which solver is appropriate for my model?
I would be really appreciated if someone send me an example code with
GAMS implementing epsilon constraint method on a two-objective model

Reza Kia, PhD candidate of industrial engineering

Regards

On 4/10/12, gamsworld@googlegroups.com wrote:

=============================================================================
Today’s Topic Summary

Group: gamsworld@googlegroups.com
Url: http://groups.google.com/group/gamsworld/topics

=============================================================================
Topic: import data from Excel to GAMS
Url: http://groups.google.com/group/gamsworld/t/ba3c7bb5663a5fde

---------- 1 of 5 ----------
From: “D.Dileep”
Date: Apr 10 07:23AM -0700
Url: http://groups.google.com/group/gamsworld/msg/3f9bff7cfceb4bdc

Hi all,

Plz, can any one tell me how to import data from Excel to GAMS?

---------- 2 of 5 ----------
From: Paul Van der Eijk
Date: Apr 10 11:19AM -0400
Url: http://groups.google.com/group/gamsworld/msg/985b2d9b94f321b8

Look for GDXXRW in gdxutils.pdf and mccarlgamsusersguide.pdf in the docs
directory.

–Paul


Paul van der Eijk
GAMS Development Corporation
Tel : (202) 342-0180 Fax : (202) 342-0181
Email: pvandereijk@gams.com
Web : http://www.gams.com

---------- 3 of 5 ----------
From: “A.R. Bahari”
Date: Apr 10 07:39PM +0330
Url: http://groups.google.com/group/gamsworld/msg/b6e7aca294cc2e05

Hi
Download the latest version of gams from www.gams.com
First locate the .xls file in the following path:
E:\Data\MatrixInputs.XLS
Now its ready to run.
Have a look at the sheet named “index” and at the 17 first rows of my cod
To know how importing data fromexcel is performed.
the 5 last rows export data to Excel
Close the excel file when GAMS is runing.

---------- 4 of 5 ----------
From: Krishna Prasad
Date: Apr 10 10:52PM +0530
Url: http://groups.google.com/group/gamsworld/msg/1398381a5dc6b653

Hi,

Let us suppose example.xls file you want to read and it has row name as
x1,x2,x3 ,…x10 and column name as y1,y2,…y20 and let us suppose you
want to save it in a parameter of name xydata then you can read in gams as
follow:

Set i /x1x10/;
Set j /y1
y20/;

PARAMETER xydata(i,j)
$CALL GDXXRW example.xls par=xydata rng=sheet_name!A1:U10 Cdim=1 Rdim=1
$GDXIN example.gdx
$LOAD xydata
$GDXIN
Display xydata;

You can see the attached file. one thing is that you must save the .xls in
2003-2007 format

Best Regards
Krishna Prasad

---------- 5 of 5 ----------
From: Dileep Damayyawar
Date: Apr 10 11:22PM +0530
Url: http://groups.google.com/group/gamsworld/msg/1e1ea110e4b62cc

Thank you very much Paul and Bahari…


Regards
Dileep Damayyawar

=============================================================================
Topic: $ conditional evaluation: efficient code question
Url: http://groups.google.com/group/gamsworld/t/a0a20e70592d1511

---------- 1 of 1 ----------
From: Steven Dirkse
Date: Apr 10 12:14PM -0400
Url: http://groups.google.com/group/gamsworld/msg/c27037169b06d8a7

Andy,

I’m just back in the office after a week’s vacation, and surprised to
see no answer to this question. I would have guessed that GAMS is
doing short-circuit evaluation of boolean AND and OR operators, but I
thought I’d write a little model to check it out. The test (included
below) shows we do not do short-circuit evals. Run with “profile=1”
on the command line to get timing outputs.

-Steve

set I / i1 * i120 /;
set T 'trips through the loop ’ / t1 * t30 /;

alias (I,J,K);
parameter A(I,J,K);
a(I,J,K) = 1;

scalars continue, hits;

hits = 0;

loop {T$[sum{(I,J,K), a(I,J,K)} >= ord(T) * power(card(I),3)],
hits = hits + 1;
};

display hits;

continue = 1;
hits = 0;

loop {T$[continue and (sum{(I,J,K), a(I,J,K)} >= ord(T) *
power(card(I),3))],
continue = 0;
hits = hits + 1;
};

display continue, hits;

continue = 1;
hits = 0;

loop {T$continue,
if {[sum{(I,J,K), a(I,J,K)} >= ord(T) * power(card(I),3)],
continue = 0;
hits = hits + 1;
};
};

display continue, hits;


Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

=============================================================================
Topic: got hell of errors----plz help
Url: http://groups.google.com/group/gamsworld/t/28016ac3888fd0c1

---------- 1 of 4 ----------
From: sara sohail
Date: Apr 07 03:38PM +0500
Url: http://groups.google.com/group/gamsworld/msg/8b5cba1243a8b946

hi All

I am a beginner can anyone diagnose error in my coding in gams. its an
economics model.i have attached the coding in world file because i dont
know how to attach directly from GAMS.

Thanks to anyone who could answer me soon.

waiting,

Sara

---------- 2 of 4 ----------
From: sara sohail
Date: Apr 09 09:30PM -0700
Url: http://groups.google.com/group/gamsworld/msg/9bb8b1f9acd407c1

---------- Forwarded message ----------
From: sara sohail
Date: Sat, Apr 7, 2012 at 3:38 AM
Subject: got hell of errors----plz help
To: gamsworld@googlegroups.com

hi All

I am a beginner can anyone diagnose error in my coding in gams. its an
economics model.i have attached the coding in world file because i dont
know how to attach directly from GAMS.

Thanks to anyone who could answer me soon.

waiting,

Sara

---------- 3 of 4 ----------
From: Destin Zed
Date: Apr 10 10:22AM +0200
Url: http://groups.google.com/group/gamsworld/msg/7950a50fe6aa6f11

Hi Sara,

I went through your GAMS code. It seems to me that the reasons why you are
getting errors are:

(1) you misplaced the asterisk (*) on your code; it should be placed at the
first character position of a line of comment.

(2) Your data entries in the tables are disorganized. Remember the
following rules while using Table in GAMS (Source GAMS User Manual):
=> The relative positions of all entries in a table are significant. This
is the only statement where end of line (EOL) has meaning. The character
positions of the numeric table entries must overlap the character positions
of the column headings.
=> The column section has to t on one line.
=> The sequence of signed numbers forming a row must be on the same line.
=> The element definition of a row can span more than one line.
=> A specific column can appear only once in the entire table.

I hope this helps.
Desta

---------- 4 of 4 ----------
From: “hervé guene”
Date: Apr 10 03:32PM
Url: http://groups.google.com/group/gamsworld/msg/d78cbe1385e5ce5c

Hi sara, your final code should look like attached!

Cheers, Hervé

Tel : (226) 75503803 / 78357776 / 71315352

De : gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] De la
part de Destin Zed
Envoyé : mardi 10 avril 2012 08:23
À : gamsworld@googlegroups.com
Objet : Re: got hell of errors----plz help

Hi Sara,

I went through your GAMS code. It seems to me that the reasons why you are
getting errors are:

(1) you misplaced the asterisk (*) on your code; it should be placed at the
first character position of a line of comment.

(2) Your data entries in the tables are disorganized. Remember the following
rules while using Table in GAMS (Source GAMS User Manual):
=> The relative positions of all entries in a table are significant. This is
the only statement where end of line (EOL) has meaning. The character
positions of the numeric table entries must overlap the character positions
of the column headings.
=> The column section has to
t on one line.
=> The sequence of signed numbers forming a row must be on the same line.
=> The element definition of a row can span more than one line.
=> A specific column can appear only once in the entire table.

I hope this helps.
Desta

On Tue, Apr 10, 2012 at 6:30 AM, sara sohail wrote:

---------- Forwarded message ----------
From: sara sohail
Date: Sat, Apr 7, 2012 at 3:38 AM
Subject: got hell of errors----plz help
To: gamsworld@googlegroups.com

hi All

I am a beginner can anyone diagnose error in my coding in gams. its an
economics model.i have attached the coding in world file because i dont know
how to attach directly from GAMS.

Thanks to anyone who could answer me soon.

waiting,

Sara


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


“gamsworld” group.
To post to this group, send email to
gamsworld@googlegroups.com.
To unsubscribe from this group, send email to

gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at

http://groups.google.com/group/gamsworld?hl=en.

=============================================================================
Topic: Matlab-GAMS loop error
Url: http://groups.google.com/group/gamsworld/t/80551239ac423be2

---------- 1 of 3 ----------
From: tjjjc
Date: Apr 09 07:34AM -0700
Url: http://groups.google.com/group/gamsworld/msg/9b4d657f2e6641ac

Gentlemen,

I have to call GAMS in a loop from Matlab but I get irregular errors.
I use a calculated value of the previous GAMS execution and use it in
the next execution.
I do this for 96 times (96 quarters in a day)

Very seldom Matlab completes this loop (96running times of GAMS),
often it breaks somewhere irregularly with the error appended below.
If I continue the loop manually from the 2nd last iteration of the
error till the end, it works. So I don’t think it depends on the
values in the model since I use the second last value which was
calculated by the loop which ended up throwing an error.

In short, with the same data, GAMS throws an error for a different
progression in the loop!

for index = 1:length_RT_schedule
loadxls_realtime(index+startpoint-1, e_bufferRT(index),pricedata);
tic
index
a = gams(‘real_time’);
toc
e_bufferRT(index+1) = a.val(2,2);
end

to get an output with the “gams()” commando, I used these lines in
GAMS:

$set matout "‘realtimeout.gdx’, e_buffer ";
$if exist matdata.gms $include matdata.gms

execute_unload %matout%;

the error:

Microsoft Visual C++ Runtime Library
Runtime Error!

Program: C:\Program Files\GAMS23.7\gams.exe

This application has requested the Runtime to terminate it in an
unusual way.

Another error I sometimes get is a.val(2.2) is empty. If I look in
the .lst file, I find a SOLVER & MODEL error no. 13

Thank you very much

---------- 2 of 3 ----------
From: Muhajir
Date: Apr 10 10:28AM +0200
Url: http://groups.google.com/group/gamsworld/msg/b192433f8a3e73f2

Hi Thomas,

A workaround for your problem is provided at:

http://support.gams-software.com/doku.php?id=matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities

Hope this helps!

---------- 3 of 3 ----------
From: tjjjc
Date: Apr 10 03:48AM -0700
Url: http://groups.google.com/group/gamsworld/msg/3b08822146e46de

Thank you very much,

I finally got it working properly after 2 days of mystery!

On Monday, April 9, 2012 4:34:47 PM UTC+2, tjjjc wrote:

=============================================================================
Topic: please see errors in my coding—can anyone help?
Url: http://groups.google.com/group/gamsworld/t/54900ee83b2da4ba

---------- 1 of 3 ----------
From: sara sohail
Date: Apr 07 03:50PM +0500
Url: http://groups.google.com/group/gamsworld/msg/c9ea5a29a03868be

hi All,

I am a beginner and could not eliminate the simple errors in gam coding my
coding is as under (after running it i get many errors)
please can anyone help me?

$Title Generic Small Open Economy Model – “SOEM”

$STitle Version 1 with:

  • 2 goods, 2 activities, 2 households;

  • no market power in the world markets;

  • no firms amongst institutions.

  • SETS ===========================================================

SETS

AC the global set including all items

  • Since there are no Firms in this exercise, they are excluded from the sets

/

AGR-A agricultural activity

NAGR-A non-agricultural activity

AGR-C agricultural commodity

NAGR-C non-agricultural commodity

LAB labour

CAP capital

U-HHD urban household

R-HHD rural household

GOV government

ROW rest of world

S-I savings-investment

YTAX income tax

STAX sales tax

TAR import tariff

TOTAL total account in SAM

/

  • Generating the specific sets and subsets

ACNT(AC) all elements in AC except total

A(AC) activities /AGR-A, NAGR-A/

C(AC) commodities /AGR-C, NAGR-C/

CE(C) exported commodities /AGR-C/

CNE(C) non-exported commodities /NAGR-C/

CM(C) imported commodities /NAGR-C/

CNM(C) non-imported commodities /AGR-C/

F(AC) factors /LAB, CAP/

I(AC) institutions /U-HHD, R-HHD, GOV, ROW/

H(I) households /U-HHD, R-HHD/

;

  • To exclude TOTAL from ACNT:

ACNT(AC) = YES;

ACNT(‘TOTAL’) = NO;

  • Alias sets to be used when we want to distinguish between two versions,
    e.g.

  • when summing y(F,F) over columns, we can write SUM(F y(F,FAL))

ALIAS ( AC , ACAL);

ALIAS (C, CAL);

ALIAS (F,FAL);

ALIAS (I,IAL);

ALIAS (ACNT,ACNTAL);

  • PARAMETERS ======================================================

PARAMETERS

ad(A) shift in the production fn for activity a

alpha(F,A) elasticity of factor f in the production fn for
activity a

aq(C) shift parameter in CES aggregation for commodity
c

ax(C) shift parameter in CES transformation for
commodity c

beta(C,H) share of households total spending on commodity c

consumer price index

cwts(C) weight of commodity c in the CPI

deltaq(C) share parameter in CES aggregation for commodity c

deltax(C) share parameter in CES transformation for
commodity c

ir(C,A) IO coeff: qnty of c as intermediate input per unit of
activity a

INV(C) base-year qnty of investment demand for commodity
c

PWE(C) export (world) price for c (foreign currency)

PWM(C) import (world) price for c (foreign currency)

QFS(F) total supply of factor f

QG(C) government demand for commodity c (in quantity)

rhoq(C) exponent parameter in the CES aggregation for
commodity c

rhox(C) exponent parameter in the CES transformation for
commodity c

shry(H,F) share of household i in income of factor f

te(C) export subsidy or tax rate for commodity c

theta(A,C) yield coeff: yield of output c per unit of activity a

tm(C) import tariff rate for commodity c

tq(C) sales tax rate for commodity c

TR(I,IAL) transfer from institution ial to institution i

ty(H) income tax rate for household h

;

  • VARIABLES =======================================================

VARIABLES

*FREE VARIABLES

BOP balance of payment (foreign savings) in foreign
currency)

GBS government budget surplus (or deficit)

QE(C) quantity of exports for commodity c (can be import
if
QFU(F) excess sup. of factor f (e.g. unemployment. excess demand)

QM(C) quantity of imports of commodity c (can be export if

WALR dummy variable (zero at equilibrium)

*POSITIVE VARIABLES

EXR exchange rate (dom. currency per unit of for.
currency)

FPD(F,A) wage distortion factor for factor f in activity a

IADJ investment adjustment factor

MPS(H marginal (and average) propensity to save for
household h

PA(A) price of activity a

PD(C) domestic price of domestic output c

PE(C) export price for c (domestic currency)

PF(F) average price of factor f

PM(C) import price for c (domestic currency)

PQ(C) composite commodity price for c

PVA(A) value-added price for activity a

PX(C) producer price for commodity c

QA(A) level of activity a

QD(C) quantity sold domestically of domestic output c

QF(F,A) quantity demanded of factor f from activity a

QH(C,H) quantity consumed of commodity c by household h

QINT(C,A) quantity of commodity c as intermediate input to
activity a

QINV(C) quantity of investment demand for commodity c

QQ(C) quantity of goods supplied domestically (composite
supply)

QX(C) quantity of domestic output of commodity c

YF(H,F) transfer of income to institutions i from factor f

YH(H) income of household h

;

  • EQUATIONS =======================================================

  • EQUATION NAME ###############

EQUATIONS

  • PRICE BLOCK +++++++++++++++++++++++++++

PMDEF(C) import price for commodity c (domestic
currency)

PEDEF(C) export price for commodity c (domestic
currency)

ABSORB(C) absorption for commodity c

OUTVAL(C) output value for commodity c

PADEF(A) price for activity a

PVADEF(A) value-added price for activity a

PNORM CPI and the price normalization rule

  • PRODUCTION AND COMMODITY BLOCK ++++++++

PRODFN (A) Cobb-Douglas production function for
activity a

FACDEM (F, A) demand for factor f by activity a

INTDEM(C , A) intermediate demand for commodity c by
activity a

OUTPUTFN(C) output of commodity c

CESQ(C) CES aggregation of QD and QM into QQ

CESX(C) CES transformation of QD and QE into QX

ESUBMD(C) import-domestic demand ratio for commodity
c

ESUBED(C) export-domestic supply ratio for
commodity c

NMQD(C) composite version for non-imported
commodity c

NEXD(C) transformation for non-exported
commodity c

  • INSTITUTION BLOCK +++++++++++++++++++++

FACTTRNS(H,F) transfer of income from factor f to
household h

HHDINC(H) income of household h

HHDCON(C,H) consumption demand by household h for
commodity c

INVDEM(C) investment demand for commodity c

GBC government budget surplus

  • SYSTEM CONSTRAINT BLOCK +++++++++++++++

FACTMEQ(F) market equilibrium condition for factor f

GOODMEQ(C) market equilibrium condition for composite
commodity c

BOPEQ current account balance for ROW

WALREQ savings-investment balance with WALR
dummy to be zero

;

  • EQUATION DESCRIPTION ###############

  • PRICE BLOCK +++++++++++++++++++++++++++

PMDEF(C)$CM(C)… PM(C) =E= (1 + tm(C))EXRPWM(C);

PEDEF(C)$CE(C)… PE(C) =E= (1-te(C))EXRPWE(C);

ABSORB(C)… PQ(C)*QQ(C)=E= (PD(C)*QD(C) + (PM(C)QM(C))$CM(C))(1 + tq(C));

OUTVAL(C)… PX(C)*QX(C) =E= PD(C)*QD(C) + (PE(C)*QE(C))$CE(C);

PADEF(A)… PA(A) =E= SUM(C, PX(C)*theta(A,C));

PVADEF(A)… PVA(A) =E= PA(A)-SUM(C, PQ(C)*ir(C,A));

PNORM… SUM(C, PQ(C)*cwts(C)) =E= CPI;

  • PRODUCTION AND COMMODITY BLOCK++++++++

PRODFN(A)… QA(A) =E= ad(A)*PROD(F, QF(F,A)**alpha(F,A));

FACDEM(F,A)… PF(F)*FPD(F,A) =E= alpha(F,A)*PVA(A)*QA(A)/QF(F,A);

INTDEM(C,A)… QINT(C,A) =E= ir(C,A)*QA(A);

OUTPUTFN(C)… QX(C) =E= SUM(A, theta(A,C)*QA(A));

CESQ(C)$CM(C)… QQ(C) =E= aq(C)*(deltaq(C)*QM(C)**(-rhoq(C))

  • (1-deltaq(C))*QD(C)(-rhoq(C)))(-1/rhoq(C));

CESX(C)$CE(C)… QX(C) =E= ax(C)*(deltax(C)*QE(C)**(rhox(C))

  • (1-deltax(C))*QD(C)(rhox(C)) )(1/rhox(C));

ESUBMD(C)$CM(C)… QM(C)/QD(C) =E=

( (deltaq(C)/(1-deltaq(C))) * (PD(C)/PM(C)) )**(1/(1+rhoq(C)));

ESUBED(C)$CE(C)… QE(C)/QD(C) =E= ( PE(C)/PD(C)*(1-deltax(C))

/deltax(C) )**(1/(rhox(C)-1) );

NMQD(C)$CNM(C)… QQ(C) =E= QD(C);

NEXD(C)$CNE(C)… QX(C) =E= QD(C);

  • INSTITUTION BLOCK +++++++++++++++++++++

FACTTRNS(H,F)… YF(H,F) =E= shry(H,F)*SUM(A, PF(F)*FPD(F,A)*QF(F,A));

HHDINC(H)… YH(H) =E= SUM(F, YF(H,F)) + CPITR(H,‘GOV’) + EXRTR(H,‘ROW’);

HHDCON(C,H)… QH(C,H) =E= beta(C,H)(1-MPS(H))(1-ty(H))*YH(H)/PQ(C);

INVDEM(C)… QINV(C) =E= inv(C)*IADJ;

GBC… GBS =E=

( SUM(H, ty(H)*YH(H))

  • SUM(C, tq(C)*(PD(C)*QD(C) + (PM(C)*QM(C))$CM(C)))

  • SUM(C$CM(C), tm(C)EXRPWM(C)*QM(C))

  • SUM(C$CE(C), te(C)EXRPWE(C)*QE(C))

  • EXR*TR(‘GOV’,‘ROW’)

) -( SUM(C, PQ(C)*QG(C))

  • SUM(I, CPI*TR(I,‘GOV’)$H(I))

);

  • SYSTEM CONSTRAINT BLOCK +++++++++++++++

FACTMEQ(F)… SUM(A, QF(F,A)) + QFU(F) =E= QFS(F);

GOODMEQ(C)… QQ(C) =E= SUM(A, QINT(C,A)) + SUM(H, QH(C,H))+ QG(C) +
QINV(C);

BOPEQ… BOP =E= SUM(C$CM(C), PWM(C)*QM(C))

-( SUM(C$CE(C), PWE(C)*QE(C))

  • SUM(I, TR(I,‘ROW’)$H(I))

  • TR(‘GOV’,‘ROW’)

);

WALREQ… WALR =E=

( SUM(H, MPS(H)*(1-ty(H))*YH(H))

    • YFRM
  • GBS + EXR*BOP )
  • ( SUM(C, PQ(C)*QINV(C)) );
  • MODEL ===========================================================

MODELS SOEMV1 “Small Open Economy Model Ver1” /ALL/ ;

  • use hold fix to speed up the solution

  • This attribute tells GAMS whether to generate and send to the solver the

  • variables that are being held fixed by the .fx

SOEMV1.HOLDFIXED = 1;

*#############################################################################

  • SOCIAL ACCOUNTING MATRIX =======================================

TABLE SAM(AC,ACAL) social accounting matrix

            AGR-A                 NAGR-A               AGR-C   NAGR-C
         LAB        CAP       U-HHD                 R-HHD

AGR-A 0 0 279
0 0 0
0 0

NAGR-A 0 0
0 394 0 0 0
0

AGR-C 84 55
0 0 0 0
30 49

NAGR-C 50 99 0
0 0 0 165
92

LAB 72 105 0
0 0 0
0 0

CAP 73 135 0
0 0 0
0 0

U-HHD 0 0 0
0 95 125 0
0

R-HHD 0 0
0 0 82 83
0 0

GOV 0 0 0
0 0 0
0 0

ROW 0 0 0
105 0 0
0 0

YTAX 0 0
0 0 0 0 20
5

STAX 0 0 10
20 0 0
0 0

TAR 0 0 0
39 0 0
0 0

S-I 0 0
0 0 0 0
70 40

  •        GOV                      ROW                    YTAX
    

STAX TAR S-I

AGR-A 0 0
0 0 0 0

NAGR-A 0 0 0
0 0 0

AGR-C 13 30
0 0 0 28

NAGR-C 67 0 0
0 0 85

LAB 0 0 0
0 0 0

CAP 0 0
0 0 0 0

U-HHD 25 40 0
0 0 0

R-HHD 5 16 0
0 0 0

GOV 0 15
25 30 39 0

ROW 0 0 0
0 0 0

YTAX 0 0 0
0 0 0

STAX 0 0 0
0 0 0

TAR 0 0 0
0 0 0

S-I 1 4
0 0 0 0

;

  • GENERATING THE TOTAL COLUMN AND ROW FOR SAM

  • note the use of ALIAS SET ACNTAL

SAM(‘TOTAL’,ACNTAL) = SUM(ACNT, SAM(ACNT,ACNTAL));

SAM(ACNT,‘TOTAL’) = SUM(ACNTAL, SAM(ACNT,ACNTAL));

  • CHECKING THE CONSISTENCY: tdiff should be zero

PARAMETER tdiff(AC) “(column total - row total) for account AC”;

tdiff(ACNT) = SAM(‘TOTAL’,ACNT)-SAM(ACNT,‘TOTAL’);

DISPLAY SAM, tdiff;

---------- 2 of 3 ----------
From: Hasan Dudu
Date: Apr 10 11:10AM +0300
Url: http://groups.google.com/group/gamsworld/msg/7a5f1e9292023f9

most of the problems in your code is due to misaligned SAM table. first
correct it. headers of the columns should be inline with the numbers in the
column. After that, following errors remains.

line 99: MPS(H => MPS(H) (missing paranthesis)
line 88: add CPI as variable (CPI is not added as a variable)
line 382: CPI => CPI.FX (CPI is a variable)
line 384: CPI => CPI.L (CPI is a variable)
line 676: delete 0 (unnecessary zero)

hasan

---------- 3 of 3 ----------
From: sara sohail
Date: Apr 10 01:24AM -0700
Url: http://groups.google.com/group/gamsworld/msg/bba2bdc16f19a5a3

Thank you Hasan!

I ll work on it accordingly. But you know its difficult for me to
understand GAMS. Can you plese tell any link except gams.com to learn GAMS
coding easily. I have a few but may be you can recommend something better.

Regards,

Sara

=============================================================================
Topic: Can I get append set element name/text dynamically into * set, eg
“abc”
Url: http://groups.google.com/group/gamsworld/t/17b8b154ba212f3b

---------- 1 of 1 ----------
From: AC
Date: Apr 09 04:10PM -0700
Url: http://groups.google.com/group/gamsworld/msg/688cad4ae708f08e

Hi

There is an existing report in a model we help maintain which is set
up something like:

parameter MY_REPORT(*);

MY_REPORT(‘discounted value in 2010’) = SOME_VALUE;
MY_REPORT(‘discounted value in 2011’) = SOME_VALUE;
etc

We want to keep the “discounted value in” prefix text (used by other
things elsewhere). What I want to do is loop over our years set and
append the year set element’s text to that prefix.

So something along the lines of

loop years do
MY_REPORT(‘discounted value in’ ) = SOME_VALUE;
endloop

Is there a way to do this? Ideally I would like it done without using
some external $batinclude file, or an echo statement which writes it
out and then reads it back in again. Is this possible to do?

Thanks in advance
Andy


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.