0
$\begingroup$

I have the following quadratic optimization problem to solve:

$$max: x'\Sigma x$$ $$Sub: x'x = 1$$

Where,

$$\Sigma = \left[ \begin{matrix} 402.0571 & 266.6035\\ 266.6035 & 305.2564 \end{matrix} \right]$$

Searching the internet I found the CVXPY package that I think I can solve the problem, I did the implementation

library(CVXR)
Sigma = matrix(c(402.0571, 266.6035, 266.6035, 305.2564), nc = 2)
w = Variable(2)
objective = Maximize(quad_form(w, Sigma))

constraint = quad_form(w, diag(2)) == 1
problem = Problem(objective, constraints = list(constraint))
result = solve(problem)

however, when implementing it I get the following problem:

Error in construct_intermediate_chain(object, candidate_solvers, gp = gp) : 
  Problem does not follow DCP rules. However, the problem does follow DGP rules. Consider calling this 
function with gp = TRUE

I have no knowledge in the area of ​​convex optimization, but which PCD rule am I violating? Or is there any other mistake?

Thanks in advance!

$\endgroup$
  • 1
    $\begingroup$ The solution is any normalized eigenvector corresponding to the maximum eigenvalue. See our posts on "PCA" for (much) more. $\endgroup$ – whuber Apr 11 '20 at 18:05
  • $\begingroup$ Tanks for the @whuber tip, however, I would like to see the resolution in a computational way, because I have to solve a more complicated problem in which the technique used in PCA I think is not enough. $\endgroup$ – Jackson Maike Apr 13 '20 at 13:09
1
$\begingroup$

It seems to me that it is a lot easier, and does not require a computer. If you take the (vector) derivative of your quadratic form, you have that the conditions of an optimal point are: $$ 2\Sigma{}x = 0$$ This is a homogeneous system, hence undetermined up to an scale factor: if $x$ is a solution, so is $kx$ for any $k$; but you can remove this indeterminacy using the condition $x'x = 1$.

$\endgroup$
  • $\begingroup$ Tanks for the @Tusell tip, I know the analytical solution, however, I have another similar problem to solve in which the analytical solution I think is not viable, so I would like to see the solution of this problem computationally. $\endgroup$ – Jackson Maike Apr 13 '20 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.