(zhangQK) #1
``````cvx_begin quiet
variable PEGU(length(y1));
variable PB(length(y1));
variable SOC(length(y1));
variable E(length(y1))
minimize(sum(cf*(pppp(1)*PEGU.^2+pppp(2)*PEGU+pppp(3)).*et)+ce*(SOC(1)-SOC(length(y1)))*Qb*Ueding*nb/1000);
subject to
0.3<=SOC<=0.9;
Pr+Pmloss<=PB+PEGU;
0<=PEGU<=87;
Imin*sqrt(2*E/C*nb)-R*Imin^2*nb<=PB<=E/2/R/C;
E-sqrt(E.^2-2*R*C*E.*PB)<=Imax*R*sqrt(2*C*E*nb);
diff(E)<=-pp(1)/R/Qb*(E-sqrt(E.^2-2*R*C*E.*PB));
C/2*nb*(pp(1)*SOCf+pp(2))^2<=E<=C/2*nb*nb*(pp(1)*SOC0+pp(2))^2;
E(1)==C/2*nb*(pp(1)*SOC0+pp(2));
E(length(y1))==C/2*nb*(pp(1)*SOCf+pp(2));
cvx_end
``````

Error using .* (line 262)
Disciplined convex programming error:
square.

Error in chengxu (line 35)
E-sqrt(E.^2-2RCE.PB)<=ImaxRsqrt(2CE*nb);

What should I do?Thank you.

(Erling D.Andersen) #2

The error means that the matrix in your quadratic term is not square i.e. has the same number of rows and columns.

(zhangQK) #3

The variables(such as PEGU,PB,SOC,E)are just vectors and they are related to time(Time is discrete,just like1,2,3,4…).So I want to know how I should show these variables in cvx.Do I should write these variables as PEGU(j),PB(j),SOC(j) and E(j) (j is discrete time) in constraints(subject to)?
Thank you.

(Mark L. Stone) #4

The error message description is not as clear as perhaps it could be. This error message is not due to dimensional incompatibility (number of rows and columns), but does indicate a violation of CVX’s DCP rules. In particular, `2*R*C*E.*PB` violates the rule prohibiting multiplication of two different CVX variables or expressions, in this case, `E` and `PB`.

If he constraint `E-sqrt(E.^2-2*R*C*E.*PB)<=Imax*R*sqrt(2*C*E*nb)` is convex, it will need to be reformulated. Have you proven it is convex?

Until you show otherwise, I will mark this problem as non-convex.

(zhangQK) #5

Thank you very much.