# How to optimize a non-linear least squares problem with cvxpy/cvxopt

I know how to minimize a linear function $$f : \mathbb{R}^{n} \rightarrow \mathbb{R}$$ with CVXPY but in my problem the function $$f$$ is quadratic and hence the problem is now in the form : $$\lVert AW-b\rVert_{2}$$ where A is a $$N\times N$$ matrix which depends on the vector W.

More specifically, my full problem is the following : $$\underset{w}{\operatorname{argmin}} \sum_{i=1}^{n}[w_{i}\times (\frac{Vw}{\sigma})_{i} - b_{i}]^{2}$$

where $$V$$ is the $$N \times N$$ covariance matrix, $$\sigma = \sqrt{w^{T}Vw}$$ is the standard deviation of the portfolio with weights $$w$$, and $$b=(b_{i})_{i=1,...,N}$$ is the (risk contribution) target vector.

Note that the left term in the sum $$w_{i}\times (\frac{Vw}{\sigma})_{i}$$ is a real scalar product (in the $$\mathbb{R}$$ space) between $$w_{i}$$ and $$(\frac{Vw}{\sigma})_{i}$$ (the i-th element of the vector in parentheses).

Is it possible to minimize this quantity using cvxopt/cvxpy ? I managed to do it with scipy but the algorithm took a lot of time to find the solution.