DCP convex programming error: Only scalar quadratic forms can be specified in CVX

Hi.
Im trying to solve problems using CVX.
But I got the error, “Disciplined convex programming error:Only scalar quadratic forms can be specified in CVX”.
My code is

cvx_begin
variables X(4,9) U(1,9)
tk=0;
minimize(100*power(-0.9,2))
    A*X+B*U-X*P==0;
    X*r-x0==0;
for i=0:100 
    r'*exp(P'*tk)*(C*X+D*U)'*diag(1,0)*(C*X+D*U)*exp(P*tk)*r<=0.16;
    tk=tk+0.03;
end
    cvx_end

Anyone please help.

The error is in the line
r'*exp(P'*tk)*(C*X+D*U)'*diag(1,0)*(C*X+D*U)*exp(P*tk)*r<=0.16;

This is in violation of CXV’s DCP rules Why isn’t CVX accepting my model? READ THIS FIRST! . DCP rules do not allow this because it may be non-convex.

I don’t know what you are really trying to do, and whether that is convex. Therefore, I don’t know whether it can be written in a form which CVX will accept… Nevertheless, I will mark is as non-convex until such time as you show a convex model formulation.

Your code has some strange things, including:

The objective function evaluates to s scalar (it does not involve any CVX variables o expressions); therefore, your problem in effect has no objective function, i.e., is a feasibility problem.

The constraints inside the for loop do not involve the for loop index, i, . Therefore, the exact same constraints are repeated each time through the loop, i.e., 101 times. Obviously, this is not what you want to do.

diag(1,0) is the same as the scalar 1.

Thanks so much for an respond.
I recognized I have not understood CVX.
I read CXV’s DCP rules.as you say,
r’exp(P’tk)(CX+DU)'diag(1,0)(CX+D*U)exp(Ptk)*r<=0.16;
is non-convex.

The problem I am trying to reproduce is the example of a relatively optimal control(https://ieeexplore.ieee.org/document/4177469).
This is convex optimization, so I think this problem can solved using CVX.(but I couldn’t…)
In this problem, should I use other methods insted of CVX?

I think you will need to extract the model out of that paper, to which I do not have access.

Per Why isn’t CVX accepting my model? READ THIS FIRST! , your first obligation is to formulate a convex optimization problem and show that it is convex. Citing a convexity claim in a paper is not sufficient, because you may either be losing critical context, or the paer’s claim cold be wrong - that happens a lot.

If it is convex, it may or may not be possible to enter or reformulate for entry into CVX. If you present the model and convexirty proof, readers on this forum can attempt to assist you in (re)formulating it for entry into CVX.

Have you studied convex optimization, or any optimization? If not, you are better off spending time and effort reading and solving exercises in a book such as “Convex Optimization”, Boyd and Vandenberghe http://web.stanford.edu/~boyd/cvxbook/ rather than starting off trying to implement a model in a journal article.

1 Like

I truly appreciate your quick reply.
The problem is here.

If that is convex, it is not obvious to me. Does the paper show how this model is optimized using CVX, or any other convex optimization tool or solver?

Not only do constraints (23) and (24) not look convex, neither does the objective function (18), due to the product terms in the integral formula which defines W.

I recommend you follow the advice in the last paragraph of my previous reply.