I met a problem about the storage constraint. Below is the simple code.
I want to constrain that the storage only have one cycle charge/discharge state in one day. If charge is 1, discharge is -1,remaining is 0, that means 1 1 1 1 0 0 -1 -1 -1 -1…, or 1 0 1 0 1 -1 -1…, only one change trailing edge.
I am not sure the problem is clear, below also paste the fig.
cvx begin
variable E(24) nonnegtive;energy starage
variable P(24) ;power input/output
min objective
subject to
Emin<=E<=Emax;
-Pm<=P<=Pm;
E0=0;
E=[E0;E(1:end-1)]+P;
***add one cycle charge and discharge constraint***
cvx end