### Binary variable modelling

Posted:

**Tue Jan 16, 2018 8:50 pm**Hello,

I am trying to model charging and discharging of batteries with two binary variables I_ch(t) and I_dis(t). I want to impose a constraint such that both do not become 1 at the same time. For that I have an equation 0<= I_ch(t) +I_dis(t)<=1. Also, these two binary variables are being used in other two contraints to check that the battery charging power and discharging power is within limits. Those equations are:

Pmin*I_ch(t)<=Pch(t)<=Pmax*I_ch(t) and

Pmin*I_dis(t)<=Pdis(t)<=Pmax*I_dis(t).

I am posting that part of my code here:

*electrical storage constraints

ch_dis_hibinary(t)..I_ch(t) + I_dis(t) =l= 1;

ch_dis_lobinary(t)..I_ch(t) + I_dis(t) =g= 0;

charge_hilim(t)..Pch(t) =l= Pmax*I_ch(t);

charge_lolim(t)..Pch(t) =g= Pmin*I_ch(t);

discharge_hilim(t)..Pdis(t) =l= Pmax*I_dis(t);

discharge_lolim(t)..Pdis(t) =g= Pmin*I_dis(t);

Can someone please check this part of my code and tell me if I am going wrong somewhere while writing the binary constraints. Even though I am not getting any error from GAMS and my code is running but I am not getting the correct results.

Thanks in advance!

Regards

Priyanka Shinde

I am trying to model charging and discharging of batteries with two binary variables I_ch(t) and I_dis(t). I want to impose a constraint such that both do not become 1 at the same time. For that I have an equation 0<= I_ch(t) +I_dis(t)<=1. Also, these two binary variables are being used in other two contraints to check that the battery charging power and discharging power is within limits. Those equations are:

Pmin*I_ch(t)<=Pch(t)<=Pmax*I_ch(t) and

Pmin*I_dis(t)<=Pdis(t)<=Pmax*I_dis(t).

I am posting that part of my code here:

*electrical storage constraints

ch_dis_hibinary(t)..I_ch(t) + I_dis(t) =l= 1;

ch_dis_lobinary(t)..I_ch(t) + I_dis(t) =g= 0;

charge_hilim(t)..Pch(t) =l= Pmax*I_ch(t);

charge_lolim(t)..Pch(t) =g= Pmin*I_ch(t);

discharge_hilim(t)..Pdis(t) =l= Pmax*I_dis(t);

discharge_lolim(t)..Pdis(t) =g= Pmin*I_dis(t);

Can someone please check this part of my code and tell me if I am going wrong somewhere while writing the binary constraints. Even though I am not getting any error from GAMS and my code is running but I am not getting the correct results.

Thanks in advance!

Regards

Priyanka Shinde