How to solve equality restrictions with CVX

a1,a2,a3 are variable

w1,w2,w3,w4 are known matrix

object function :

a1*w1+a2*w2+a3*w3=w4

subject to :

a1+a2+a3=1

a1,a2,a3>=0

How to get a1,a2,a3 with CVX?

a1w1+a2w2+a3*w3=w4 where w4 is a known matrix is not an objective function. What does =w4 with w4 known mean? Your objective function needs to be (evaluate to) a scalar. And per my answer to a previous post of yours, you need to use == for equality constraints.

“What does =w4 with w4 known mean?”

I mwans w1 is koown,w3 is koown,w3 is koown and w4 is knnwn.

a1,a2,a3 are variable

w1,w2,w3,w4 are known matrix,that is to say w1 is koown,w2 is koown,w3 is koown and w4 is knnwn.

object function :

min||a1w1+a2w2+a3*w3-w4||f
subject to :

a1+a2+a3==1

a1,a2,a3>=0
How to get a1,a2,a3 with CVX?

This doesn’t make any more sense than your original post. Leaving aside the =w4 (which doesn’t make sense), your objective function does not evaluate to a scalar. What are the dimensions of your variables and known matrices?

I real aim is to learn the coefficient of multiple kernel learning, that is a1,a2,a3, 3 real number. w1,w2,w3, is the square symmetrical kernel matrix, The dimension of kernel matrix is the labeled datapoint. w4 is the ideal kernel matrix. w4(i,j)=1,if label i = lable j,w4(i,j)=0, otherwise.

You need to formulate a scalar objective function. Until then, we can’t help you.

I have changed objective function. The new objective function is min||a1w1+a2w2+a3*w3-w4|\f2 subject to a1+a2+a3=1,a1>0,a2>0,a3>0 w1,w2,w3,w4 are kown. how to get a1,a2,a3?

This is a trivial problem to formulate. You should read the CVX User’s Guide.

cvx_begin
variables a1 a2 a3
minimize(norm(a1*w1+a2*w2+a3*w3-w4,'fro'))
a1+a2+a3 == 1
[a1 a2 a3] >= 0
cvx_end

After CVX solves the problem, a1, a2, and a3 will be the optimal values.