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
Binary variable modelling
Re: Binary variable modelling
Priyanka,
I can see a problem with these constraints. ch_dis_lobinary is superfluous, but that's okay. When you say that "I am not getting the correct results" what do you mean. Do you have both I_ch and I_dist 1, or are the Pch and Pdis not 0 or between bounds? First of all make sure you get an optimal or at least feasible solution from the solver. Check the solve summary (https://www.gams.com/latest/docs/UG_GAM ... lveSummary) with the Model and Solve status.
Michael
I can see a problem with these constraints. ch_dis_lobinary is superfluous, but that's okay. When you say that "I am not getting the correct results" what do you mean. Do you have both I_ch and I_dist 1, or are the Pch and Pdis not 0 or between bounds? First of all make sure you get an optimal or at least feasible solution from the solver. Check the solve summary (https://www.gams.com/latest/docs/UG_GAM ... lveSummary) with the Model and Solve status.
Michael

 User
 Posts: 5
 Joined: 2 months ago
Re: Binary variable modelling
Dear Michael,
Thank you for your help. I could resolve my problem and now I can get Optimal solution. These constraints were correct however I had to give some lower limit constraints of some other variables in my code.
Priyanka
Thank you for your help. I could resolve my problem and now I can get Optimal solution. These constraints were correct however I had to give some lower limit constraints of some other variables in my code.
Priyanka