How do I limit the optimization variable to be non-negative when I'm using the sedumi solver

I want to use sedumi to solve a linear optimization problem, where Sk is the optimization variable, and it requires a value between 0 and 1.So, i write like this

variable Sk(K,M) nonnegative;
minimize sum(sum(Ttotal(:,:)))
subject to
for k=1:K
for m=1:M

It turns out that Sk is only less than 1, but it’s not greater than or equal to zero. Even if I add the “Sk(k,m)>=0” constraint, Sk will still be negative sometimes, how do I solve this?

How negative? It is completely normal that every constraint, also a constraint of the form x>=0, is satisfied only up to some precision.

If the value of Sk has elements which are slightly negative, such as -1e-8, but you really need Sk to be nonnegative, you can either

Add the statement
Sk = max(Sk,0);
after cvx _end

or use

variable Sk(K,M)
S >= small_positive_number

where small_positive_number is perhaps 1e-5 or 1e-6. If this constraint is 'violated" by an amount up io the solver feasibility tolerance, the value of Sk will b still be nonnegative.

Thanks a lot, Mark! I use the method one because even the positive Sk is less than 1e-9

Are you saying that the optimal S = zeros(K,M) ?

Is there some part of your program which you did not include in your post? You don’t show where Ttotal is computed. If Ttotal is a MATLAB variable set to some numerical value prior to the CVX program, then CVX would consider it to be input data; so the objective function would be minimize a constant. That is the same as a feasibility problem. That means the solver and CVX can return any value of Sk they “want to”, presuming it satisfies the constraints to within solver feasibility tolerance. If this is not the case, perhaps we can provide more assistance if you show u s the code as to how Tttotal is computed, and how it relates to the CVX (optimization) variables. If Ttotal is an expression, that expression must be provided before the objective function; because if it is provided after the objective function, the expression will have the default value of zero for use in the objective function, which will make it a feasibility problem, contrary to what you wanted.

I use the method 1, which means I add the statement
Sk = max(Sk,0);
after cvx _end
as you say.

There is actually some part of program which i did not include in my post? As for Ttotal, this is an expression containing the variable Sk and some constants that I declared after cvx_begin as “expression Ttotal(K,M) ;”. And I provid it before the objective function as
for k=1:K
for m=1:M

Hello mark, I have another problem. I use the sedumi to solve two convex optimization problems by alternately. I first minimized Ttotal by optimizing Sk. And then substituted the optimized Sk as a constant into another convex optimization problem. And also try to minimize Ttotal by optimizing the variable Q(2,M). But it shows like this

Successive approximation method to be employed.
For improved efficiency, SeDuMi is solving the dual problem.
SeDuMi will be called several times to refine the solution.
Original size: 8149 variables, 2596 equality constraints
900 exponentials add 7200 variables, 4500 equality constraints

Cones | Errors |
Mov/Act | Centering Exp cone Poly cone | Status
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed

Status: Failed
Optimal value (cvx_optval): NaN

I don’t konw why? Is it because my constraints are too tight?

Do both of the following:

  1. We don’t know what your input data is. You should rescale the data (variables) if not all non-zero input data are within a small number of orders of magnitude of one.

  2. If Mosek is available to you, use it as solver. Otherwise follow the advice at CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions

Thank you, Mark! I’ll try it.