1

I have defined a random 2x2 matrix

import cvxpy as cp 
import numpy as np

np.random.seed(1)
A = np.random.randn(2, 2)
type(A)
numpy.ndarray

This is of type numpy.ndarray and I want to use this variable within cvxpy to ask for it to become a constraint of positive definiteness. How can I convert such a numpy.ndarray to a cvxpy variable such that I can ask for

constraints = [A >> 0]

??

In my actual problem A is much more complicated that a random matrix(it is a specific 19x12 matrix I have constructed using numpy) but the idea is the same as above.

Marion
  • 271
  • 3
  • 11
  • This does not make sense. `A` as defined is a matrix of *constants*. There is nothing *variable* to *optimize over*. If you are trying to do some *get me the nearest PSD matrix P given my_metric(A, P)*, this must be explicitly stated (of course there are !cvxpy! *variables* involved). – sascha Jun 10 '21 at 13:25
  • Sorry, it was just meant to introduce/initialize a random matrix. Imagine I define this matrix with random values and I want to optimize it according to some constraints. – Marion Jun 11 '21 at 18:24
  • so you are asking if in x = cp.Variable(n) with n = np.random.randn(2, 2) is valid expession ?? – pippo1980 Jun 16 '21 at 17:10
  • A = cp.Variable((2,2)) ?? – pippo1980 Jun 16 '21 at 17:13
  • A = cp.Variable((x,y)) ?? – pippo1980 Jun 16 '21 at 21:00

0 Answers0