How do I change these 2 equations to ensure the problem is convex and fits into CVX


(YMK) #1

I have the following:
"

cvx_begin
variable x(26282);
minimize( transpose(A)*x*x(26282) + x(26281)*BattPrice );
subject to
    x(1:8760,1) == elecdemand + x(8761:17520,1) - PVpower   %power balance eqn
    x(8761:17520) <= Pmax*(x(26281)/7.2);  %Pbatt <= Pmax
    x(8761:17520) >= Pmin*(x(26281)/7.2);  %Pbatt <= Pmin
    x(17521,1) == 0.5*x(26281);    %setting initial battery capacity to half of battery capacity
    for k = linspace(17521,26279,8759)
        x(k+1) <= x(k) + ( x(k-8760) - BattLoss*abs(x(k-8760)) );
        x(k+1) >= SOCmin*x(26281);   %x(26281,1) is the BattCap
        x(k+1) <= SOCmax*x(26281);
    end
    x(1:8760) >= -10   %minimum Pgrid is -10kW (setting a limit on power fed back to grid)
    x(26282)*norm(x(8761:17520),1)<=8000*x(26281);
cvx_end

"
I believe the problem lies in 2 areas:
the objective: minimize(transpose(A)xx(26282) + x(26281)*BattPrice)
one of the constraints: x(26282)norm(x(8761:17520),1)<=8000x(26281)

I got the following error message:
"
Error using .* (line 262)
Disciplined convex programming error:
Invalid quadratic form(s): not a square.
Error in * (line 36)
z = feval( oper, x, y );
Error in convexproject_cycleconstraint (line 108)
minimize( transpose(A)xx(26282) + x(26281)*BattPrice );
"

How do I go about this error if I would like to keep that constraint on x(26282)?


(YMK) #2

Sorry for the poor formatting in my previous post. Please refer to the images attached. I know those 2 equations are not in a format for CVX, is there a trick to go around this?


(Mark L. Stone) #3

Please insert code as text and use Preformatted text button. That allows readers to copy and paste your code into a MATLAB session.

The objective and constraint you hiighlighted look non-convex, which I will assume them to bem unless you show otherwise. Please carefully read Why isn't CVX accepting my model? READ THIS FIRST! .


(YMK) #4

Hi Mark. Thanks for replying. Yes there are indeed not convex in those form. I am hoping there is a trick to make it such that it fits in as an overall convex problem


(Mark L. Stone) #5

There’s no trick that I see. Unless your problem is convex, there is no such trick.