Creator
Creator

Reputation: 43

How can I define the following objective function in cvxpy?

In cvxpy, I have variables defined as w=Variable(10,4). My objective function is the sum of the dot products of each column. In Matlab it would be

(w(:,1)'*w(:,1) + w(:,2)'*w(:,2) + w(:,3)'*w(:,3) + w(:,4)'*w(:,4))

Can anyone please help how to do it in cvxpy?

Upvotes: 1

Views: 534

Answers (1)

Rodrigo de Azevedo
Rodrigo de Azevedo

Reputation: 1143

Your objective function is the trace of the Gram matrix, i.e., the squared Frobenius norm. Try:

objective = Minimize( norm(W,"fro") )

Upvotes: 1

Related Questions