CVXPY is a Python-embedded modeling language for convex optimization problems inspired by the MATLAB package CVX.
Questions tagged [cvxpy]
609 questions
1
vote
1 answer
Inconsistency in solutions using CVXPY
Please, consider the following optimisation problem. Specifically, x and b are (1,n) vectors, C is (n,n) symmetric matrix, k is an arbitrary constant and i is a (1,n) vector of ones.
Please, also consider the following equivalent optimisation…

Nipper
- 207
- 2
- 15
1
vote
1 answer
Modifying existing logger configuration of a python package
I am currently using cvxpy for my project. When I solve an optimization problem, I have the option to turn the verbose flag on using prob.solve(solver=cvx.CVXOPT, verbose=True). When I do that, the logger starts printing the DEBUG level log messages…

Omar Shehab
- 1,004
- 3
- 14
- 26
1
vote
0 answers
What is 'G' in CVXPY and how to fix it
I'm trying to use a binary integer linear program to assign members of my staff to different shift. I have a 16x9 matrix of preferences for my staff in a csv (16 staff members, 9 slots to fill) and I used the following code to try and assign…

Nakul Upadhya
- 494
- 4
- 16
1
vote
1 answer
Strict Positive Definite Matrix in cvxpy python
I am trying to apply cvxpy python to solve an LMI
How can I define a strictly positive definite matrix here?
For about a matrix of order 10 for example this is the syntax
X = cp.Variable((100, 100), PSD=True)
but it is for X when X>=0
I need X>0.
I…
user16570268
1
vote
1 answer
CVXPY error when trying to solve a convex minimization / binary programming problem
I'm trying to solve a problem that I submitted to QSE, https://quant.stackexchange.com/questions/65680/find-k-of-n-assets-that-minimize-the-correlation-matrix/, but I'm running into an issue using the cvxpy lib. Namely, what I believe to be a…

geofflittle
- 437
- 1
- 3
- 14
1
vote
0 answers
numpy.ndarray to CVXPY variable
I have defined a random 2x2 matrix
import cvxpy as cp
import numpy as np
np.random.seed(1)
A = np.random.randn(2, 2)
type(A)
numpy.ndarray
This is of type numpy.ndarray and I want to use this variable within cvxpy to ask for it to become a…

Marion
- 271
- 3
- 11
1
vote
0 answers
How to place constraints on subsets of an array dynamically in cvxpy?
I have a decision variable that consists of a matrix of power usage for an energy facility. Each column in the matrix corresponds to different energy drains (for example light bulbs or heating), with every row being the energy usage at a time step…

ROHAN DATTA
- 11
- 2
1
vote
0 answers
Why is np.linalg.norm producing an error here?
I am trying to solve the classical Least Squares Problem using cvxpy, but I am getting an error due to np.linalg.norm. Any help would be immensely appreciated.
My code is below. As it is, it works. However, if I change cp.sum_squares to…

user56202
- 299
- 1
- 9
1
vote
1 answer
CVXPY: How to maximize dot product of two vectors
Suppose we have three features and 252 samples per each feature. Here, features are returns of three different stocks. The goal is to maximize the total return, i,e,
My question is how to define this objective function inside a CVXpy optimization…

sci9
- 700
- 1
- 7
- 21
1
vote
1 answer
Absolute value function not recognized as Disciplined Convex Program (CVXPY)
I am trying to run the following optimization using CVXPY:
import cvxpy as cp
import numpy as np
weights_vec = cp.Variable(10)
er_vec = cp.Parameter(10, value=np.random.randn(10))
prev_h_vec = cp.Parameter(10, value=np.ones(10))
tcost_vec =…
1
vote
1 answer
Is Julia.JuMP 15x slower then Python.Cvxpy?
I was trying to solve a simple optimization problem, first via Python.Cvxpy framework and then via Julia.JuMP framework, but Julia.JuMP formulation is 15x slower.
My optimization problem:
In Python.Cvxpy: (runtime: 4 sec)
# Run: time python…

pqrz
- 133
- 5
1
vote
0 answers
Version conflict between cvxpy and numpy: "module compiled against API version 0xe but this version of numpy is 0xd"
I'm trying to upgrade some packages and to consolidate my requirements.txt for an existing python program in order to move it to a docker container.
This container will be based on the tensorflow docker container, this dictates some package versions…

dfust
- 55
- 4
1
vote
0 answers
Why is cvxpy (solver=GLPK_MI) so slow on this knapsack problem?
I'm trying to use cvxpy to solve a knapsack problem with varying available quantities of items, and seeing it run much slower with some quantities than others.
(My objective here is to minimize wasted capacity, so values=weights.)
import cvxpy as…

Jeremy Sadler
- 55
- 4
1
vote
2 answers
CVXPY constraints formulation
I am trying to solve the Isoperimetric problem (7.14) from Additional Exercises for Convex Optimization by Stephen Boyd using CVXPY. The problem formulation is:
The code of constraints is given below:
constraints = [ y[1] == 0,
y[N]…

cst
- 125
- 1
- 7
1
vote
1 answer
Integer problem is unbounded, but its linear relaxation not in CVXPY
Dears,
I´m experimenting on CVXPY and have generated a simple Integer Program. For the sake of comparisson I´ve also generated a linear relaxation of it. But, when solving, I get a value for the relaxed problem (1.429). For the integer problem,…

Bruno
- 87
- 5