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
How to warm start with cvxpy using solver SCS
According to the documentation of cvxpy, http://www.cvxpy.org/en/latest/tutorial/advanced/ there should be a way to warm_start SCS solver using cvxpy. (by the way if anyone knows how warm_start can be done using mosek in cvxpy, that would be…

user2015487
- 2,075
- 3
- 17
- 20
0
votes
0 answers
Unable to run exe file of a CVXPy code compiled by Pyinstaller
I've wrote a simple code that solves optimization problem using the CVXPy library.
from cvxpy import Variable, Minimize, Problem, abs
c = [20, 20, 50]
k = [-0.25, -0.15, -0.25, -0.35, -0.15, -0.25]
xbr_1, xbr_2 = Variable(1), Variable(1)
mra_1,…

Premysl Vorac
- 473
- 6
- 16
0
votes
1 answer
Entropy maximization unbounded/infeasible using CVXPY
I am attempting to solve an entropy maximization problem numerically using CVXPY. Even though the problem passes the DCP checks, I keep getting an infinite result, and problem statuses like infeasible and unbounded_inaccurate (depending on the…

ErnChe
- 1
- 3
0
votes
1 answer
Maximise the Slope using CVXPY
I'm trying to use CVXPY to maximise the Sharpe Ratio of a stock portfolio.
The variable w is a portfolio weight vector, Sigma is an nxn correlation matrix, mu - is the average return of each portfolio stock, and rf - the risk-free rate (a scalar…

maria saz
- 191
- 1
- 10
0
votes
1 answer
Dynamically generate list of constraints in CVXPY
I am working on a minimum variance optimisation problem in Python using CVXPY that takes in constraints in the form of
constraints = [
sum_entries(w) == 1,
w[0:5] >0.05,
w[1] > 0.05,
…

ThatQuantDude
- 759
- 1
- 9
- 26
0
votes
1 answer
Python/Installing cvxpy package error - setup.py egg_info with error code 1
I'm trying to install cvxpy on my Mac through pip and through PyCharm and I'm getting the following error: "Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-azdpOA/CVXcanon/". Would anyone know what's that and…

aabujamra
- 4,494
- 13
- 51
- 101
0
votes
1 answer
Convert a semidefinite program from CVX to CVXPY
I want to convert the following SDP — which just verifies the feasibility of the constraints — from CVX (MATLAB) to CVXPY (Python):
Ah = [1.0058, -0.0058; 1, 0];
Bh = [-1; 0];
Ch = [1.0058, -0.0058; -0.9829, 0.0056];
Dh = [-1; 1];
M = [0, 1;1,…

Huayu Zhang
- 207
- 4
- 11
0
votes
3 answers
Python: How do i find an equation's value for a given input
Say, I have an equation f(x) = x**2 + 1, I need to find the value of f(2).
Easiest way is to create a function, accept a parameter and return the value.
But the problem is, f(x) is created dynamically and so, a function cannot be written beforehand…

Sanjay
- 111
- 1
- 9
0
votes
1 answer
CVXPY constraint with N variables
Trying to figure out a way to write a constraint with N variable to use on CVXPY that fit this:
var1 + var2 + ... + varN = K # K is a constant
All variables objects are instantiated and are stored in a list.
[Variable, Variable, ...]

gerosalesc
- 2,983
- 3
- 27
- 46
0
votes
1 answer
Element wise multiplication in CVXPY
I have the following code snippet for CVXPY:
delta=1e-3
loglambda = rvec*theta #rvec: TxJ regressor matrix, theta: (Jx1) cvx variable
a= mul_elemwise(dy[0:T],loglambda) # size(Tx1)
b1=cvx.exp(loglambda)
b2=mul_elemwise(delta,b1)
cost= -a + b1 …

Msin
- 63
- 2
- 7
-1
votes
1 answer
constraint of cvxpy: the sum of the min of X and its upper_bound bigger than a const
I want to assign weight to ten different industries to construct a portfolio. But there is a constrain that at least 80% of the industry should come from an index, called ZZ800 index. The ind weights of ZZ800 index are known, for example, the A…

nan
- 401
- 4
- 13
-1
votes
1 answer
Can't install cvxpy in pycharm
So i tried to install cvxpy package in pycharm but the following error occurred:
Collecting ecos==2.0.7.post1
Using cached ecos-2.0.7.post1.tar.gz (126 kB)
Requirement already satisfied: numpy>=1.6 in d:\programmi…

Antonio Mastroianni
- 35
- 1
- 8
-1
votes
1 answer
optimization comparison between cvxpy and gurobi
There are number of jobs to be assigned to number of resources each with a score (performance indicator) and cost. The resource assignment problem (RAP) objective is to maximize assignment scores considering the budget. Constraints: Each resource…

Mohsen Ghanavati
- 1
- 3
-1
votes
1 answer
Extract numbers from CVXPY array
I'm working on an optimization problem using Python's CVXPY package. I created a CVXPY variable called x (an array of 10 values). I need to impose a constraint that the 2nd largest value in x is smaller than .03. I tried converting it to a NumPy…

cona
- 169
- 1
- 13
-1
votes
1 answer
CVXPY - passing both variables and constants
I'm trying to do the following (CVX matlab code):
variable x(2)
minimize(norm([x;1]) + 2*max([x;0])
But when I try to this in python CVXPY, I get an error:
x = Variable(2)
norm([x, 1])
TypeError: float() argument must be a string or a number,…

Maverick Meerkat
- 5,737
- 3
- 47
- 66