# Disciplined convex programming error: Illegal operation: {complex affine} - {convex}

I am trying to solve this SOCP problem using CVX. But I am getting this error. How to resolve this issue?
I am attaching my code here.
Thanks

``````cvx_begin quiet
variable Gamma nonnegative
variable b(N*Nb,1,K) complex
minimize Gamma
subject to
for i=1:K
b(:,i)'*Truehk(:,i) - norm(Pk(:,:,i)'*b(:,i),2) >=  1
end
for t=1:K
for r=1: K
if r~=t
real(b(:,r)'*Truehk(:,t)) + norm(Pk(:,:,t)'*b(:,r),2) <= Gamma
end
end
end
cvx_end``````

Inequality constraints in CVX must be real http://cvxr.com/cvx/doc/dcp.html#constraints .

In `b(:,i)’*Truehk(:,i) - norm(Pk(:,:,i)’*b(:,i),2) >= 1 `
Perhaps you want to use `real(b(:,r)’` as you do in the subsequent inequality constraint?

I also suggest you not use the `quiet` option until you have verified everything, inckuding the solution process, is working correctly. That way you will see solver output and CVX output.after the solver concludes.

My variables were complex. Then I concatenated real and imaginary parts of the vectors in a single vector. But still I am not getting correct results.

This is my problem which I am trying to solve.

I have choose Pk and unit norm vector uk as
EllipsoidConfigurationMatrix= epsilon^2eye(NNb);
Pk = sqrtm(EllipsoidConfigurationMatrix);
unitNormVector = randn(NNb,1);
uk = rand
unitNormVector/norm(unitNormVector);
I have formulated my robust beamforming problem as SOCP.

This is your problem, lifted from wherever, so you will have to tell us what it is supposed to mean.Is the left-most term in each inequality supposed to be real? If not, what do the inequalities mean?

If none of the input data is complex, I presume your variables should be real (i…e, not complex), and then everything would be fine, If input data and your `b` are complex, do you want `real(b'*h)` (with indices, etc. filled in)?

hk is complex channel vector and bk’s are also complex beamforming vector. Gamma worst-case interference which is real.
I have omitted the real thing in first inequality constraint by concatenating the real and imaginary parts.

As I wrote, it is your problem, so you will have to figure out what the inequalities mean. If the LHS of the inequalities is not real, then how are the inequalities to be interpreted? If they apply separately for real and imaginary parts, then use `real(b'*h)` for one set of inequalities, and also formulate a second set of inequalities with `imag(b'*h) >= 0` , or `imag(b'*h) == 0`, or whatever it is you want.

Or perhaps your last post indicates you have now “solved” the problem of how to formulate and input in CVX, in which case I suppose all is well.

1 Like

Yeah. Thanks for your patience. I was wondering whether we can write the constraints by concatenating the real and imaginary parts.

Thanks

You can do whatever you want compliant with CVX’s rules. As to whether that is a valid formulation of your problem, meaningful in the real world, that is for you to determine, because forum readers don’t know how to interpret your problem. Is 2 + sqrt(-1) >= 1? You tell us (that is a rhetorical request, i.e., you don’t have to provide it), because we don’t know.