# How to give constraints to a temporary variable

I try to calculate

log(trace(RV))

, where V is a hermitian matrix and R is a parameter matrix. But CVX show

“illegal operation: rel_entr({positive constant},{complex affine})”

I had to note that the R is hermitian too, so the trace(RV) is real. But R is not a variable which needs to be optimize. I don’t know how to mark R as a hermitian matrix.

Please show a complete, but minimum reproducible example, so we know exactly what you’re talking about.

Thank you for your help, the necessary code is as follows.

Illegal operation: rel_entr( {positive constant}, {complex affine} )

``````g = rand(N,1,M,K)+1j*rand(N,1,M,K); # g represents M*K vectors with N dimensions
gt = pagectranspose(g);
R0 = pagemtimes(g,gt); # R0 represents M*K hermitian matrixs

# we take R0 as a const parameter in CVX
cvx_begin
...
for i,j
TR(i,j) = trace(R0(:,:,i,j)*V(:,:,i,j));
for i
R(i)=sum(TR(i,:));
subject to
sum(-rel_entr(1, ones+R))  -  sum(a(:,i).*(R-TR(:,i))+b(:,i)) >= yita;
# where ones denotes a vector of ones, and 'a' 'b' denote const real parameters too.
...
end_cvx
``````

The 2nd argument of `rel_entr` (or argument of `log`) must be concave. It is not allowed to be complex. But `R0` is complex.

That’s R, which is trace(R_0*V), and satisfy V>=0(semidefinite).

it’s a affine transform and a concave transform.

trace({semidefinite}*{semidefinite})

specially, if we set R_0 as unit matrix, it works well.

modified after 10h.

Oh, I have found the solution. If I add “real()” to the formula, it will work. But I still don’t know if the result is right.

Thank you again!

It is your optimization problem. Forum readers don’t know what the “correct” problem formulation is.