uncontrolled set entered as constant

Problems with modeling
Post Reply
m_tanawat
User
User
Posts: 13
Joined: 6 years ago

uncontrolled set entered as constant

Post by m_tanawat »

Hi there,

I want to represent my production equation X=AX*d in GAMS.
However, when I fill in the equation,it showed uncontrolled set entered as constant error.

I supposed that error come from set since I plus the different set together.
But I am not sure if I want to write this GAMS equation syntax (X=AX*d ). Is it possible?
If possible,how can I declare set of X.

Or is there any trick I can solve this error?

Thank you very much.


***********************************************

SET
ALLSET "Set with all elements in order"
/AGRI "Agricultural sector"
INDU "Industrial sector"
SERV "Services sector"
CONS "Consumer - final demand"
INV "Investments by origin - final demand"
GOVT "Government - final demand"
EXPORT "Exports - final demand"
TOTOUT "Total production outputs"
IMPO "Imports"
DEPR "Depreciation - primary inputs"
WAGES "Total labour expenditures - primary inputs"
PROFIT "Total profits and capital payments - primary inputs"
TOTIN "Total inputs in production or total demand by sector"
/
J(ALLSET) "Production sectors"
/AGRI, INDU, SERV/
D(ALLSET) "Final demand sectors"
/CONS, INV, GOVT, EXPORT/
Prim(ALLSET) "Primary inputs"
/DEPR, WAGES, PROFIT/

des(allset) "demand side"
/AGRI, INDU, SERV,CONS, INV, GOVT, EXPORT /

;

*The following says that I can use both names I and J to refer to set J.
ALIAS (I,J),(D,DD),(allset,allsett),(des,des2);

TABLE IODATA(ALLSET,ALLSET) Input-output table in billions of US dollars
AGRI INDU SERV CONS INV GOVT EXPORT TOTOUT
AGRI 10 30 40 100 0 40 180 400
INDU 20 60 50 300 200 30 340 1000
SERV 40 60 10 200 0 20 170 500
IMPO 60 120 20 400 100 100 0 800
DEPR 10 20 10 40
WAGES 200 600 300 1100
PROFIT 60 110 70 240

TOTIN 400 1000 500 1000 300 190 690
;

$ontext
out(i) = sum(j, IODATA(i,j)) + IODATA(i,"D") ;
va0(j) = IO("cap",j) + IO("lab",j) ;
ene0(j) = sum(en, IO(en,j)) ;
vae0(j) = va0(j) + ene0(j) ;

ax(i,j) = IODATA(i,j)/out(j) ;
avae(j) = vae0(j)/out(j) ;
ax(i,j) = IODATA(i,j)/out(j) ;
$offtext

PARAMETERS
FD(I,D) Final demand (billion US dollars) by demand sector D for goods made by sector I
INCOME(D) Total income of final demand sector D (billion US dollars)
A(I,J) Input-output coefficients from sector I to sector J
PI_coef(Prim,J) Primary inputs coefficients of input Prim in sector J
Imp_coef(ALLSET) Import coefficients of production or final demand sector
RESULT(ALLSET,ALLSET) Resulting IO-table
X0(i,j)
PI0(Prim,j)
import0(i,j)
;

X0(i,j) = IODATA(i,j);
PI0(prim,j) = IODATA(prim,j);
import0(i,j) = IODATA(i,j);
FD(I,D) = IODATA(I,D);
INCOME(D) = IODATA("TOTIN",D);
A(I,J) = IODATA(I,J)/IODATA(J,"TOTOUT");
PI_coef(Prim,J) = IODATA(Prim,J)/IODATA(J,"TOTOUT");
Imp_coef(J) = IODATA("IMPO",J)/IODATA(J,"TOTOUT");
Imp_coef(D) = IODATA("IMPO",D)/INCOME(D);

display X0,PI0,FD, INCOME, A, PI_coef, Imp_coef;

VARIABLES
X(i,des) Production quantity of good I (billion US dollars)
IMPORT Import quantities (billion US dollars)
PI(Prim,j) Primary inputs (billion US dollars)
OBJ Objective (dummy);

EQUATIONS

QX(i,des) equation of goods I
Qimport(i,j) import equation
QPI(prim,j) primary input equation
QOBJ objective value euqation
;

QX(i,des).. X(i,des)=e= (A(i,j)*X0(i,j))+FD(j,d);
QPI(prim,j).. PI(Prim,j)=e= PI0(prim,j);
Qimport(i,j).. import(i,j)=e=import0(i,j);
QOBJ.. obj=e= sum((i,j),(X(i,j)));

MODEL IO /ALL/ ;

SOLVE IO USING DNLP MAXIMIZING OBJ;
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: uncontrolled set entered as constant

Post by cladelpino »

Matrix product between matrix A and vector x:

Code: Select all

set i /i1*i3/
set j /j1*j4/

parameter A(i,j),x(j),matProd(i);
*You can set some values for A and x if you want to test the code
*Here I just set it to random integers drawn from an uniform distribution
A(i,j)=uniformint(0,10);
x(j)=uniformint(0,10);

matProd(i)=sum(j,A(i,j)*x(j));

display A,x,matProd;
Post Reply