I have a follow up question to another question of mine How to set a limit for a switch to 0 of a variable about counting the number of switches to 0 of one decision variable. Now I would like to ask the same question for two combined decision variables. So basically I have the decision variable x(t) and another decision variable y(t). The both quantify the heating output of a heating device for two different thermal storage systems for every timeslot t in [1,...,288]. It should be avoided that the heating device is switched on and off frequently thus I want to set a limit for the switching.
The rule in pseudocode looks like this:
if (x(t-1)>0 AND x(t)=0 AND y(t)=0) OR if (y(t-1)>0 AND y(t)=0 AND x(t)=0)
then increase count by 1
Constraint: count <= limit
Both variables x(t) and y(t) are continious variables with the boundaries [0,1]. It should also be noted that x(t) and y(t) can't be greater 0 simultaneously (this would mean that the heating device would have heated up 2 storages at the same time which is not possible). For this I just use 2 constraints with binary auxilliary variable h(t)
x(t)<= h(t)
y(t)<= (1- h(t))
with h(t) in {0,1}
Any idea how I can derive constraints for something like this? Next to the pure answer I would also appreciate some general advices as how to approach questions like this (if there is a more or less general way of doing this).