Dear Professor,
I'm trying to model an Energy Hub (photovoltaic + energy storage) and to optimize its scheduling. I'm having problems when modeling the electrical energy storage: in particular I'm modelling the maximum energy that can be charged/discharged as a variable and also the non simultaneity of charge and discharge using two binary variables. So the upper bound of the charging flow, for example, end up being the product of a variable and a binary variable. I get a warning stating "Solver not applicable (gurobi) when running the optimization. I'm pretty inexperienced in the field of optimization and solvers but I read the "Unit commitment" tutorial on github realizing that this product might be a problem (as a matter of fact in the tutorial the max/min values of the variables were constants). Is this the problem in this case? Do you have suggestions on how to fix this problem and on how to model the non simultaneity of charge and discharge keeping the model a MILP so that Gurobi can solve it?
(The complete model is attached).
Thank you very much for your attention!
%EES VARIABLES AND CONSTRAINTS
EES_capacity = 50; %energy capacity of the battery [kWh]
EES_selfdis = 0.001; %battery selfdischarge (%/100/h)
EES_loss_ch = 0.1; %charging loss
EES_loss_dis = 0.1; %dicharging loss
%%%%%%flows variables
Pphub_ees = sdpvar(1,Horizon); %variable "from power hub to battery"
Pees_phub = sdpvar(1,Horizon); %variable "from battery to power hub"
Pees_store = sdpvar(1,Horizon+1); %variable "energy stored" (the 25th step relates to the 24th step of other variables)
%%%%%%binary variables
delta_ees_ch = diag(binvar(Horizon,1)); %battery input flow bin var
delta_ees_dis = diag(binvar(Horizon,1)); %battery output bin var
ees_binvar_con = (delta_ees_ch + delta_ees_dis)<=1; %constraint on bin vars (charge/discharge not at same time)
%%%%%%in constraints
Pphub_ees_ch_max_start = EES_capacity - Pees_store(1); %maximum energy that can be charged at the first timestep
Pphub_ees_ch_max = EES_capacity - Pees_store(2:end-1); %maximum energy that can be charged for timesteps from 2 to 24 regarding the input flow
Pphub_ees_con = [Pphub_ees>=0,Pphub_ees(1)<=Pphub_ees_ch_max_start*delta_ees_ch(1,1),Pphub_ees(2:end)<=Pphub_ees_ch_max*delta_ees_ch([2:end],[2:end])]; %charge constraint: positivity/=0 + smaller than the energy that can fit in the battery + non simultaneity
%%%%%%out constraints
Pees_phub_con = [Pees_phub>=0,Pees_phub<=Pees_store(1:end-1)*delta_ees_dis]; %discharge constraint: positivity/=0 and smaller than the previously stored energy until that moment
%%%%%%store constraints
Pees_store_con = [Pees_store>=0,Pees_store<=EES_capacity]; %energy stored has to be positive/=0 and smaller than the capacity
Pees_store_cont =[Pees_store(2:end)==(1-EES_selfdis)*Pees_store(1:end-1)+(1-EES_loss_ch)*Pphub_ees - (1/(1-EES_loss_dis))*Pees_phub,Pees_store(1)==0]; %continuity: energy at timestep t+1 is equal to the energy stored at timestep t plus all charges and minus discharges
%%%%%%overall constraint
EES_constraints = [Pphub_ees_con,Pees_phub_con,Pees_store_con,Pees_store_cont,ees_binvar_con]; %EES constraints collection