Hi,

I have the following simple optimization problem to determine the minimum number of batteries. For a given P_av = [507.9294; 594.0480; 443.1900; 85.1496], P_t =10, P_t_BS = 66,t_slots =4, the problem is infeasible when I put the constraint E_bt(1) == N_bat * beta_module.

```
P_av = [507.9294; 594.0480; 443.1900; 85.1496];
P_t =10;
P_t_BS = 66
beta_module =37.44;
delta_t =1;
eta_bt = 0.9;
t_slots =4;
cvx_begin
cvx_solver mosek
variable N_bat
variable P_bt(t_slots)
variable E_bt(t_slots+1)
minimize N_bat
subject to
E_bt >= 0
E_bt (2:end)<= N_bat * beta_module
E_bt(1) == N_bat * beta_module;
for in=1:t_slots
P_bt(in) == P_av (in) - (P_t+P_t_BS);
if (in ~= 1)
E_bt(in) == E_bt(in-1)+P_bt(in-1)*delta_t*eta_bt;
end
end
E_bt(t_slots+1) == E_bt(t_slots)+P_bt(t_slots)*delta_t*eta_bt;
cvx_end
```

You didn’t provide the value of `beta_module`

. So the problem is not reproducible. In the future, you can make things easier for people to help you by including all the input data with the program, rather than making people separately find the input data in your post.

But you’ll probably learn more by figuring things out yourself. All but section 1 of Debugging infeasible models - YALMIP also applies to CVX.

I don’t think it will cause difficulty, but it is probably better to have

`E_bt(2:end) <= N_bat * beta_module`

so that you won’t have a redundant constraint with

`E_bt(1) == N_bat * beta_module;`

Apologies for not providing the complete set of variable values. I have edited the post with all values. I checked with different solvers with and without the objective function, which is still infeasible. The problem is with the constraint E_bt(1) == N_bat * beta_module;

It is just not possible to satisfy all those constraints at once. You can’t impose that combination of initial conditions and dynamics with that input data if you want a feasible solution.

Given the other constraints, you can’t have both

`E_bt(1) == N_bat * beta_module;`

and

`P_bt(1) == P_av (1) - (P_t+P_t_BS);`

hold.

You can pick one or the other, but not both.

It is your model, so you have to be the one to figure out how to fix it, either by changing the form of the model, or by recognizing that certain input data is not feasible.

Yes, you are right. If P_bt(1) is positive then E_bt(2) will become greater than N_bat * beta_module which is not feasible. Thanks a lot!