Multiregional Leontief Matrix

Problems with modeling
Post Reply
albertofranco
User
User
Posts: 4
Joined: 1 year ago

Multiregional Leontief Matrix

Post by albertofranco »

Hello everyone!

I hope that you are all having a good week. :D

I have been wondering if you could give me some GAMS insights on the following issue whenever you can.

I mainly need GAMS to build a random intercountry input-output coefficients table (Matrix) a “loops” number of times. I am mainly using this code (you can also find it enclosed):

Parameter

Matrix(loops,regions,industries,regions2,industries2)=uniform(0,1);

Where the following sets “regions” and “regions 2” stand for regions (5 in total) and “industries” and “industries2” stand for activities. Enclosed, you can find a picture of how that coefficients matrix should look like

Afterward, I want to calculate the Leontief Inverse of that matrix in this way:

Variable

DUM1 'Dummy'

INVA1(loops,regions3,industries2,regions,industries) 'Leontief inverse Matrix';

Equations

EQM(loops,regions,industries,regions3,industries3)

DUMEQM1;

EQM(loops,regions,industries,regions3,industries3).. SUM(industries2,Matrix(loops,regions,industries,regions3,industries2)*INVA1(loops,regions3,industries2,regions,industries))=E=Id(loops,regions,industries,regions3,industries3);

DUMEQM1.. DUM1 =E= 1;

MODEL INVERSEM1 /EQM, DUMEQM1/;

SOLVE INVERSEM1 USING NLP MAXIMIZING DUM1;

Where "Id" is an identity matrix.

However, no matter how hard I try, I always get an infeasible solution. Would you have any idea of where the mistake could come from?
Leontief.gms
(1.1 KiB) Downloaded 142 times
Thank you very much!



Best,



Alberto
Intercountry Matrix.png
User avatar
bussieck
Moderator
Moderator
Posts: 1038
Joined: 7 years ago

Re: Multiregional Leontief Matrix

Post by bussieck »

You had the indexes for the inversion wrong. The long names really confused me, so I went to short names and also improved at a few other places (Id calculation and use option to truly display a matrix).

Hope this helps,
Michael
Leontief.gms
(860 Bytes) Downloaded 225 times
albertofranco
User
User
Posts: 4
Joined: 1 year ago

Re: Multiregional Leontief Matrix

Post by albertofranco »

Dear Michael,

Thank you very much for your time and effort. Your reply is of immense help to me. Thanks, again!

Please, allow me one final question: why is this option coding for (option Matrix:4:3:2, Id:4:3:2) in this case?

Thank you very, very much!

Sincerely,

Alberto
User avatar
bussieck
Moderator
Moderator
Posts: 1038
Joined: 7 years ago

Re: Multiregional Leontief Matrix

Post by bussieck »

Option symbol:decimal:rowIndex:colIndex (see https://www.gams.com/latest/docs/UG_Dis ... layControl) allows to set the number of decimals to display and how many of the indexes to put in the row and how many in the column, so you can display and read a matrix properly.

-Michael
albertofranco
User
User
Posts: 4
Joined: 1 year ago

Re: Multiregional Leontief Matrix

Post by albertofranco »

Dear Michael,

Thank you very, very much for your help!

I really appreciate it!

Sincerely,

Alberto
cagacan.deger
User
User
Posts: 1
Joined: 1 month ago

Re: Multiregional Leontief Matrix

Post by cagacan.deger »

Hi,

I am sorry to raise a zombie thread but I cant not get around this issue.

What if some of the columns or rows of the M matrix is zero? This is a very common case with MRIO data, with some sectors some countries having no data at all. Solver returns infeasible, as expected. I have created the attached example based on the codes you two have provided. Basically, REG3 and COMM3 have 0, making the equation system infeasible.

There must be a way to tell GAMS that if a column/row is "empty", related variables can be fixed to zero. I have not been able to come up with the syntax for this. Any ideas?

Best,
Attachments
ver-01.gms
(787 Bytes) Downloaded 85 times
Post Reply