I have a problem where a variable (i.e. temperature) at one timeinterval (t) is dependent on the value in the previous interval (t1). This relationship has been modeled as the constraint given below:
dtemp(t) .. temp(t)=e=({temp(t1)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.
Considering initial conditions/values in temporal constraints

 User
 Posts: 1
 Joined: 5 months ago
Re: Considering initial conditions/values in temporal constraints
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:
2. let t run from 0 to ... (i used 100) but define the equation for t>=1 and fix temp value for t=0:
I hope this helps!
Fred
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(t1)A(t)}*exp{delt*invTau(t)})+A(t) ;
Code: Select all
set t / 0*100 / ;
temp('0').fx = temp_t0;
dtemp(t)$(ord(t)>=2).. temp(t)=e=({temp(t1)A(t)}*exp{delt*invTau(t)})+A(t) ;
Fred
Re: Considering initial conditions/values in temporal constraints
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:
https://www.gams.com/latest/gamslib_ml/ ... amsey.html
Code: Select all
kk(t+1).. k(t+1) =e= k(t) + i(t);