Double Exponent in Objective Function

Problems with modeling
Post Reply
pelorn
User
User
Posts: 14
Joined: 4 years ago

Double Exponent in Objective Function

Post by pelorn »

hi there,

I want to include a function in the objective function that requires the objective to be squared first, multiplied with its probability, and then squared with the inverse again.

I tried the following function to figure it out:

(power((sum(t, CEMUTOTPER(t))),2))**0.5

How can I make sure that I get the same result as sum(t, CEMUTOTPER(t))? The squared function above messes it up even though it should mathematically be the same as sum(t, CEMUTOTPER(t))?

Thanks for your help
GFA
User
User
Posts: 50
Joined: 5 years ago

Re: Double Exponent in Objective Function

Post by GFA »

Hi pelorn,

I tried to reproduce your error but somehow in my example they are the same?

Code: Select all

set t /1*5/;
parameter CEMUTOTPER(t);
CEMUTOTPER(t) = 5;
parameter Test;
parameter Test2;
Test = (power((sum(t, CEMUTOTPER(t))),2))**0.5;
Test2 = sum(t, CEMUTOTPER(t))

display Test, Test2;

Code: Select all

----     10 PARAMETER Test                 =       25.000  
            PARAMETER Test2                =       25.000  
Or am I not understanding your problem correctly?

GFA
User avatar
bussieck
Moderator
Moderator
Posts: 1037
Joined: 7 years ago

Re: Double Exponent in Objective Function

Post by bussieck »

Test and Test2 are not equal:

Code: Select all

set t /1*5/;
parameter CEMUTOTPER(t);
CEMUTOTPER(t) = 5;
parameter Test;
parameter Test2;
Test = (power((sum(t, CEMUTOTPER(t))),2))**0.5;
Test2 = sum(t, CEMUTOTPER(t))
scalar diff; diff = test-test2;
display Test, Test2, diff;

Code: Select all

----     75 PARAMETER Test                 =       25.000  
            PARAMETER Test2                =       25.000  
            PARAMETER diff                 =  -3.5527E-15  
Floating point numbers don't represent real numbers accurately (https://en.wikipedia.org/wiki/Floating-point_arithmetic). So you get rounding errors. No way to guarantee equality of the two numbers. That's numerical analysis 101.

-Michael
pelorn
User
User
Posts: 14
Joined: 4 years ago

Re: Double Exponent in Objective Function

Post by pelorn »

Hey,

Thanks for your replies. So real and floating numbers are not precisely the same, but how can that have such a big effect on the model? If I try to run the model with an exponent of say 1.000001 in the objective function, leaving everything unchanged (I am trying to modify one thing in the DICE2013 model (https://sites.google.com/site/williamdn ... /dice-rice) btw), it messes up the whole output. How can that be? And any ideas how to fix that?

Many thanks
User avatar
bussieck
Moderator
Moderator
Posts: 1037
Joined: 7 years ago

Re: Double Exponent in Objective Function

Post by bussieck »

That's a totally different question. If you turn a linear coefficient into a non-linear one this can have all sorts of effects depending on the model, e.g. this want allow the variable to becomes negative. So without specifics it's hard to say what is going on. Why don't you be precise and tell us how exactly you changed the DICE-RICE model and what significant changes you see. Then one can try to help.

-Michael
pelorn
User
User
Posts: 14
Joined: 4 years ago

Re: Double Exponent in Objective Function

Post by pelorn »

Hi Michael,

Basically, I try to replicate a paper by Ackerman et al. (2013) who introduce Epstein-Zin preferences into the model.

For that, I would run the model simultaneously for six different states of climate sensitivity (the code below is only for two states) from period 10 onwards, collapse the first 9 periods and then recursively try to maximize utility in period 1.

acemutotpereq(t).. ACEMUTOTPER(t) =E= APERIODU(t) * L(t) * rr(t);
bcemutotpereq(t).. BCEMUTOTPER(t) =E= BPERIODU(t) * L(t) * rr(t);

aperiodueq(t).. APERIODU(t) =E= ((AC(T)*1000/L(T))**(1-elasmu)-1)/(1-elasmu)-1;
bperiodueq(t).. BPERIODU(t) =E= ((BC(T)*1000/L(T))**(1-elasmu)-1)/(1-elasmu)-1;

aceeq.. acertainty =E= tstep * scale1*(sum(t, ACEMUTOTPER(t)))+scale2;
bceeq.. bcertainty =E= tstep * scale1*(sum(t, BCEMUTOTPER(t)))+scale2;
util.. UTILITY =E= ((((1-Beta)* (((AC("1"))*1000)**rho)) + (beta*(((pA*(acertainty)**alpha)+(pB*(bcertainty**alpha)))**(rho/alpha))))**(1/rho));

That results in a lot of gibberish as output, so I tested it with the (Exp(2))EXP(0.5) objective function example (i.e. UTILITY =E= (((pA * acertainty + pB * bcertainty)**2)**0.5).

But that resulted in a lot of gibberish as well, the result of the objective function simply turns to 0. Even if I did the same thing to the standard DICE2013 model and only changed the objective function with (Exp(2))EXP(0.5). So I don´t know how it messes it up. Any ideas?

Thanks a lot!
Post Reply