Model "infeasible"

Problems with modeling
Post Reply
gridemann
User
User
Posts: 2
Joined: 7 years ago

Model "infeasible"

Post by gridemann »

Hi, Im currently learing GAMS for a Project, I started off with a strong simplification of the Model wich I managed to implement,
however all they solvers Ive tried so far either produce no solution at all or completely weird ones (Binary values of 0.182 ...).

The Idea of the Model is to try to keep the water temperature of a pool above a certain treshold during a timeset with fluctuating energy price. A Binary Variable h(t) Signals wheter the heater is on at the certain time. The Goal is to compute the minimum price to keep your water "warm" and to know when to turn the heater on/off from this solution. The Water temperature is modeled in the equation temperature(t) wich computes the temp(t+1) (of the next timestep) out of the current temp(t) and h(t).

So far Im not sure whether I've described my Model wrong (syntax) or If I've simply tried out all the wrong solvers so far. I hope you know of a solution. Code below.
Thanks in Advance!
Code:

Code: Select all

Sets
t time /0,1,2,3,4,5,6,7,8,9/;

*Energy price
Parameters
price(t) Energy Price
         /0 8
          1 8
          2 1
          3 8
          4 8
          5 8
          6 8
          7 8
          8 8
          9 8/;

Variables
k cost,
temp(t) Water temperature;

Binary Variable h(t);
*Heater on/off

Equations
cost           Cost function,
temperature(t)  watertemperature function,
mint(t) minimum temperature;

cost ..        k =e= sum(t,price(t)*h(t));
temperature(t) .. temp(t)+ 10*h(t)- 1 * (1-h(t)) =e= temp(t+1) ;
mint(t).. temp(t) =g= 26;

Model test /all/;

temp.fx('0') = 30;

Solve test using rmip minimizing k;
Fred
Posts: 372
Joined: 7 years ago

Re: Model "infeasible"

Post by Fred »

Hi grideman,

your formulation of equation temparature(t) is problematic. For the last t=9 you refer to temp(t+1) on the right hand side which doesn't exist. There are different workaraounds for that. Either you may want to link your last time step to the first one and use t++1 (this may still be hard to satisfy as temperature increases/decreases in discrete steps)

Code: Select all

temperature(t) .. temp(t)+ 10*h(t)- 1 * (1-h(t)) =e= temp(t++1) ;
or you do not generate the equation for the last time step

Code: Select all

temperature(t)$(ord(t)<card(t)).. temp(t)+ 10*h(t)- 1 * (1-h(t)) =e= temp(t+1) ;


Besides that I noticed that you solve the problem as RMIP which means that the integrality requirement for discrete variables is relaxed. Hence, getting fractional values for binaty variables is not surprising. You may want to change your solve statement to

Code: Select all

Solve test using mip minimizing k;
I hope this helps!

Best,
Fred
gridemann
User
User
Posts: 2
Joined: 7 years ago

Re: Model "infeasible"

Post by gridemann »

Hi, Fred
Thank you very much for the help, with your workaround I finally got it working now :D
I was suspecting a logical mistake along those lines, but the fact some solvers actually returned results threw me off.
Fred
Posts: 372
Joined: 7 years ago

Re: Model "infeasible"

Post by Fred »

Hi Ping,

the ++ is a "Circular Lag and Lead Operator". A detailed description of lag and lead operators for ordered sets can be found in the documentation: https://gams.com/latest/docs/userguides ... dOperators

Best,
Fred
Post Reply