Skip to main content

Questions tagged [cvxpy]

CVXPY is a Python-embedded modeling language for convex optimization problems.

Filter by
Sorted by
Tagged with
0 votes
0 answers
62 views

Nuc norm and L2 norm for sdp problem

I have a question about using nuclear norm for rank minimisation. I have a SDP problem. f(X) is convex in nature and g(x) is linear. Now, I must apply rank minimisation and establish a relationship ...
Muhammad's user avatar
2 votes
1 answer
68 views

Penalize absolute value while keeping the problem DPP (CVXPY)

I am trying to implement the objective function max a . x + c . abs(x - g). where all elements of c are non-positive, ...
GabCaz's user avatar
  • 41
2 votes
1 answer
159 views

How to model the constraints of min and max in cvxpy

I have a continuous variable $x_{ij}\in[0,1]$ and I need to write the following constraint: $$M_i-m_i+1\leq C_i$$ where $M_i=\max\{j: x_{ij}>0\}$ and $m_i=\min\{j: x_{ij}>0\}$
zdm's user avatar
  • 403
1 vote
1 answer
121 views

Convex approximation of a constraint

I have a constraint given as $ \left|x_n+\beta x_{n+ 1}\right|-\varepsilon_{ky}\left|x_{n}\right|\leq0\hspace{1em}\forall n=1,2...,N $ I need to convert this into a convex form to implement in CVX. $...
Muhammad's user avatar
0 votes
1 answer
117 views

Convex approximation of an expression with fraction for CVX

I have the optimization problem $$\underset{\mathbf{x} \in \Bbb C^N}{\max} \left| \frac{\mathbf{x}a-b}{\mathbf{x}c+b} \right|^2$$ where $a$, $b$ and $c$ are some scalars. I want to solve this ...
Muhammad's user avatar
2 votes
1 answer
497 views

MOSEK via fusion vs API vs CVXPY

In Python, I would like to solve a collection of problems, that are all solvable via MOSEK's conic optimization solvers (ExpCone, SOCP, etc.) I have tried CVXPY. I get very robust and reliable results,...
independentvariable's user avatar
0 votes
1 answer
286 views

Convex approximation of an expression

I am trying to transform an expression given by $$ \operatorname{trace} \left( {\bf{X} } \right) + \left( \sum_{n=1}^N \mathcal{R}(x_n) \right) $$ into convex from where $\mathbf{x}$ is complex in ...
Muhammad's user avatar
5 votes
0 answers
571 views

How to write this objective in CVXPY for quasiconvex programming?

I have the following objective that I want to maximize: \begin{equation} \max_{U_T\in \mathbb{R}, x\in\mathbb{R}^T} J_\alpha(U_T) = \frac{\alpha}{\alpha-1}\log\left(\frac{\cosh(U_T)}{\cosh(\alpha U_T)^...
Uomond's user avatar
  • 86
2 votes
1 answer
313 views

Quadratic optimisation with $\ell_1$ constraints with CVXPY

Crossposted on Mathematics SE I seek to minimize a convex quadratic objective subject to linear and $\ell_1$-based equality constraints. When I turn to CVXPY, an error is raised indicating that it ...
jam123's user avatar
  • 21
1 vote
0 answers
127 views

Handling Variable Division in CVXPY for Calculating Annualized Rate of Change

I am working with a dataset that contains multiple entries for different IDs across various years. Some IDs might have a gap of years between entries. My goal is to solve an optimization problem using ...
user760900's user avatar
0 votes
1 answer
268 views

CVXPY stuck in Compilation step during solving linear program

I'm trying to solve a linear program with 869532 variables and 8869 constraints in CVXPY. The CVXPY gets stuck in the Compilation session right before passing the problem to the solver. Here's the ...
Mohammad Namakshenas's user avatar
1 vote
1 answer
102 views

How do I implement this convex problem in CVXPY?

I am looking to implement the following optimization problem in CVXPY. $$ \max _{x_t} x_t' \mu - \frac{\gamma}{2} x'_t \Sigma x_t - x'_t\Lambda \Delta x_t $$ where $\Delta x_t := x_t - x_{t-1}$ and $\...
Lydia's user avatar
  • 11
0 votes
1 answer
134 views

Simulating an integer quadratic knapsack problem

I am trying to simulate the following quadratic integer program using $\textsf{cvxpy}$: $$ \begin{array}{ll} \underset {x_1, \dots, x_K} {\text{minimize}} & \displaystyle\sum\limits_{i=1}^{K}\frac{...
UserX's user avatar
  • 103
0 votes
1 answer
185 views

Optimal blending of gasoline via LP

...
N_ote's user avatar
  • 11
2 votes
3 answers
301 views

How to represent the objective function of the Weapon Target Assignment problem in CVXPY?

I am trying to use CVXPY to analyse a problem and the objective function for this problem involves calculating a product and a sum as per the problem description below (taken from a draft paper I am ...
BRavos's user avatar
  • 29
2 votes
0 answers
78 views

How to rewrite a constraint with sum of convex and concave components to satisfy DCP rule?

suppose that decision variable is X with N dimensions, and one type of the constraint is ...
Allen Zhang's user avatar
5 votes
2 answers
544 views

Simple OLS problem can only be solved in SCS. Is the dual infeasible?

Essentially, I am trying to solve a simple orthogonal least-squares (OLS) problem with some constraints — the coefficients must sum to $1$, no coefficient can be less than $0$, and no coefficient can ...
Pipob Puthipiroj's user avatar
4 votes
3 answers
663 views

Determining the optimize lambda in Multi-Objective Optimization

I have a convex optimization problem: Maximize obj1 Minimize obj2 Some constraint Now to solve this problem, I used lambda to make it one problem: ...
Soroosh Noorzad's user avatar
1 vote
2 answers
234 views

Does the cvxpy replace the max function by MIP formulation under the hood?

Does the cvxpy replace the max function, which is convex, by MIP formulation under the hood when shows up in the constraints (for example, $\max(x,y)\le z$) or in the objective function? In gurobipy, ...
Hussein Sharadga's user avatar
3 votes
2 answers
1k views

Is solving a quadratic programming optimization problem using python slower than C++?

I am using the cvxpy library in python to solve a quadratic programming problem and the solver used is scip. I found that when the amount of data becomes large, the solution process will be ...
happy's user avatar
  • 63
2 votes
1 answer
497 views

MIQP — CVXPY unable to treat summation of variables as a variable

I have a quadratic integer programming assignment problem. The goal is to assign riders seats on a bus such that distance between any two riders is maximized; however, the importance of each objective ...
jbuddy_13's user avatar
  • 559
3 votes
1 answer
67 views

Is not the substitution method supposed to reduce the computation cost?

Is the substitution method expected to reduce the computation cost? We know it will reduce the number of variables and constraints. I mean by substitution method is to eliminate the equality ...
Hussein Sharadga's user avatar
1 vote
2 answers
381 views

How to solve this mixed integer quadratic program using cvxpy or other method?

My problem is described in this picture: $$ \begin{array}{l} \left\{\begin{array}{l} \text { objective function: } \\ f = \min \sum_\limits{l=1}^2 \sum_\limits{i=0}^{2^l-1} \sum_\limits{j=0}^{2^l-2}\...
happy's user avatar
  • 63
3 votes
0 answers
167 views

Does Gurobipy exploits sparsity of the optimization problem?

What happens when a (sparse) csr matrix / array is submitted to Gurobi (via Cvxpy framework in python). Does it exploit the sparsity Information about the matrix or ...
pqrz's user avatar
  • 470
4 votes
1 answer
238 views

Geometric Programming with Simple Affine Equality Constraint

Consider a Geometric Program (GP), $$ \begin{array}{cl} \operatorname{minimize} & f_{0}(x) \\ \text { subject to } & f_{i}(x) \leq 1, \quad i=1, \ldots, m, \\ & g_{i}(x)=1, \quad i=1, \...
Apprentice's user avatar
5 votes
1 answer
237 views

Constraints like "max(column a + column b) == 2" are not DCP

I am struggling with the following constraint on a minimization problem cvx.max(z[:, i] + z[:, j]) == 2 where z is a Boolean ...
Brannon's user avatar
  • 970
8 votes
1 answer
420 views

Translate LP format to Numpy matrices

We have a large-scale optimization problem (~10K vars and ~10K constraints) in the form of LP format file (generated using Cplex ...
pqrz's user avatar
  • 470
3 votes
1 answer
547 views

Adding CVXPY abs to optimization problem turns out to be non-DCP

I have tried to solve an optimization problem using CVXPY library. This problem aims to minimize the distance between a vector of $n$ variables ($\beta$), which can be positive or negative real ...
Sasin's user avatar
  • 39
1 vote
1 answer
88 views

Convex Optimization with Variable Dependency / no unmet demand carry forward

I'm running into an issue with a Linear Optimization Problem. The ultimate goal is to come back with an optimal production quantity (prod_qty) across several items ...
Piranha's user avatar
  • 11
4 votes
1 answer
167 views

DCP formulation of sum of nonconvex and convex functions

I am trying to find a DCP formulation for the following convex objective function (using CVXPY): Let $x$ be the $N$-dimensional vector variable on which we optimize on, $c$ be a known scalar value ...
LowOdds's user avatar
  • 41
2 votes
1 answer
168 views

Constraint raises DCP Error

I have defined a problem which will minimize the cost of to run a pump. That is defined as the objective of the problem. ...
Aidan Donnelly's user avatar
5 votes
1 answer
466 views

Practical open source LP solvers for large linear programming problem with $10^7$ parameters

I have an LP problem of the form $\min\ c^Tx$ subject to $Ax\leq b$ where $x$ consists of 30 million parameters and $A$ is a very very sparse matrix of size 30M by 30M (with only 3 ones per row). I ...
vkmv's user avatar
  • 151
1 vote
0 answers
175 views

Optimization Multiple Constraints

I am trying to solve a linear algebra problem: an optimization problem and I am using CVXOPT. I've split the problem into 3 components In its simplest form, The general formulation for CVXOPT is \...
Marco_sbt's user avatar
  • 173
1 vote
0 answers
428 views

Minimum trade size in CVXPY

I'm trying to replicate some of the suggestions of this paper. On page 40-41, it's made the following suggestion when it comes to enforcing a minimum trade size: In this context, ...
stevew's user avatar
  • 119
2 votes
1 answer
2k views

Impose binary constraint on integer matrix with CVXPY

So I have the following matrix: \begin{equation} P_{i,j}= \begin{bmatrix} x_0 & x_1 & x_2 \\ y_0 & y_1 & y_2 \\ z_0 & z_1 & z_2 \end{bmatrix} \end{equation} where ...
Johnny's user avatar
  • 293
2 votes
1 answer
249 views

Matrix Singularity Constraint

I'm using CVXPY. Given a $2\times2$ matrix $A$, is it possible to add a singularity constraint? Anything equivalent to: $|A| = 0$: The determinant is $0$ $\operatorname{rank}(A) \leq 1$ Smallest ...
Adi Shavit's user avatar
6 votes
2 answers
431 views

Directly calling gurobipy API causes substantially longer runtime than calling cvxpy

Background I am trying to implement the reranking algorithm proposed in the paper (Eqn 3). The algorithm is cast into an integer linear program which is trying to find permutation matrix $\mathbf{X} \...
Mr.Robot's user avatar
  • 171
7 votes
1 answer
461 views

Maximizing a Ratio/Percent

I'm using cvxpy to model a problem. Inside a very large and complex LP, I create two continuous, affine (unconstrained) expressions: $x$ and $y$. Due to how they ...
Adi Shavit's user avatar
3 votes
1 answer
523 views

Portfolio optimization with indicator function constraint in CVXPY

I have the following portfolio optimization problem that I want to solve using CVXPY: \begin{align}\min_w&\quad w^\top\Pi\\\text{s.t.}&\quad\sum_{i=1}^nw_i=1\\&\quad w^\top\Sigma w\le\...
Paolo Baudissone's user avatar
2 votes
1 answer
1k views

Mixed integer quadratic programming (MIQP) in CVXPY

There's something I don't understand about CVXPY's example on its MIQP use. It says that the algorithm returns a solution $x \in \mathbb{Z}^n$ but I thought in general the point of MIQP algorithms was ...
FredNgu's user avatar
  • 157
4 votes
1 answer
235 views

Make Optimization term fit into DCP rules

I want to make a term in an objective function I am working with fit into DCP for CVXPY. I am working on replicating this research paper for an active learning problem. Specifically equations 5 is ...
Lukas Dauterman's user avatar
4 votes
0 answers
2k views

cvxpy: Code that works for default solver doesn't work for cp.GLPK_MI

The following code works: ...
Rohit Pandey's user avatar