CVXPY is a Python-embedded modeling language for convex optimization problems inspired by the MATLAB package CVX.
Questions tagged [cvxpy]
609 questions
0
votes
0 answers
Least squares problem run out of memory in CVXPY
I've posted this in the Google Group but hoping for a faster response here. I have a simple least squares problem with a lot of observations. The vector has 200,000 observations but I'd expect cvxpy simply square each element and sum them.
import…

swmfg
- 1,279
- 1
- 10
- 18
0
votes
1 answer
CVXPY exponent atom using Mosek
below is a snippet of code from my program.
import CVXPY as cp
X = cp.Variable(shape=(10,4), boolean = True)
y = cp.exp(X[0,1])
objective = cp.Minimize(cp.sum(X))
constraint = [y <= 0]
prob = cp.Problem(objective, constraints)
result =…

P. Khoza
- 21
- 4
0
votes
1 answer
CVXPY function to restrict sum of integer variables to be 1 at max in a constraint
I need some way to cap the sum of integer variables to be 1 at max in a python cvxpy optimization task constraint.
What i do not want is to force the sum of the variables to be 1, I just need a function to cap the result of sum(x) to be 1 at max to…

Vlad de Elstyr
- 83
- 1
- 2
- 6
0
votes
0 answers
How can I solve problems iteratively in CVXPY?
I want to solve a problem, then use that problem's variables in another problem's constraints, solve it, use the second problem's variables in a third problem's constraints, and so on until the distance between the nth and the (n-1)-th variables is…
0
votes
0 answers
Optimization with grouping function
I have an optimization problem with the dat frame as below:
Loc Lattitude Longtitude Car Distance
1 34.30 -36.30 A 23
2 36.06 -67.32 B 32
3 41.35 -22.04 C 12
4 30.49 -14.25 A 41
5 …

Grace
- 75
- 11
0
votes
0 answers
Why is CVXPy or DMCP returning a "NoneType" when simple constraints are added?
I recently ran into an interesting package/paper called dmcp (disciplined multi-convex programming). You can find a link to the repo here and a link to the paper here.
I wanted to use this to solve for equilibria in a model I have been studying in…

Dupin
- 1
- 2
0
votes
0 answers
Solvers in CVXPy seem to be sensitive to initial conditions, imprecise, or incompatible
I've recently implemented a convex program from my research in CVXPy and I'm not reliably getting good answers. By this I mean that when I use:
ECOS sometimes I get an answer and other times I get "Unreliable search direction detected, recovering…

Dupin
- 1
- 2
0
votes
1 answer
cvxpy .solve() with solver OSQP fails with 'maximum iterations reached' error on tutorial code
I'm attempting to use cvxpy. I have installed version 1.1.0a1 into my conda environment using pip and cloned the cvxpy github repository. When trying to run their SVM-example jupyter notebook, prob.solve() throws the following error…

Christina
- 1
- 1
- 1
0
votes
0 answers
How to set Hermitian and positive semidefinite constraints in CVXPY?
I am new to CVXPY due to my recent project. I need to use maximum likelihood method in python. The matrix I want to tune is both hermitian and semidefinite (a density matrix in physics language). But I find that these two constrains cannot appear at…

Benjamin Jiang
- 11
- 2
0
votes
1 answer
Weights minimization issue with linprog
I am trying to use python (and at present failing) to come to a more efficient solution than Excel Solver provides for an optimization problem.
Matrices
The problem is the form AB=C -->D
Where AB produces C where the absolute value for C-D for each…

jcrick
- 33
- 7
0
votes
1 answer
CVXPY 1.0.24 in Python 3.+ isn't solving quad problem correctly
I am trying to maximize cx - xAx with A being positive definite, but solution is not what I it should be. Please help
I tried the problem using this data
A = np.array([[1595., 1098., 1133., 0., 0., 0., 0.],
[1191., 1497., 1133., …
0
votes
2 answers
using CVXPY under PyPy3
I'm trying to use CVXPY under pypy3.6-7.1.1. But I'm getting this error
def build_lin_op_tree(root_linPy, tmp):
"""
Breadth-first, pre-order traversal on the Python linOp tree
Parameters
-------------
…

Sylvain Chassang
- 3
- 2
0
votes
0 answers
CVXPY gives "AttributeError: 'numpy.bool_' object has no attribute 'variables' " error when I use predefined np array in constraints
I am trying to find an optimal solution on predefined np arrays and I need to use these arrays in constraints. I tried converting those arrays to cvxpy variables but it it says that cvxpy variables do not support assignment. Here is code for…
0
votes
0 answers
CVXPY: objective function to have solution equals to each other
I would like to have CVXPY solve a maximization problem where objective function is a summation over [0,i]. However, I want the same solution for all x[0,i]
I tried the code as displayed here but solution to x are not the same.
x = Variable(10)
g=…

Bryan Lwy
- 45
- 1
- 6
0
votes
1 answer
Defining the set of possible values that a variable can take
In CVXPY, how do I enforce the constraint that the value of a specific variable can take only a specific value from a given set of values?
eg: Value of the variable should be one out of the set P = [2, 4, 8, 9]

NandyGirl
- 33
- 4