Hi Claudio,
Thanks for the explanations and your help. I really appreciate it! Indeed I need to calculate U(T) every year, but to maximize once as it’s done with TOTU. I’ll try to figure it out in the model. Let’s keep in touch, if you have time and willingness to participate.
with best regards,
Tanya
On Friday, 29 August 2014 16:58:48 UTC+2, Claudio Delpino wrote:
Hi Tanya !
First of all, congratulations on your persistence. I just want to let you know that in the latest versions of your model (those discussed over at the other thread with Andre, Arne and others, which I hadn’t read when replying my past email), this is well defined. Please lets continue any further discussion in that thread, where the conceptual confusion seems to be the difference between parameters and variables.
I’ll give you an explanation anyway.
The question you would have to ask to yourself is about the “dimensionality” of U.
In less formal terms, ask yourself: How many “instances” of U exist?
Is there one for each time period ?, as opposed to,
Is it just one value?
(This second option means what I refer with a “scalar variable” [I might be loosing track on the formal interpretation of “scalar” here, my background in math is what I learned throughout my engineering studies so I have limitations of my own ] )
If there are many instances of U (i.e. one for each time period) then, you have to think what are you trying to maximize. If you think about it, this can only be one variable. In more formal terms, the objective of nonlinear optimization is always a scalar function. In the model you discussed in the other thread, the variable maximized is TOTU, which is the sum over all time periods “T” of U(T). TOTU is a scalar variable (zero dimensions), and as such it can be the objective of the optimization.
Don’t focus on how difficult and stressfull “programming” appears to be, but on solving your problem, what you will do eventually, and then look back at all this and laugh. What I tried to tell you (and I’m sorry if it came across as harsh) is the following: Dealing with GAMS (or any other modelling language) is difficult and stressfull for you because you appear to not been properly introduced into the basic math behind optimization. Once you are and understand what you are trying to accomplish, it will be fairly easy provided you don’t need any complicate stuff.
Do you have any background in linear algebra ? You will CERTAINLY need it if you’re going into this field.
Good luck and please concentrate any further questions on the other thread: “Error 125 in GAMS. I Urgently need help!”
Regards,
Claudio
On Fri, Aug 29, 2014 at 7:28 AM, Tanya B. wrote:
Hi Claudio,
Thanks for your help. I’m not experienced in GAMS, at the very beginner’s level. The U is an objective, that has to be maximized. Therefore, it’s a variable, defined by the model. So I need to maximize U , but not U(T). But I’m confused by what you’ve said. What is the difference between scalar variable and just variable? I can understand the difference between a parameter and a scalar. Could you please put more explanation for the phrase : “It cannot be the objective of a nonlinear optimization (which attempts to maximize or minimize a scalar function)”.
I used U instead of U(T), but the model still doesn’t work. Also made a correction for the ORD. Now I have: U =E= (C(“A”,T)**0.5)*(C(“B”,T)0.5)/((1+r)(ORD(T)-1)));
p.s. before asking, I try to solve the problem, but if I have no clue, then I ask.
p.s2. I’ve never done any programming in my life, it’s probably simple for you, but difficult and stressfull for me…
On Tuesday, 26 August 2014 17:04:40 UTC+2, Claudio Delpino wrote:
Hello: There is a big error here around U. Is it a scalar variable or is it indexed by time periods ?
If it is a scalar variable:
1- This equation maxes no sense since there isn’t a U for each period as is assumed when writing U(T)
4 EQU(T) … U(T) =E= (C(“A”,T)gamma)*(C(“B”,T)(1-gamma))/((1+r)**(ORD(T)));
2- You can use it as the objective variable for a non-linear optimization: solve invest using dnlp maximizing U
If it is an indexed variable:
1- Declaration should take that into acount:
39 U utility
should be U(T)
2- It cannot be the objective of a nonlinear optimization (which attempts to maximize or minimize a scalar function)
As a general advice on modelling, the higher the ratio of [thinking time]/[writing code] the better results you will get.
Hope to be helpful !
Claudio
On Tue, Aug 26, 2014 at 11:15 AM, Tanya B. wrote:
1 set
2 T time periods /20142064/
3 J producers /A,B/
4
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 /5201/
14 K0 captial stock at t = 0 /194239/
15 LB(J,T) labour force of the sector A or B
16 gamma Share of good A and B in utility function
17
18 ;
19
20 Parameter values
21 A(J,T) = 1;
22 r=0.02;
23 gl = 0.01;
24 delta = 0.10;
25 alpha(“A”) = 0.2;
26 alpha(“B”) = 0.3;
27 gamma = 0.5;
28
29
30 VARIABLES
31
32 C(J,T) consumption
33 L(T) labour force at time t
34 K(J,T) capital
35 I(J,T) investment
36 S(J,T) savings
37 Y(J,T) economic activity or output
38 Y1(J,T) economic activity or output Y1
39 U utility
40
41 ;
42
43
44 POSITIVE VARIABLES C(J,T), L(T), K(J,T), I(J,T), Y1(J,T);
45
46 EQUATIONS
47
48 EQL(T) labour force at time t
49 EQLB(J,T) labour force A or B
50 EQK(J,T) capital
51 EQY(J,T) economic activity
52 EQY1(J,T) economic activity Y1
53 EQS(J,T) savings
54 EQU(T) utility
55
56 ;
57
58 EQL(T)… L(T) =E= L0(1+gl)**(ORD(T));
59 EQLB(J,T)… LB(“A”,T)+LB(“B”,T) =L= L(T);
60 EQK(J,T)… K(J,T) =E= (K0$(ord(T)=1)+K(J,T-1))(1-delta)+I(J,T);
61 EQY(J,T)… Y(J,T) =E= A(J,T)K(J,T)alpha(J)*L(T)(1-ALPHA(J));
62 EQY1(J,T)… Y(J,T) =E= C(J,T)+I(J,T);
63 EQS(J,T)… S(J,T) =E= I(J,T);
64 EQU(T) … U(T) =E= (C(“A”,T)**gamma)(C(“B”,T)(1-gamma))/((1+r)(O
RD(T)));
65
66
67
68 L.L(T)=L0;
69 K.L(J,T)=K0;
70
71
72
73 MODEL INVEST /ALL/;
74 SOLVE INVEST USING DNLP MAXIMIZING U(T);
**** $148,257,409
75
76
77
78 DISPLAY Y.L, C.L, L.L, K.L, I.L, S.L, U.L;
**** $141 $141 $141 $141 $141
GAMS Rev 148 x86/MS Windows 08/26/14 16:13:07 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
409 Unrecognizable item - skip to find a new statement
looking for a ‘;’ or a key word to get started again
–
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.
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.