Ensuring realations between decision variables

Problems with modeling
PeterBe
User
User
Posts: 29
Joined: 7 months ago

Ensuring realations between decision variables

Postby PeterBe » 3 months ago

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(t-1)=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(t-1)=1 the next 10 x(t)s should be 0.

Is it possible to include that in a mip model in GAMS?

Manassaldi
User
User
Posts: 44
Joined: 9 months ago
Location: Rosario - Argentina

Re: Ensuring realations between decision variables

Postby Manassaldi » 3 months ago

Hi again PeterBe, you can try this:

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(t-1) +   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) + 1-x(t-1) + 1-x(tp) =g= 1;
This can be fine but i'm not sure
Best regard!

PeterBe
User
User
Posts: 29
Joined: 7 months ago

Re: Ensuring realations between decision variables

Postby PeterBe » 3 months ago

Hi Manassaldi,

it seems to work :-) How did you derive those equations? Also with the basic steps?

Thanks a lot for your great help!

Manassaldi
User
User
Posts: 44
Joined: 9 months ago
Location: Rosario - Argentina

Re: Ensuring realations between decision variables

Postby Manassaldi » 3 months ago

Hi, I used the basic steps with your logic proposition.
" if x(t)=1 and x(t-1)=0 the next 10 x(t)s should be 1"
X(t) ^ ¬X(t-1) => (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(t-1) => ^(tp gt t and tp le t+10) X(tp)

" if x(t)=0 and x(t-1)=1 the next 10 x(t)s should be 0"
¬X(t) ^ X(t-1) => (¬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(t-1) => ^(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) + 1-x0 + 1-x(tp) =g= 1;
Bye!


Who is online

Users browsing this forum: No registered users and 8 guests