Error 125 in GAMS. I Urgently need help!

548 views
Skip to first unread message

Tanya B.

unread,
Aug 20, 2014, 11:21:06 AM8/20/14
to gams...@googlegroups.com
Dears, I'm frustrated! I am not good at modelling in GAMS... Could you help me please. I need to make a limit of Capital and Labour of two 2 producers A and B every year to be lower or equal Labour (EQL(J,T))  and Capital  EQK(J,T) calculated within the model. I have an error 125.

  1  set
   2  T   time periods /2014*2064/
   3  J   producers /A,B/
   4  ;
   5  
   6  PARAMETERS
   7  A(J,T)   technology level parameter for production function
   8  alpha(J) Expenditure shares of capital for production function
   9  r        discount rate
  10  gl       rate of labour force
  11  delta    depreciation rate
  12  L0       labour force at t = 0 /4324/
  13  K0       captial stock at t = 0 /194239/
  14  CC(T)    per capita consumption
  15  ;
  16  
  17  *Parameter values
  18  A(J,T) = 1;
  19  r=0.02;
  20  gl = 0.01;
  21  delta = 0.10;
  22  alpha("A") = 0.2;
  23  alpha("B") = 0.3;
  24  
  25  
  26  
  27  VARIABLES
  28  
  29  C(T)     consumption
  30  L(J,T)   labour force
  31  K(J,T)   capital
  32  I(J,T)   investment
  33  S(J,T)   savings
  34  Y(J,T)   economic activity or output
  35  Y1(J,T)  economic activity or output Y1
  36  TOTY(T)  total ptoduction of 2 sectors
  37  U(T)     utility
  38  TOTU     objective function
  39  
  40  ;
  41  
  42  
  43  POSITIVE VARIABLES  C(T), L(J,T), K(J,T), I(J,T), Y1(J,T);
  44  
  45  EQUATIONS
  46  
  47  EQL(J,T)   labour force
  48  EQK(J,T)   capital
  49  EQY(J,T)   economic activity
  50  EQY1(J,T)  economic activity Y1
  51  EQS(J,T)   savings
  52  EQTOTY(T)  total ptoduction of 2 sectors
  53  EQU(T)     utility
  54  EQTOTU     objectie fuction
  55  EQKS(J)
  56  EQLS(J)
  57  
  58  ;
  59  
  60  EQL(J,T)..   L(J,T) =E= L0*(1+gl)**(ORD(T));
  61  EQK(J,T)..   K(J,T) =E= (K0$(ord(T)=1)+K(J,T-1))*(1-delta)+I(J,T);
  62  EQY(J,T)..     Y(J,T) =E= A(J,T)*K(J,T)**alpha(J)*L(J,T)**(1-ALPHA(J));
  63  EQY1(J,T)..  Y(J,T) =E= C(T)+I(J,T);
  64  EQTOTY(T)..  TOTY(T) =E= sum(J,Y(J,T));
  65  EQS(J,T)..   S(J,T) =E= I(J,T);
  66  EQU(T)..     U(T) =E= C(T)/((1+r)**(ORD(T)-1));
  67  EQTOTU..     TOTU =E= sum(T,U(T));
  68  EQKS(J)..     SUM(J,K(J)) =L= K(J,T);
****                     $125$148        $149
  69  EQLS(J)..     SUM(J,L(J)) =L= L(J,T);
****                     $125$148        $149
  70  
  71  
  72  L.L(J,T)=L0;
  73  K.L(J,T)=K0;
  74  
  75 
  76 
  77  
  78  
  79  MODEL INVEST /ALL/;
  80  SOLVE INVEST USING DNLP MAXIMIZING TOTU;
****                                        $257
  81  
  82  CC(T)=C.L(T)/sum(J,L.L(J,T));
****          $141
  83  
  84  DISPLAY Y.L, C.L, L.L, K.L, I.L, S.L, U.L, TOTU.L, TOTY.L, CC;
****            $141                $141 $141 $141    $141    $141
GAMS Rev 148  x86/MS Windows                            08/20/14 17:14:18 Page 2
G e n e r a l   A l g e b r a i c   M o d e l i n g   S y s t e m
Error Messages


125  Set is under control already
141  Symbol neither initialized nor assigned
        A wild shot: You may have spurious commas in the explanatory
        text of a declaration. Check symbol reference list.
148  Dimension different - The symbol is referenced with more/less
        indices as declared
149  Uncontrolled set entered as constant
257  Solve statement not checked because of previous errors

**** 14 ERROR(S)   0 WARNING(S)

Mihai-Bogd...@ec.europa.eu

unread,
Aug 21, 2014, 2:44:04 AM8/21/14
to gams...@googlegroups.com

Error 125: if you have the equation EQKS(J) defined over J (you have j number of equations), you then can't use a SUM function over J

Error 148: you define capital K as a function of J and T, but then use it as K(J) only.

--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Savitsky Andre

unread,
Aug 21, 2014, 2:44:04 AM8/21/14
to gams...@googlegroups.com
Dear Tania!

Use see!
EQKS(J).. SUM(J,K(J)) =L= K(J,T);

J is main index in equation and You used SUM for it.

May be this help

EQKS(J).. SUM(J1,K(J1)) =L= K(J,T);


But more serious error is "T"

In equation we can see only "J"

"T" is free ad this not good and give 125 error

This will work I suggest
EQKS(J,T).. SUM(J1,K(J1)) =L= K(J,T);


Andre


Put after SET j definition Alias(j,j1) ;
and
--
With kindly regards!
Andre Savitsky
E-mail:andre...@yandex.ru
andre...@yahoo.com

Tanya B.

unread,
Aug 21, 2014, 4:20:11 AM8/21/14
to gams...@googlegroups.com, andre...@yandex.ru
Thank you Andre!

I put a definition Alias(j,j1), is it right?


set
T   time periods /2014*2064/
J   producers /A,B/
Alias(j,j1)

Then I changed the  EQKS(J)..  and still have an error 148:

EQKS(J,T)..     SUM(J1,K(J1)) =L= K(J,T);

Do I need to do the same adjustment with the EQLS(J)?
E-mail:a...@yandex.ru
       andre...@yahoo.com

Tanya B.

unread,
Aug 21, 2014, 4:24:34 AM8/21/14
to gams...@googlegroups.com, Mihai-Bogd...@ec.europa.eu
Thank you Mihai-Bogd, do you have any suggestions of how to fix it?

Savitsky Andre

unread,
Aug 22, 2014, 12:11:33 AM8/22/14
to gams...@googlegroups.com, mihai-bogd...@ec.europa.eu
Dear Tania

You have
Have to be

Alias(j,j1) ;
Equation
48 EQK(J,T) capital
49 EQY(J,T) economic activity
50 EQY1(J,T) economic activity Y1
51 EQS(J,T) savings
52 EQTOTY(T) total ptoduction of 2 sectors
53 EQU(T) utility
54 EQTOTU objectie fuction
EQKS(J,T)
EQLS(J,T)
57
58 ;
59
60 EQL(J,T).. L(J,T) =E= L0*(1+gl)**(ORD(T));
61 EQK(J,T).. K(J,T) =E= (K0$(ord(T)=1)+K(J,T-1))*(1-delta)+I(J,T);
62 EQY(J,T).. Y(J,T) =E= A(J,T)*K(J,T)**alpha(J)*L(J,T)**(1-ALPHA(J));
63 EQY1(J,T).. Y(J,T) =E= C(T)+I(J,T);
64 EQTOTY(T).. TOTY(T) =E= sum(J,Y(J,T));
65 EQS(J,T).. S(J,T) =E= I(J,T);
66 EQU(T).. U(T) =E= C(T)/((1+r)**(ORD(T)-1));
67 EQTOTU.. TOTU =E= sum(T,U(T));

EQKS(J,T).. SUM(J1,K(J1)) =L= K(J,T);
EQLS(J,T).. SUM(J1,L(J1)) =L= L(J,T);

70


I am almost sure that errors will disappear

Andre
--
With kindly regards!
Andre Savitsky
E-mail:andre...@yandex.ru
andre...@yahoo.com

Savitsky Andre

unread,
Aug 22, 2014, 12:11:33 AM8/22/14
to Tanya B., gams...@googlegroups.com
Ofcourse Tania!

Dimension have to be the same

(J,T) and (J,T)

> Thank you Andre!
>
> I put a definition Alias(j,j1), is it right?
>
> set
> T time periods /2014*2064/
> J producers /A,B/
> Alias(j,j1)
>
> Then I changed the EQKS(J).. and still have an error 148:
>
> EQKS(J,T).. SUM(J1,K(J1)) =L= K(J,T);
>
> Do I need to do the same adjustment with the EQLS(J)?
>
> On Thursday, 21 August 2014 08:44:04 UTC+2, Savitsky Andre wrote:
>
>> Dear Tania!
>>
>> Use see!
>>
>> EQKS(J).. SUM(J,K(J)) =L= K(J,T);
>>
>> J is main index in equation and You used SUM for it.
>>
>> May be this help
>>
>> EQKS(J).. SUM(J1,K(J1)) =L= K(J,T);
>>
>> But more serious error is "T"
>>
>> In equation we can see only "J"
>>
>> "T" is free ad this not good and give 125 error
>>
>> This will work I suggest
>>
>> EQKS(J,T).. SUM(J1,K(J1)) =L= K(J,T);
>>
>> Andre
>>
>> Put after SET j definition Alias(j,j1) ;
>>
>> and
>>
>> With kindly regards!
>>
>> Andre Savitsky
>>
>> E-mail:a...@yandex.ru
>>
>> andre...@yahoo.com

Tanya B.

unread,
Aug 22, 2014, 9:32:55 AM8/22/14
to gams...@googlegroups.com, andre...@yandex.ru
Hi Andre! Thanks again. But the model still doesn't work. I'm confused by  Alias(j,j1) . When I put it in the set, the word "Alias" is blue.... My intention is to limit the labour and capital of the two sectors A and B (LS, KS) every year by the L(J,T) and K(J,T) calculated within the model every year.   


 1  set
   2  T   time periods /2014*2064/
   3  J   producers /A,B/ 
   4  Alias(j,j1)
   5  ;
   6  
   7  PARAMETERS
   8  A(J,T)   technology level parameter for production function
   9  alpha(J) Expenditure shares of capital for production function
  10  r        discount rate
  11  gl       rate of labour force
  12  delta    depreciation rate
  13  L0       labour force at t = 0 /4324/
  14  K0       captial stock at t = 0 /194239/
  15  CC(T)    per capita consumption
  16  ;
  17  
  18  *Parameter values
  19  A(J,T) = 1;
  20  r=0.02;
  21  gl = 0.01;
  22  delta = 0.10;
  23  alpha("A") = 0.2;
  24  alpha("B") = 0.3;
  25  
  26  
  27  
  28  VARIABLES
  29  
  30  C(T)     consumption
  31  L(J,T)   labour force
  32  K(J,T)   capital
  33  I(J,T)   investment
  34  S(J,T)   savings
  35  Y(J,T)   economic activity or output
  36  Y1(J,T)  economic activity or output Y1
  37  TOTY(T)  total ptoduction of 2 sectors
  38  U(T)     utility
  39  TOTU     objective function
  40  
  41  ;
  42  
  43  
  44  POSITIVE VARIABLES  C(T), L(J,T), K(J,T), I(J,T), Y1(J,T);
  45  
  46  EQUATIONS
  47  
  48  EQL(J,T)   labour force
  49  EQK(J,T)   capital
  50  EQY(J,T)   economic activity
  51  EQY1(J,T)  economic activity Y1
  52  EQS(J,T)   savings
  53  EQTOTY(T)  total ptoduction of 2 sectors
  54  EQU(T)     utility
  55  EQTOTU     objectie fuction
  56  EQKS(J,T)
  57  EQLS(J,T)
  58  
  59  
  60  ;
  61  
  62  EQL(J,T)..   L(J,T) =E= L0*(1+gl)**(ORD(T));
  63  EQK(J,T)..   K(J,T) =E= (K0$(ord(T)=1)+K(J,T-1))*(1-delta)+I(J,T);
  64  EQY(J,T)..     Y(J,T) =E= A(J,T)*K(J,T)**alpha(J)*L(J,T)**(1-ALPHA(J));
  65  EQY1(J,T)..  Y(J,T) =E= C(T)+I(J,T);
  66  EQTOTY(T)..  TOTY(T) =E= sum(J,Y(J,T));
  67  EQS(J,T)..   S(J,T) =E= I(J,T);
  68  EQU(T)..     U(T) =E= C(T)/((1+r)**(ORD(T)-1));
  69  EQTOTU..     TOTU =E= sum(T,U(T));
  70  EQKS(J,T)..     SUM(J1,K(J1)) =L= K(J,T);
****                             $148
  71  
  72  EQLS(J,T)..      SUM(J1,L(J1)) =L= L(J,T);
****                              $148
  73  
  74  
  75  L.L(J,T)=L0;
  76  K.L(J,T)=K0;
  77  
  78 
  79  
  80  
  81  
  82  MODEL INVEST /ALL/;
  83  SOLVE INVEST USING DNLP MAXIMIZING TOTU;
****                                        $257
  84  
  85  CC(T)=C.L(T)/sum(J,L.L(J,T));
****          $141
  86  
  87  DISPLAY Y.L, C.L, L.L, K.L, I.L, S.L, U.L, TOTU.L, TOTY.L, CC;

****            $141                $141 $141 $141    $141    $141
GAMS Rev 148  x86/MS Windows                            08/22/14 15:23:16 Page 2

G e n e r a l   A l g e b r a i c   M o d e l i n g   S y s t e m
Error Messages
141  Symbol neither initialized nor assigned
        A wild shot: You may have spurious commas in the explanatory
        text of a declaration. Check symbol reference list.
148  Dimension different - The symbol is referenced with more/less
        indices as declared
257  Solve statement not checked because of previous errors
**** 10 ERROR(S)   0 WARNING(S)
 

Tanya B.

unread,
Aug 22, 2014, 10:19:53 AM8/22/14
to gams...@googlegroups.com, mihai-bogd...@ec.europa.eu, andre...@yandex.ru
Dear Andre, I did what you had said, but the model doesn't work....

Savitsky Andre

unread,
Aug 25, 2014, 3:57:58 AM8/25/14
to Tanya B., gams...@googlegroups.com
Dear Tania!

I am not good specialist in economic and this reason why I not understood and possible never can understand what this model is and what about

But error in GAMS code - this i not dificult

Please read this file.
*******************************************
set
T time periods /2014*2064/
J producers /A,B/ ;
Alias(j,j1)
;

PARAMETERS
A(J,T) technology level parameter for production function
alpha(J) Expenditure shares of capital for production function
r discount rate
gl rate of labour force
delta depreciation rate
L0 labour force at t = 0 /4324/
K0 captial stock at t = 0 /194239/
CC(T) per capita consumption
;

*Parameter values
A(J,T) = 1;
r=0.02;
gl = 0.01;
delta = 0.10;
alpha("A") = 0.2;
alpha("B") = 0.3;



VARIABLES

C(T) consumption
L(J,T) labour force
K(J,T) capital
I(J,T) investment
S(J,T) savings
Y(J,T) economic activity or output
Y1(J,T) economic activity or output Y1
TOTY(T) total ptoduction of 2 sectors
U(T) utility
TOTU objective function

;


POSITIVE VARIABLES C(T), L(J,T), K(J,T), I(J,T), Y1(J,T);

EQUATIONS

EQL(J,T) labour force
EQK(J,T) capital
EQY(J,T) economic activity
EQY1(J,T) economic activity Y1
EQS(J,T) savings
EQTOTY(T) total ptoduction of 2 sectors
EQU(T) utility
EQTOTU objectie fuction
EQKS(J,T)
EQLS(J,T)


;

EQL(J,T).. L(J,T) =E= L0*(1+gl)**(ORD(T));
EQK(J,T).. K(J,T) =E= (K0$(ord(T)=1)+K(J,T-1))*(1-delta)+I(J,T);
EQY(J,T).. Y(J,T) =E= A(J,T)*K(J,T)**alpha(J)*L(J,T)**(1-ALPHA(J));
EQY1(J,T).. Y(J,T) =E= C(T)+I(J,T);
EQTOTY(T).. TOTY(T) =E= sum(J,Y(J,T));
EQS(J,T).. S(J,T) =E= I(J,T);
EQU(T).. U(T) =E= C(T)/((1+r)**(ORD(T)-1));
EQTOTU.. TOTU =E= sum(T,U(T));
***************************************************** WAS
* EQKS(J,T).. SUM(J1,K(J1)) =L= K(J,T);
*** $148
*
* EQLS(J,T).. SUM(J1,L(J1)) =L= L(J,T);
*** $148
*****************************************************

***************************************************** May be this is more correct
EQKS(J,T).. SUM(J1,K(J1,T)) =L= K(J,T);
EQLS(J,T).. SUM(J1,L(J1,T)) =L= L(J,T);
*****************************************************
L.L(J,T)=L0;
K.L(J,T)=K0;
MODEL INVEST /ALL/;
SOLVE INVEST USING DNLP MAXIMIZING TOTU;
CC(T)=C.L(T)/sum(J,L.L(J,T));
DISPLAY Y.L, C.L, L.L, K.L, I.L, S.L, U.L, TOTU.L, TOTY.L, CC;

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

I receive answer that something not good in mathematical description of model. But only You can to find where economic problems in model. Some interfighing between equations.

All the best! Andre








>> Hi Andre! Thanks again. But the model still doesn't work. I'm confused by Alias(j,j1) . When I put it in the set, the word "Alias" is blue.... My intention is to limit the labour and capital of the two sectors A and B (LS, KS) every year by the L(J,T) and K(J,T) calculated within the model every year.
>
> 1 set
> 2 T time periods /2014*2064/
> 3 J producers /A,B/
> 4 Alias(j,j1)
> 5 ;
> 6
> 7 PARAMETERS
> 8 A(J,T) technology level parameter for production function
> 9 alpha(J) Expenditure shares of capital for production function
> 10 r discount rate
> 11 gl rate of labour force
> 12 delta depreciation rate
> 13 L0 labour force at t = 0 /4324/
> 14 K0 captial stock at t = 0 /194239/
> 15 CC(T) per capita consumption
> 16 ;
> 17
> 18 *Parameter values
> 19 A(J,T) = 1;
> 20 r=0.02;
> 21 gl = 0.01;
> 22 delta = 0.10;
> 23 alpha("A") = 0.2;
> 24 alpha("B") = 0.3;
> 25
> 26
> 27
> 28 VARIABLES
> 29
> 30 C(T) consumption
> 31 L(J,T) labour force
> 32 K(J,T) capital
> 33 I(J,T) investment
> 34 S(J,T) savings
> 35 Y(J,T) economic activity or output
> 36 Y1(J,T) economic activity or output Y1
> 37 TOTY(T) total ptoduction of 2 sectors
> 38 U(T) utility
> 39 TOTU objective function
> 40
> 41 ;
> 42
> 43
> 44 POSITIVE VARIABLES C(T), L(J,T), K(J,T), I(J,T), Y1(J,T);
> 45
> 46 EQUATIONS
> 47
> 48 EQL(J,T) labour force
> 49 EQK(J,T) capital
> 50 EQY(J,T) economic activity
> 51 EQY1(J,T) economic activity Y1
> 52 EQS(J,T) savings
> 53 EQTOTY(T) total ptoduction of 2 sectors
> 83 SOLVE INVEST USING DNLP MAXIMIZING TOTU;
> **** $257
> 84
> 85 CC(T)=C.L(T)/sum(J,L.L(J,T));
> **** $141
> 86
> 87 DISPLAY Y.L, C.L, L.L, K.L, I.L, S.L, U.L, TOTU.L, TOTY.L, CC;
> **** $141 $141 $141 $141 $141 $141
> GAMS Rev 148 x86/MS Windows 08/22/14 15:23:16 Page 2
> G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
> Error Messages
>
> 141 Symbol neither initialized nor assigned
> A wild shot: You may have spurious commas in the explanatory
> text of a declaration. Check symbol reference list.
> 148 Dimension different - The symbol is referenced with more/less
> indices as declared
> 257 Solve statement not checked because of previous errors
> **** 10 ERROR(S) 0 WARNING(S)
--
With kindly regards!
Andre Savitsky
E-mail:andre...@yandex.ru
andre...@yahoo.com

Tanya B.

unread,
Aug 25, 2014, 5:17:35 AM8/25/14
to gams...@googlegroups.com, for_t...@mail.ru, andre...@yandex.ru
Thanks a lot, Andre!  The model was taken from the course reader. I'll try to fix it!

Tanya B.

unread,
Aug 25, 2014, 5:23:26 AM8/25/14
to gams...@googlegroups.com, for_t...@mail.ru, andre...@yandex.ru
I also tried to fix the 148 error without "Alias":


EQKS(J,T)..  K("A",T)+K("B",T) =L= K(J,T);
EQLS(J,T)..  L("A",T)+L("B",T) =L= L(J,T);

the model works, but the result is the same as yours.



On Monday, 25 August 2014 09:57:58 UTC+2, Savitsky Andre wrote:
E-mail:a...@yandex.ru
       andre...@yahoo.com

Arne Stolbjerg Drud

unread,
Aug 25, 2014, 5:54:39 AM8/25/14
to gams...@googlegroups.com

Hi Tania

 

I usually do not respond to questions with “Urgent” in the subject list. In my view, the GAMS lists are friendly offers for help to users that themselves make an effort, think about what they do, try to learn, and put in time. So do not push with Urgent, Quick or something like that. At least it kept me away from your problem for a long time.

 

Anyway, you really have to think about your variables. What does L and K mean? Sure, it is labor and capital. But you should have something with total labor and capital in a particular year and then you should have something with the amount of labor and capital in each sector. This means you need variables like LT(T) and KT(T) for total labor and capital  and LS(J,T) and KS(J.T) for the amounts used in each sector. Go through your model and think which of these variable you need in each case. The equations that have been the subject of this thread for the last week are quite simple: they are just the relationship between the two different labor variables, LT and LS, and between the two different capital variables, KT and KS.

 

Once you have these concepts right and understand what a set and an index is, then you should be all right.

 

Good luck.

 

Arne

 

-------------------------------------------

Arne Stolbjerg Drud

ARKI Consulting & Development A/S

Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark

Phone: (+45) 44 49 03 23, Fax: (+45) 44 49 03 33, email: ad...@arki.dk

--

Tanya B.

unread,
Aug 26, 2014, 9:55:37 AM8/26/14
to gams...@googlegroups.com, ad...@arki.dk
Hi Arne,


Thanks for the message sent. Usually before asking my question, I try to fix the problem myself, to read the explanation of the error that I have and fix it. Due to my limited expertise and not being  able to solve the issue, I put the question with the word "Urgent". Finally, I tried to solve the problem (particularly Labour constraint), now I have a new error, the explanation of which I don't understand.  

with kind regards,
Tanya


set
T   time periods /2014*2064/
J   producers /A,B/
;
PARAMETERS
A(J,T)   technology level parameter for production function
alpha(J) Expenditure shares of capital for production function
r        discount rate
gl       rate of labour force
delta    depreciation rate
L0       labour force at t = 0 /5201/

K0       captial stock at t = 0 /194239/
CC(T)    per capita consumption
LB(J,T)
;
*Parameter values
A(J,T) = 1;
r=0.02;
gl = 0.01;
delta = 0.10;
alpha("A") = 0.2;
alpha("B") = 0.3;

VARIABLES
C(T)     consumption
L(J,T)   labour force
K(J,T)   capital
I(J,T)   investment
S(J,T)   savings
Y(J,T)   economic activity or output
Y1(J,T)  economic activity or output Y1
TOTY(T)  total ptoduction of 2 sectors
U(T)     utility
TOTU   objective function
LT(T)
;

POSITIVE VARIABLES  C(T), L(J,T), K(J,T), I(J,T), Y1(J,T);

EQUATIONS
EQL(J,T)   labour force
EQLT(T)
EQLB(J,T)   labour force

EQK(J,T)   capital
EQY(J,T)   economic activity
EQY1(J,T)  economic activity Y1
EQS(J,T)   savings
EQTOTY(T)  total ptoduction of 2 sectors
EQU(T)     utility
EQTOTU    objectie fuction

;
EQL(J,T)..   L(J,T) =E= L0*(1+gl)**(ORD(T));
EQLT(T)..      LT(T) =E= sum(J,L(J,T));
EQLB(J,T)..   LB("A",T)+LB("B",T) =L= LT(T);

EQK(J,T)..   K(J,T) =E= (K0$(ord(T)=1)+K(J,T-1))*(1-delta)+I(J,T);
EQY(J,T)..     Y(J,T) =E= A(J,T)*K(J,T)**alpha(J)*L(J,T)**(1-ALPHA(J));
EQY1(J,T)..  Y(J,T) =E= C(T)+I(J,T);
EQTOTY(T)..  TOTY(T) =E= sum(J,Y(J,T));
EQS(J,T)..   S(J,T) =E= I(J,T);
EQU(T)..     U(T) =E= C(T)/((1+r)**(ORD(T)));
EQTOTU..     TOTU =E= sum(T,U(T));

L.L(J,T)=L0;
K.L(J,T)=K0;

MODEL INVEST /ALL/;
SOLVE INVEST USING DNLP MAXIMIZING TOTU;

DISPLAY Y.L, C.L, L.L, K.L, I.L, S.L, U.L, TOTU.L, TOTY.L;

Tanya B.

unread,
Aug 26, 2014, 10:30:19 AM8/26/14
to gams...@googlegroups.com, ad...@arki.dk

I did not put the list file. The error 66 stated that I need to put a value for LB. Why I have to do it, if I want the model to distribute the amount of labour between two sectors LB(J,T) to be equal total labour LT(T)?

 1  set
   2  T   time periods /2014*2064/
   3  J   producers /A,B/
   4  ;
   5  
   6  PARAMETERS
   7  A(J,T)   technology level parameter for production function
   8  alpha(J) Expenditure shares of capital for production function
   9  r        discount rate
  10  gl       rate of labour force
  11  delta    depreciation rate
  12  L0       labour force at t = 0 /5201/
  13  K0       captial stock at t = 0 /194239/

  14  CC(T)    per capita consumption
  15  LB(J,T)

  16  ;
  17  
  18  *Parameter values
  19  A(J,T) = 1;
  20  r=0.02;
  21  gl = 0.01;
  22  delta = 0.10;
  23  alpha("A") = 0.2;
  24  alpha("B") = 0.3;
  25  
  26  
  27  VARIABLES

  28  
  29  C(T)     consumption
  30  L(J,T)   labour force
  31 
  32  K(J,T)   capital
  33  I(J,T)   investment
  34  S(J,T)   savings
  35  Y(J,T)   economic activity or output
  36  Y1(J,T)  economic activity or output Y1
  37  TOTY(T)  total ptoduction of 2 sectors
  38  U(T)     utility
  39  TOTU   objective function
  40  LT(T)
  41  
  42  ;
  43  
  44  
  45  POSITIVE VARIABLES  C(T), L(J,T), K(J,T), I(J,T), Y1(J,T);
  46  
  47  
  48  EQUATIONS
  49  
  50  EQL(J,T)   labour force
  51  EQLT(T)    total labour
  52  EQLB(J,T)   labour force A and K
  53  EQK(J,T)   capital
  54  EQY(J,T)   economic activity
  55  EQY1(J,T)  economic activity Y1
  56  EQS(J,T)   savings
  57  EQTOTY(T)  total ptoduction of 2 sectors
  58  EQU(T)     utility
  59  EQTOTU    objectie fuction
  60  
  61  
  62  ;
  63  
  64  EQL(J,T)..   L(J,T) =E= L0*(1+gl)**(ORD(T));
  65  
  66  EQLT(T)..      LT(T) =E= sum(J,L(J,T));
  67  EQLB(J,T)..    LT(T) =G= LB("A",T)+LB("B",T);
  68  EQK(J,T)..   K(J,T) =E= (K0$(ord(T)=1)+K(J,T-1))*(1-delta)+I(J,T);
  69 
  70  EQY(J,T)..     Y(J,T) =E= A(J,T)*K(J,T)**alpha(J)*L(J,T)**(1-ALPHA(J));
  71  EQY1(J,T)..  Y(J,T) =E= C(T)+I(J,T);
  72  EQTOTY(T)..  TOTY(T) =E= sum(J,Y(J,T));
  73  EQS(J,T)..   S(J,T) =E= I(J,T);
  74  EQU(T)..     U(T) =E= C(T)/((1+r)**(ORD(T)));
  75  EQTOTU..     TOTU =E= sum(T,U(T));
  76  
  77  
  78  
  79  L.L(J,T)=L0;
  80  K.L(J,T)=K0;
  81  
  82  
  83  
  84  MODEL INVEST /ALL/;
  85  SOLVE INVEST USING DNLP MAXIMIZING TOTU;
****                                        $66,256
**** The following DNLP errors were detected in model INVEST:
****  66 equation EQLB .. symbol "LB" has no values assigned
  86  
  87  
  88  DISPLAY Y.L, C.L, L.L, K.L, I.L, S.L, U.L, TOTU.L, TOTY.L;
GAMS Rev 148  x86/MS Windows                            08/26/14 16:21:56 Page 2

G e n e r a l   A l g e b r a i c   M o d e l i n g   S y s t e m
Error Messages

 66  The symbol shown has not been defined or assigned

        A wild shot: You may have spurious commas in the explanatory
        text of a declaration. Check symbol reference list.
256  Error(s) in analyzing solve statement. More detail appears
     Below the solve statement above


On Monday, 25 August 2014 11:54:39 UTC+2, Arne Stolbjerg Drud wrote:

Claudio Delpino

unread,
Aug 27, 2014, 3:26:35 AM8/27/14
to gams...@googlegroups.com
Tanya: 

GAMS fix: You declared LB to be a PARAMETER but then you didn't initialize (assign values) into it. I get the feeling that it should be a Variable, but no one better than you to understand what you are trying to model, which takes me to...

Philosophycal rant on modelling: 
Do you understand the difference between a parameter and a variable ? You should not be in the coding stage if you don't.
As I wrote you before: "As a general advice on modelling, the higher the ratio of [thinking time]/[writing code] the better results you will get."  

I go into this because you are asking a lot of things which stem not from difficult GAMS syntax, but not a proper understanding of modelling in general terms and your model specifically.

Write it on paper, even better, try to solve it. Know how your variables should behave. Then learn the syntax of the language -GAMS- in order to achieve what you already at least feel your model should achieve. 
Sets, summing over sets, equalities and inequalities, appear to be on top of your learning list. 

I will agree if you say this is a lengthy and a process that's not easy to do alone (don't you have a tutor ???), but I'm sure that it will payoff to you in the long run. I'd think most of the people here using the language -GAMS- efficiently have gone through it in the past. I'm sure I have, and it has paid off for me. Syntax is easy once you know your theory. 

Please don't take this the wrong way, just trying to help you. 

Regards 
Claudio

Savitsky Andre

unread,
Aug 27, 2014, 3:27:02 AM8/27/14
to gams...@googlegroups.com, ad...@arki.dk
Dear Tania!

Please, look!


You want to distribute LT into to fraction (A and B)

It is mean You do not know this distribution

It is mean this can not be parameter.

LB have to be variable only

andre
E-mail:andre...@yandex.ru
andre...@yahoo.com

Savitsky Andre

unread,
Aug 27, 2014, 3:27:02 AM8/27/14
to gams...@googlegroups.com, ad...@arki.dk
Dear Tania


I use LB as variable

All became OK


Also I change in EQUATION EQLB from =G= to =E=


It seem to me this has more sence

***************
set
T time periods /2014*2064/
J producers /A,B/
;

PARAMETERS
A(J,T) technology level parameter for production function
alpha(J) Expenditure shares of capital for production function
r discount rate
gl rate of labour force
delta depreciation rate
L0 labour force at t = 0 /5201/
K0 captial stock at t = 0 /194239/
CC(T) per capita consumption

;

*Parameter values
A(J,T) = 1;
r=0.02;
gl = 0.01;
delta = 0.10;
alpha("A") = 0.2;
alpha("B") = 0.3;


VARIABLES

C(T) consumption
L(J,T) labour force

K(J,T) capital
I(J,T) investment
S(J,T) savings
Y(J,T) economic activity or output
Y1(J,T) economic activity or output Y1
TOTY(T) total ptoduction of 2 sectors
U(T) utility
TOTU objective function
LT(T)

;


POSITIVE VARIABLES C(T), L(J,T), K(J,T), I(J,T), Y1(J,T), LB(J,T) ;


EQUATIONS

EQL(J,T) labour force
EQLT(T) total labour
EQLB(J,T) labour force A and K
EQK(J,T) capital
EQY(J,T) economic activity
EQY1(J,T) economic activity Y1
EQS(J,T) savings
EQTOTY(T) total ptoduction of 2 sectors
EQU(T) utility
EQTOTU objectie fuction


;

EQL(J,T).. L(J,T) =E= L0*(1+gl)**(ORD(T));

EQLT(T).. LT(T) =E= sum(J,L(J,T));
EQLB(J,T).. LT(T) =E= LB("A",T)+LB("B",T);
EQK(J,T).. K(J,T) =E= (K0$(ord(T)=1)+K(J,T-1))*(1-delta)+I(J,T);

EQY(J,T).. Y(J,T) =E= A(J,T)*K(J,T)**alpha(J)*L(J,T)**(1-ALPHA(J));
EQY1(J,T).. Y(J,T) =E= C(T)+I(J,T);
EQTOTY(T).. TOTY(T) =E= sum(J,Y(J,T));
EQS(J,T).. S(J,T) =E= I(J,T);
EQU(T).. U(T) =E= C(T)/((1+r)**(ORD(T)));
EQTOTU.. TOTU =E= sum(T,U(T));



L.L(J,T)=L0;
K.L(J,T)=K0;



MODEL INVEST /ALL/;
SOLVE INVEST USING DNLP MAXIMIZING TOTU;

DISPLAY Y.L, C.L, L.L, K.L, I.L, S.L, U.L, TOTU.L, TOTY.L;

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

Tanya B.

unread,
Sep 1, 2014, 12:11:31 PM9/1/14
to gams...@googlegroups.com

Thanks for the good advice, Claudio! It's a better to find an answer myself! It's not that easy to ask a tutor. Learning by doing - a motto of the university!


Tanya

Tanya B.

unread,
Sep 1, 2014, 12:14:03 PM9/1/14
to gams...@googlegroups.com, ad...@arki.dk, andre...@yandex.ru
Dear Andre!

Thank you very much! Your help is highly appreciated! 


kind regards,
Tanya
Reply all
Reply to author
Forward
0 new messages