How to code the following?

Uncategorized
Mar 16, 2022
S

I have the following equation that i want to solve,
x*C -E -y = 0

Here, x and y are given; C and E are variables,
x’s size = (128,1),
C’s size = (1,2),
E’s size = (128,2),
y’s size = (128,2),

An important constraint other than the equation mentioned at first is that every row in E has to have the same value. That is E[0][0] = E[1][0] = E[2][0] = … = E[127][0] and
E[0][1] = E[2][1] = … = E[127][1]

How to frame the syntax for this in cvxpy (or cvx)? Answer mainly needed for cvxpy. Please help.

M

Here is CVX code. You should be able to do the equivalent in CVXPY.

cvx_begin
variable E(128,2)
variable d(2)
E(:,1) == d(1)
E(:,2) == d(2)
...

Note that the RHS could instead be d(1)*ones(128,1) , d(2)*ones(128,1), Whether this kind of modification is needed for CVXPY is for you to determine.

Here is a different way of doing it in CVX.

cvx_begin
variable d(1,2)
E = repmat(d,128,1)
...

This second way might be faster because it has fewer variables and constraints.

S
Replying to #2

Please could you give me the cvxpy code as well because I’m a beginner and I’m kinda lost. Please help.

M

This is not the appropriate place for CVXPY assistance. You should be able to apply one or the other of the ideas I showed to CVXPY. If you need more specific CVXPY assistance, you will have to request assistance on one of the CVXPY support locations.

S
Replying to #4

Thanks for letting me know. Appreciate your patience.