How to import a X= 1/v variables? (Tried inv_pos and ^(-1)

Hello guys. I am now studing another paperanother paper and tried to repeat the codes with my own typing (I found a Github programme with the same title but totally different things… )
From the codes, the expression is approximated into a convex form by Taylor expansion, however I met a problem for input the variable X.

The paper directly set an “x = 1/v” type inputs, for x and v are both variables. When I tried to do the similar, the error occurs:

That obviously this input (or constraint?) is not allowed to set as this. I tried many methods such as inv_pos, ^(-1) or just 1/(…), and none of them work.
I wonder if someone met similar questions before and give me some hints? Thank you so much!!!

You’re supposed to be solving problem (1) per Algorithm 1 in . I’ll let you sort out what that all means. iI you do need to use inv_pos, you should incorporate it directly into the constraint in which it appears, and there would be no equality constraint with it (nonlinear equality constraints are non-convex and not allowed by CVX).

I recommend you carefully read CVX Users’ Guide and Why isn't CVX accepting my model? READ THIS FIRST! rather than aimlessly trying stuff in hopes you get something CVX accepts, to implement an algorithm you may not understand.

1 Like

Yeah, thank you so much for your guidance and it programme now can work, though the results are strange to me…I’ll figure it out later.
But I still have a question is, since the x and y are all based on functions of eta, why could not I set the expression like “X = 1/eta” and “Y = eta+1” to define/convert them, but to use constraints “X >= 1/eta” and “Y >= eta+1” ?
Sorry I do not find something which can solve this question from the guidance webpage and the CVX textbook you referred to me. (Or maybe I missed something…?

variable x
x^2 <= 5


variable x
y = x^2;
y <= 5

do the same thing. Note that = is assignment of an expression (whether declared or not), which is different than ==, which is equality constraint.

Assignment, =, allows nonlinear convex or concave expressions on the RHS. Of course, that assigned expression must not later be used in violation of CVX"s rules.

1 Like

Hello Mark. I wanted to pick up this programme again so I tried it again and followed the example you showed but it still shows error. It seems that assign “1/(τρβη) to X” and “τρ*sum(βη|ψψ|^2)+1 to Y” is not allowed here. If I still want to do this operation, what should I do? Thank you.

You are still treating variables as expressions. Please reread the entire CVX User’s Guide.

1 Like

After reading the guidance book and test the codes, I understand that because the X and Y are numeric arrays in the program, so they need to be defined as “expressions” not the “variables” as I programmed in former pictures.

And then it can work now, thank you!