Tactical investment model

Problems with modeling
Post Reply
edumt6
User
User
Posts: 5
Joined: 3 years ago

Tactical investment model

Post by edumt6 »

Hi everyone,

I'm trying to write a system into GAMS language but it's being impossible to me. So, if anyone can help me, I really appreciate it.

The system is the next:
System problem.png
And it's follow by some instructions that I attach as well.

I lost my patience trying to do this and this is all I have, but is wrong, of course. Thanks in advance.

SETS i categorias /RD, AKZ, KLM, PHI, UN/;

SETS t tiempo /1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50/;

SCALAR M objetivo medio del rendimiento /0.2/;

PARAMETERS media(i) rendimiento medio esperado
/RD -0.28
AKZ 0.33
KLM 0.4
PHI 0.3
UN 0.55
/;

TABLE d(t,i) - "with the expected values"

VARIABLES VAR, x(i), y(t);

POSITIVE VARIABLES x(i);

EQUATIONS FO, RESTRIC1, RESTRIC2, RESTRIC3;

FO.. VAR =E= sum(t,0.004*(SQR(y(t))));

RESTRIC1.. sum(t,y(t)) =E= sum(i,x(i)*sum(t, d(t,i)-media(i)));
RESTRIC2.. sum(i,media(i)*x(i))=G=M;
RESTRIC3.. sum(i,x(i))=E=1;

MODEL ejemplo1 /all/;

SOLVE ejemplo1 USING NLP MINIMIZING VAR;
Problem instructions.pdf
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Tactical investment model

Post by Renger »

Hi

I added some random numbers to get the parameter d in your model. After that, there are no errors. Perhaps you could start from this code, add your table d correctly and continue.

Code: Select all

SETS i categorias /RD, AKZ, KLM, PHI, UN/;

SETS t tiempo /1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50/;

SCALAR M objetivo medio del rendimiento /0.2/;

PARAMETERS media(i) rendimiento medio esperado
/RD -0.28
AKZ  0.33
KLM  0.4
PHI  0.3
UN   0.55
/;

parameter d(t,i);

d(t,i) = uniform(0,1);

VARIABLES VAR, x(i), y(t);

POSITIVE VARIABLES x(i);

EQUATIONS FO, RESTRIC1, RESTRIC2, RESTRIC3;

FO.. VAR =E= sum(t,0.004*(SQR(y(t))));

RESTRIC1.. sum(t,y(t)) =E= sum(i,x(i)*sum(t, d(t,i)-media(i)));
RESTRIC2.. sum(i,media(i)*x(i))=G=M;
RESTRIC3.. sum(i,x(i))=E=1;

MODEL ejemplo1 /all/;

SOLVE ejemplo1 USING NLP MINIMIZING VAR;
Renger

PS. You can add code by using the </> symbol in the post editor. It is than easier to read and to copy.
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
edumt6
User
User
Posts: 5
Joined: 3 years ago

Re: Tactical investment model

Post by edumt6 »

Hi,
Thank you for your answer.
Unfortunately, there is some mistake yet, I think probably in the restrictions. Maybe they are misspelled...
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Tactical investment model

Post by Renger »

Without code, there is no way to answer that...
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
edumt6
User
User
Posts: 5
Joined: 3 years ago

Re: Tactical investment model

Post by edumt6 »

Here I attach the code .gms. I didn't copy that earlier because I don't wanna disturb with so much data here.

The problem is running but the results are not valid with the solution I have.
Solution.png
Last edited by edumt6 3 years ago, edited 1 time in total.
edumt6
User
User
Posts: 5
Joined: 3 years ago

Re: Tactical investment model

Post by edumt6 »

Here I attach the code .gms. I didn't copy that earlier because I don't wanna disturb with so much data here.

The problem is running but the results are not valid with the solution I have.
Tactical model investment.gms
Solution.png
[attachment=0]
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Tactical investment model

Post by Renger »

Hi
A few remarks:
- You have to remove the assignment to d(t,i) I made, because you inserted the table.
- Your equations FO and restrict1 do not comply with the description:
- x is not always positive, you should treat it not as a positive variable-

Equation restrict1: This one is defined over t and you didn't follow the text. It should be:

Code: Select all

RESTRIC1(t).. y(t) =E= sum(i, x(i) *  d(t,i));
You FO equation is also not the one in the description. In the description one assumes equal probabilities for all scenarios, so we can drop p(rt) from the equation:

Code: Select all

FO.. VAR =E= sum(t,SQR(y(t)));
THis results in the correct answer (a small deviation probably due to rounding errors in the data you supplied).

Code: Select all

---- VAR x  

       LOWER     LEVEL     UPPER    MARGINAL

RD      -INF      0.339     +INF       EPS       
AKZ     -INF      0.061     +INF       EPS       
KLM     -INF      0.216     +INF       EPS       
PHI     -INF      0.091     +INF       .         
UN      -INF      0.293     +INF       .         
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
edumt6
User
User
Posts: 5
Joined: 3 years ago

Re: Tactical investment model

Post by edumt6 »

Hello,

Thank you very much. I just saw it and it comes out the same.

Now what happens to me is that the associated risk (VAR) is much higher than it should be, so there is probably something wrong.

LOWER LEVEL UPPER MARGINAL

---- VAR VAR -INF 450.2594 +INF .

Thank you very much.
Post Reply