Considering initial conditions/values in temporal constraints

Problems with modeling
Post Reply
power_user
User
User
Posts: 1
Joined: 5 months ago

Considering initial conditions/values in temporal constraints

Post by power_user » 5 months ago

I have a problem where a variable (i.e. temperature) at one time-interval (t) is dependent on the value in the previous interval (t-1). This relationship has been modeled as the constraint given below:

dtemp(t) .. temp(t)=e=({temp(t-1)-A(t)}*exp{-delt*invTau(t)})+A(t) ;

Initial temperature value (i.e. at t=0) is known, but I don't know how to incorporate that into the given constraint. GAMS is considering the first equation as :

temp("1") =e= (0 - A("1"))*other terms.

I want the 0 in the above equation to be replaced with the initial known temperature value. How can I do that?
Thanks.

Fred
Posts: 174
Joined: 3 years ago

Re: Considering initial conditions/values in temporal constraints

Post by Fred » 5 months ago

Hi,

There are many ways to accomplish what you want to do. I'll give you two brief examples, assuming that you have initial temperature value at t=0 stored in a scalar temp_t0.

1. add temp_t0 iff t=1:

Code: Select all

dtemp(t) .. temp(t)=e=({temp_t0$(sameas(t,'1')+temp(t-1)-A(t)}*exp{-delt*invTau(t)})+A(t) ;
2. let t run from 0 to ... (i used 100) but define the equation for t>=1 and fix temp value for t=0:

Code: Select all

set t  / 0*100 / ;
temp('0').fx = temp_t0;
dtemp(t)$(ord(t)>=2).. temp(t)=e=({temp(t-1)-A(t)}*exp{-delt*invTau(t)})+A(t) ;
I hope this helps!

Fred

User avatar
dirkse
Moderator
Moderator
Posts: 91
Joined: 3 years ago
Location: Fairfax, VA

Re: Considering initial conditions/values in temporal constraints

Post by dirkse » 5 months ago

You can also use the technique used in the ramsey model in the model library. The link is below. This model is quite small and illustrates how to use subsets tfirst and tlast to handle the boundary times. It uses a lead to avoid an equation for tfirst:

Code: Select all

kk(t+1)..       k(t+1) =e=  k(t) + i(t);
https://www.gams.com/latest/gamslib_ml/ ... amsey.html

Post Reply