Hot answers tagged

7

The whole point is that you do NOT include the constraint $U = uu^T$ . That constraint is non-convex. Instead you include the constraint that $Z_j$ is (positive) semi-definite. This constraint is a convex relaxation of $U = uu^T$, obtained by Schur complement. I.e., the relaxed constraint, which is convex, is used instead of the original non-convex ...


5

Because the matrix KK is not PSD. It has minimum eigenvalue of -1. It is indefinite. Perhaps you are under the misapprehension that a symmetric matrix with all elements positive is PSD. As this example shows, that is not the case.


2

You can solve Question A as a second-order cone program like so: #!/usr/bin/env python3 import cvxpy as cp import numpy as np ########################## #Question A ########################## n = 50 #Arbitrary number of dimensions r = 10 #Arbitrary radius e = 3 #Epsilon value a =...


2

You are doing a broadcast (A*x), rather than matrix multiplication (A@x), so your code should look like this: #!/usr/bin/env python3 import numpy as np import cvxpy as cp A=np.array([[1,0,0],[0,1,0], [0,0,1]]) y=np.array([1,1,1]) # Upper bound for the constraint term upper=1 # Solve the optimization problem using CVXPY x = cp.Variable(3) ...


1

Based on your experience, one of (ignoring the subscripts) h or p must be a variable. Therefore h'*p is affine. After introducing subscripts, you can form the norm of the vector of these individual affine terms in compliance with CVXPY's DCP rules, because the argument of norm is affine (vector). cp.norm of the appropriate vector is correct, but not cp.norm ...


1

CVXPY's norm atom won't accept a raw Python list as an argument; you need to pass it a CVXPY expression. Stack the list of scalars into a vector using the hstack atom, like so: constraints = [cp.norm( cp.hstack([ y_hat[col] - cp.trace( np.transpose((B_hat_star[:,col][:,np.newaxis]*np.sqrt(L)*C_hat[col,:])) @ X) for col in ...


1

cvxpy's rules for disciplined convex programming are listed here. Notably, it states that: The DCP rules require that the problem objective have one of two forms: Minimize(convex) Maximize(concave) Indeed, your program runs if we remove the quad_form and doesn't run if we leave only the quad_form: prob = cp.Problem(cp.Maximize(cp.quad_form(x, ...


1

EDIT: Intermediate solution from cvxpy import * import numpy as np np.random.seed(1) n = 10 Sigma = np.random.randn(n, n) Sigma = Sigma.T.dot(Sigma) w = Variable(n) mu = np.abs(np.random.randn(n, 1)) ret = mu.T*w risk = quad_form(w, Sigma) orig_weight = [0.15,0.2,0.2,0.2,0.2,0.05,0.0,0.0,0.0,0.0] min_weight = [0.35,0.0,0.0,0.0,0.0,0,0.0,0,0.0,0.0] ...


Only top voted, non community-wiki answers of a minimum length are eligible