CVXPY is a Python-embedded modeling language for convex optimization problems inspired by the MATLAB package CVX.
Questions tagged [cvxpy]
609 questions
2
votes
1 answer
Optimization integer programming with covariance matrix
I am trying to do a optimization problem which requires the calculation of a new covariance matrix affected by the variable within the implementation.
I am able to do so with scipy optimization Minimize using numpy.cov within my objective function.…

Wee Darren
- 21
- 1
2
votes
1 answer
numpy.bool_' object has no attribute 'parameters'
I have encountered a weird error, reporting AttributeError: 'numpy.bool_' object has no attribute 'parameters'
import numpy as np
import math
import cvxpy as cp
def max_peak(power_signal,overall_ld):
max_value = overall_ld[0] +…

Xu Siyuan
- 27
- 7
2
votes
1 answer
TypeError: tri() missing 1 required positional argument: 'N'
I can't get past the error:
> ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
7 d_unpair =…

Md. Rezuwan Hassan
- 59
- 1
- 12
2
votes
2 answers
cvxpy is solving to produce empty answer
I am working with the following code:
import sys, numpy as np
import cvxpy as cvx
if __name__ == '__main__':
sims = np.random.randint(20, 30, size=500)
center = 30
n = [500, 1]
# minimize p'*log(p)
# subject to
# …

Zanam
- 4,607
- 13
- 67
- 143
2
votes
0 answers
Mixed integer semi-definite programming (MISDP) solvers in Python
It just came to my realization that MOSEK does not support mixed-integer convex programming (MICP) problems when there are semi-definite constraints. Wrapper functions are available in MATLAB (YALMIP) and Julia (Pajarito). I was wondering whether…

mmy_ubc
- 21
- 1
2
votes
1 answer
Is there a way to define a skew_symmetric variable in cvxpy?
I want to define a 'skew_symmetric' variable in cvxpy, with real elements. Is there a short way to do this? The package supports defining 'symmetric' variables but not 'skew_symmetric' variables.
Thanks.

Arya
- 23
- 4
2
votes
1 answer
Stop GLPK from printing log messages when using cvxpy
I don't want my code to print anything to the terminal.
Right now, the line I'm running is:
prob.solve(cp.GLPK_MI, glpk={'msg_lev': 'GLP_MSG_OFF'}, verbosity=False)
And it's displaying the text:
Long-step dual simplex will be used
I've looked at…

Pro Q
- 4,391
- 4
- 43
- 92
2
votes
2 answers
CVXPY constraint: variable == 0 OR variable >= min
I am trying to solve a portfolio optimisation problem with the constraint that weights can be either zero or at least min (a Nx1 vector).
import cvxpy as cp
w = cp.Variable(len(mu))
mins = np.ones(len(mu)) * 0.03
risk = cp.quad_form(w, S)
prob =…

lagrange103
- 169
- 3
- 9
2
votes
1 answer
CVXPY returns Infeasible/Inaccurate on Quadratic Programming Optimization Problem
I am trying to use CVXPY to solve a nonnegative least squares problem (with the additional constraint that the sum of entries in the solution vector must equal 1). However, when I run CVXPY on this simple quadratic program using the SCS solver, I…

Frank Liu
- 31
- 1
- 3
2
votes
0 answers
Python - Optimizing a non-convex function that is "convex" when adding constraints
Suppose I have an objective function f(x) that is non-convex (x can be a vector), but once I add constraints it becomes a convex problem. To show what i mean, consider this trivial example: let f(x) = cos(x). Clearly, cos(x) is not convex, but if i…

user788466
- 121
- 1
2
votes
1 answer
CVXPY Optimal control of a reentry vehicle
I am trying to determine the optimal control of an Apollo-type vehicle during reentry. For simplicity, it is limited to two dimensions (down range and altitude) and a flat Earth. The control is the amount of lift. The lift direction is perpendicular…

wcottee
- 21
- 1
2
votes
0 answers
black box function in CVXPY
Suppose I have a function f(x) which I know to be convex on the domain I am interested in (for example, sin(x) on [0, Pi], but it may be some black box user-defined function). Is there any way to tell this to CVXPY?

Igor Rivin
- 4,632
- 2
- 23
- 35
2
votes
2 answers
CVXPY Quadratic Programming; ArpackNoConvergence error
I'm trying to use the Python package CVXPY to solve a convex quadratic programming problem of the first form here: https://www.cvxpy.org/examples/basic/quadratic_program.html, using the following code
x = np.variable(2 * N)
prob =…

Qwertiops
- 123
- 5
2
votes
1 answer
ERROR: Could not build wheels for cvxpy which use PEP 517 and cannot be installed directly
I have encountered below issue when installing the CVXPY, I have also downloaded the lasted version of visual studio but seems not working either.
> C:\Anaconda3\lib\site-packages\numpy\distutils\system_info.py:1730:
> UserWarning:
…

Richard
- 41
- 1
- 3
2
votes
0 answers
Numeric issues during ellipsoid fitting using with SCS to perform SDPs?
I've attempted to implement the Calafiore (2002) method of fitting ellipsoids to data using CVXPY as a wrapper to SCS to perform the semi-definite programming.
When I run this implementation, I get decent agreement with the first ellipsoid of…

Richard
- 56,349
- 34
- 180
- 251