Hi guys,
I have a binary variable x(t) for every minute of a day (1440). This binary variable indicates if a heating device is on or off. Now I want to ensure that the device does not switch from on to off quite frequently. This is why I want to insert a restriction which ensures that if the heating device is switched on it should run for at least 10 minutes. This means that if x(t)=1 and x(t1)=0 the next 10 x(t)s should be 1. And of course the same with switching from on to off, meaning that if x(t)=0 and x(t1)=1 the next 10 x(t)s should be 0.
Is it possible to include that in a mip model in GAMS?
Ensuring realations between decision variables

 User
 Posts: 37
 Joined: 7 months ago
 Location: Rosario  Argentina
Re: Ensuring realations between decision variables
Hi again PeterBe, you can try this:
This can be fine but i'm not sure
Best regard!
Code: Select all
sets
t /1*1440/
;
alias(t,tp)
;
binary variable
x(t)
;
equation
eq1
eq2
;
eq1(t,tp)$(ord(t) gt 1 and ord(tp) gt ord(t) and ord(tp) le ord(t)+10).. 1  x(t) + x(t1) + x(tp) =g= 1;
eq2(t,tp)$(ord(t) gt 1 and ord(tp) gt ord(t) and ord(tp) le ord(t)+10).. x(t) + 1x(t1) + 1x(tp) =g= 1;
This can be fine but i'm not sure
Best regard!
Re: Ensuring realations between decision variables
Hi Manassaldi,
it seems to work How did you derive those equations? Also with the basic steps?
Thanks a lot for your great help!
it seems to work How did you derive those equations? Also with the basic steps?
Thanks a lot for your great help!

 User
 Posts: 37
 Joined: 7 months ago
 Location: Rosario  Argentina
Re: Ensuring realations between decision variables
Hi, I used the basic steps with your logic proposition.
" if x(t)=1 and x(t1)=0 the next 10 x(t)s should be 1"
X(t) ^ ¬X(t1) => (X(t+1)^X(t+2)^X(t+3)^X(t+4)^X(t+5)^X(t+6)^X(t+7)^X(t+8)^X(t+9)^X(t+10))
or reduced:
X(t) ^ ¬X(t1) => ^(tp gt t and tp le t+10) X(tp)
" if x(t)=0 and x(t1)=1 the next 10 x(t)s should be 0"
¬X(t) ^ X(t1) => (¬X(t+1)^¬X(t+2)^¬X(t+3)^¬X(t+4)^¬X(t+5)^¬X(t+6)^¬X(t+7)^¬X(t+8)^¬X(t+9)^¬X(t+10))
or reduced:
¬X(t) ^ X(t1) => ^(tp gt t and tp le t+10) ¬X(tp)
I think that you can add the equations "eq3" and "eq4" where x0 correspond to the status of the previously day:
Bye!
" if x(t)=1 and x(t1)=0 the next 10 x(t)s should be 1"
X(t) ^ ¬X(t1) => (X(t+1)^X(t+2)^X(t+3)^X(t+4)^X(t+5)^X(t+6)^X(t+7)^X(t+8)^X(t+9)^X(t+10))
or reduced:
X(t) ^ ¬X(t1) => ^(tp gt t and tp le t+10) X(tp)
" if x(t)=0 and x(t1)=1 the next 10 x(t)s should be 0"
¬X(t) ^ X(t1) => (¬X(t+1)^¬X(t+2)^¬X(t+3)^¬X(t+4)^¬X(t+5)^¬X(t+6)^¬X(t+7)^¬X(t+8)^¬X(t+9)^¬X(t+10))
or reduced:
¬X(t) ^ X(t1) => ^(tp gt t and tp le t+10) ¬X(tp)
I think that you can add the equations "eq3" and "eq4" where x0 correspond to the status of the previously day:
Code: Select all
eq3(t,tp)$(ord(t) eq 1 and ord(tp) gt ord(t) and ord(tp) le ord(t)+10).. 1  x(t) + x0 + x(tp) =g= 1;
eq4(t,tp)$(ord(t) eq 1 and ord(tp) gt ord(t) and ord(tp) le ord(t)+10).. x(t) + 1x0 + 1x(tp) =g= 1;
Bye!
Who is online
Users browsing this forum: No registered users and 1 guest