CVXPY is a Python-embedded modeling language for convex optimization problems inspired by the MATLAB package CVX.
Questions tagged [cvxpy]
609 questions
0
votes
1 answer
cannot import cvxpy & cannot import name and SolvingChain
It seems there are problems in importing cvxpy. I have tried uninstalling and reinstalling but no difference. Before, it works but several times without changing anything it suddenly stopped to work and could not import cvxpy. Then, the problem has…

F E
- 1
0
votes
0 answers
Is it possible to implement the CVXPY library on a Raspberry pi 3?
I would like to implement a MPC controller on a RPI3, but my script uses CVXPY, and I have some trouble installing it. When I search the internet, I do not find anyone else who has done it, so now I am thinking it might not be possible to do it? can…

Kenneth Schmidt
- 55
- 5
0
votes
1 answer
Incremental Summation of Expressions in CVXPY
I need to incrementally build a CVXPY expression, e.g. a sum.
At the moment I'm using:
sum_expr = None
for ...
var = cp.Variable(...)
if sum_expr:
sum_expr += var
else:
sum_expr = var
# use sum_expr
Is there a cleaner, more…

Adi Shavit
- 16,743
- 5
- 67
- 137
0
votes
0 answers
Getting DCPError when trying to solve Dual form of SVM using CVXPY
I am trying to create a SVM using cvxpy, by solving its Dual form
Here is the code:
import cvxpy as cp
import numpy as np
DIM = 2
NUM = 50
#COLORS = ['red', 'blue']
M1 = np.ones((DIM,))
M2 = 2 * np.ones((DIM,))
C1 = np.diag(0.3 *…

Siladittya
- 1,156
- 2
- 13
- 41
0
votes
0 answers
Multiplying gurobi variable and np.array elementwise
I'm attempting to cast a CVXPY problem to Gurobi's Python API.
The CVXPY problem is the following (I'm ommitting previous variables definitions as they're secondary for my issue. Check comments for their types and shapes.):
import cvxpy as…

cab20
- 35
- 1
- 5
0
votes
0 answers
How to run MOSEK solver in CVXOPT
I have written a small code to do a simple min variance optimisation using CVXOPT, you can see the whole code below
By using solvers.qp(P, q, G, h, A, b) in CVXOPT the code runs fine and it find a solution
solvers.qp(P, q, G, h, A, b)
I wanted to…

Marco_sbt
- 309
- 1
- 12
0
votes
1 answer
Installing cvxpy on windows with anaconda: failed nosetests misrebally
Please explain what I should do slowly. I am trying to install cvxpy on my machine. I have installed python, visual studio build tools and tried in command prompt but I got errors when I tried to install. So I ditched that idea and installed…

seniordesign
- 1
- 3
0
votes
1 answer
Cannot install cvxpy with python 3.8
I have tried installing cvxpy (https://www.cvxpy.org/install/) for python. I use Python 3.8 for all my projects and am not to fond of making virtual environments where i use 3.7. Does anyone have a fix for using cvxpy on python 3.8 (I am using…

Bart
- 317
- 4
- 18
0
votes
1 answer
Constraints for Rotor Balancing Problem with CVXPY
I am a machinery engineer with minimum background on math. I was tempted to use CVXPY to write a simple code about rotor balancing problem. It was amazing how simple and robust it works. My problem was as follows:
After getting user input for a…

Maged Eltorkoman
- 67
- 1
- 7
0
votes
1 answer
Number of constraints in convex model
Why does a convex QCQP model written using cvxpy and solved using Mosek show more constraints than those defined in the model (As reported by Mosek)?
I notice the same even for cvxpy atom like square(x), where if x is a single variable and…

P. Khoza
- 21
- 4
0
votes
1 answer
Slow solving with ECOS_BB, CBC errors with "Not enough constraints"
I have an binary MIP optimization problem where I want to select the best candidates given a budget and constraints on some other attributes. For each candidate I have a sample vector of their possible utilities obtained from a separate bayesian…
0
votes
1 answer
Getting "Cannot multiply AFFINE and CONVEX" in cvxpy 0.4.10 but not 1.0.18
I'm working on two different environments which have different versions of cvxpy.
On 1.0.18, this works as expected:
import cvxpy as cp
print(cp.__version__)
X = cp.Parameter(name='X', shape=(10), nonneg=True)
Y =…

JPN
- 632
- 12
- 24
0
votes
1 answer
determining whether two convex hulls overlap
I'm trying to find an efficient algorithm for determining whether two convex hulls intersect or not. The hulls consist of data points in N-dimensional space, where N is 3 up to 10 or so. One elegant algorithm was suggested here using linprog from…

kevinafra
- 11
- 3
0
votes
2 answers
Portfolio Optimization with CVXPY constraint has DCP error
I am optimizing a portfolio where I maximize active return. I also have four constraints: the sum of weights must be equal to 1, all weights must be less than or equal to 0.05, all weights must be greater than or equal to 0.0005, and active risk…

Diego Uribe
- 13
- 1
- 6
0
votes
1 answer
Constraints not met while optimising using CVXPY
Used cp.Maximize functionality of CVXPY to maximise the sumproduct of weight and score. Added constraint that w cannot be greater than zero, but it failed.
import cvxpy as cp
score =…

Gautam Kakkar
- 21
- 7