Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
18 views

Portfolio quantity optimization violates DCP rules in CVXPY

I need to estimate the optimal quantity of individual stocks in a portfolio based on the daily net value fluctuations of the portfolio (known), where some of the stock quantity are known (...
Fitz_Hoo's user avatar
  • 591
0 votes
0 answers
40 views

Different solution using scikit-learn and cvxpy

I am trying to code a logistic regression model using the CVXPY library. The code I have written so far "works" in the sense that it can be executed, it does not yield any error message and ...
Álvaro Méndez Civieta's user avatar
0 votes
0 answers
113 views

cvxpy diagonal matrix as variable

Given some constraints (useless for this question), I want to minimize -log(det(M)) for some diagonal n x n matrix M. Usually, we do this for symmetric matrices, so that M = cvxpy.Variable((n, n), ...
Nicolas's user avatar
  • 65
0 votes
0 answers
21 views

Using proxsuite within CVXPY

I have just installed "proxsuite" package for optimization purposes. In the main page of the package, it is stated that this is already incorporated in CVXPY. However, I am not able to call ...
user25768957's user avatar
0 votes
0 answers
44 views

How to Implement Conditional Statements within an Objective Function in CVXPY

I want to clarify that this is a follow-up question to one where we resolved an issue I was having with the max atomic function in CVXPY (Convex Function in CVXPy does not appear to be producing the ...
Luis Enriquez-Contreras's user avatar
2 votes
1 answer
61 views

Convex Function in CVXPy does not appear to be producing the optimal solution for a battery in an electircal system

I am working on optimizing a battery system(1 MWh) that, in conjunction with solar power(200 kW nameplate capacity), aims to reduce electricity costs for a commercial building. For those unfamiliar ...
Luis Enriquez-Contreras's user avatar
0 votes
1 answer
63 views

How to express a variable vector to the constant vector in cvxpy?

I want to express X^C in cvxpy where X is a convex expression as a vector and C is constant vector. How should I write this using cvxpy? I tried cp.power(X,C) but in this function C should be a scalar....
Mahdi Hosseini's user avatar
0 votes
0 answers
48 views

CVXPY DCP error for cp.outer with two decision variables

I'm trying to solve the problem of finding an optimal choice of parallelization algorithm for each operator (v) in a Machine Learning computation graph, where each algorithm has an associated compute ...
Pedro Gimenes's user avatar
0 votes
0 answers
28 views

DCP Error when using CVXPY instead of scipy

I don't know how to solve the following using cvxpy instead of scipy fsolve. Please help! delta_E = { 1: 13.552999999999999, 2: 6.087000000000002, 3: 35.187000000000005, 4: 27....
cvpp's user avatar
  • 45
0 votes
0 answers
24 views

Trouble computing gradient of constraint function in PyTorch for SQUAT adversarial attack algorithm implementation

I am implementing the SQUAT algorithm from a research paper on adversarial attacks using Sequential Quadratic Programming (SQP) with the CVXPY library.. My current task involves calculating the ...
BernMan's user avatar
0 votes
0 answers
76 views

how to calculate mean of positive elements with cvxpy

I want to calculate the mean of positive elements as a constraint like mean of (3,5,-1) is 4 I tried x = cp.variable(3) constraints = [ cp.mean(cp.pos(x)) 《 3 ] but it contains zero,how to exclude ...
Ayame Ikuta's user avatar
0 votes
1 answer
55 views

Optimization problem: cvxpy returns that the problem is not DPP

I am writing a convex optimization problem with cvxpy, but it returns that the problem is not DPP even though it is. import cvxpy as cp import numpy as np from cvxpylayers.tensorflow import CvxpyLayer ...
evrihikri's user avatar
0 votes
0 answers
48 views

How to model log(e^x/(e^y+c)) in cvxpy with respect to DCP rules?

I have this objective function. Maximize log(e^X/(e^Y+c)) where X and Y are positive Variable vector and c is a constant. CVXPY says it does not follow DCP rules. The following is my code. P_D = cp....
Mahdi Hosseini's user avatar
0 votes
0 answers
44 views

Reformulation of SOCP constraints for convex optimization problem

I am doing a convex optimization problem related to reactive power management on a network. When trying to compile my problem on CVXPY, I have a problem with two constraints which do not comply with ...
bens44's user avatar
  • 1
1 vote
1 answer
38 views

How to represent X^2/Y (X and Y are matrices) in cvxpy respecting DCP rules?

I have a convex problem for maximizing -X^2/Y in cvxpy, where X and Y are matrices. I know that quad_over_lin is not elementwise. How can I write it in a acceptable way for cvxpy? I used loops and ...
Mahdi Hosseini's user avatar
0 votes
0 answers
46 views

Why does CVXPY determine $maximize -\frac{x^2}{y}$ as an objective function thas does not follow DCP rules?

I am solving a convex problem using CVXPY. The following is my written code. import cvxpy as cp # Define variables x = cp.Variable(nonneg = True) y = cp.Variable(nonneg = True) # Define the ...
Mahdi Hosseini's user avatar
1 vote
0 answers
50 views

Optimization Issues in Convex Function with scipy.optimize and cvxpy

I'm encountering challenges while simulating an algorithm. I'm working to optimize a convex function (theoretically convex since it originates from -2log(p(X; Y)), relating to a Maximum Likelihood ...
skye W's user avatar
  • 11
0 votes
1 answer
29 views

Why is the below code not working? It is giving dcp error

np.random.seed(0) weights = np.random.normal(0, 1, size=(6, 8)) weights[weights<0] = 0 weights_self = np.random.normal(0, 1, size=(6, 6)) weights_self[weights_self<0] = 0 fixed_x = np.random....
Soham Gosavi's user avatar
0 votes
0 answers
28 views

Quadratic Portfolio Optimisation with one weight fixed

I want to maximise the expected return of a portfolio of securities, subject to a maximum level of risk. The following code does this. I would now like to fix the first security weight to be something ...
GlaceCelery's user avatar
  • 1,023
0 votes
0 answers
21 views

How to ignore SolverError in cvxpy?

I have an optimization problem with random inputs. When I solve the problem using cvxpy with cvxpy.MOSEK, I got on some random inputs the optimal solution and on some other inputs the SolverError ...
zdm's user avatar
  • 521
0 votes
0 answers
25 views

cvxpy - cp.Minimize giving no answer

I'm trying to get the expected returns that satisfies a set of known weights, asset covariance, a set of weight limits and an estimated risk aversion. I'm using cp.Minimize to solve the problem. But ...
Farrep7's user avatar
  • 43
0 votes
2 answers
44 views

Running `cc --version` gave "[Errno 13] Permission denied: 'cc'" when trying to pip install pyportfolio opt in a docker build using airflow base image

I am creating a apache airflow app which requires the use of python packages pyportfolioopt or cvxpy. In the dockerfile i am currently using apache/airflow:2.8.4 as the base image. When i run docker-...
ryantan's user avatar
  • 115
0 votes
0 answers
65 views

my code with cvxpy.Variable is not work,and the error say "Invalid dimensions (5,) for Variable value."

my code is : import cvxpy as cp # 创建整数变量 x,取值范围为 {1, 2, 3, 4, 5} x_values = [1, 2, 3, 4, 5] x = cp.Variable(integer=True, value=x_values) # 构建目标函数和约束条件(示例:最小化 x 的和) objective = cp.Minimize(cp.sum(x))...
xiyang's user avatar
  • 1
1 vote
0 answers
24 views

CVXOPT fails to solve LP with CVXPY

I am trying to solve a very simple LP with cvxpy and cvxopt. Here is the code for the model: import cvxpy as cp import numpy as np n = 2 x = cp.Variable(n) prob = cp.Problem(cp.Maximize(cp.sum(x)), [...
asfiwefewrno's user avatar
0 votes
0 answers
46 views

cvxpy Python MPC controller - update reference variable xref based on manipulated variable u at each predictive time step

for t in range(horizon_length): # Here, xref[:, t] needs to be calculated from u[:, t].value cost += cvxpy.quad_form(x[:, t] - xref[:, t], Q) cost += cvxpy.quad_form(u[:, t], R) ...
Drizzle's user avatar
  • 105
0 votes
0 answers
25 views

Problem does not follow DCP rules, even though it is convex

I pinpointed with one of lines leading to “Problem does not follow DCP rules”. obj_constraints += [cp.reshape(cp.transpose(C_i)@LagrangeZ[i], (3numNodes,1)) == cp.transpose([email protected](lot@v0) + tau ...
Xu Siyuan's user avatar
0 votes
0 answers
40 views

CVXPY : Minimising with parameter set to 0 and minimising without parameter gives different answers

When trying to minimise an objective through CVXPY, I have two different optimisation problems. When a parameter alpha is set to 0, both these objectives should give the same minimisation results. But ...
Adithya Moorthy's user avatar
1 vote
1 answer
102 views

Write quadratic fractional program in CVXPY

I am trying the write the following quasiconvex function in CVXPY, which I eventually want to minimize. # Import packages import cvxpy as cp import numpy as np # parameters A1 = np.matrix([[2,1],[1,3]...
Nick's user avatar
  • 21
0 votes
0 answers
45 views

Can't find solutions with lower bound in constraints using cvxpy

My optimization problem is to minimize risk but risk has to be lower than 0.2. It seems whenever I add the lower bound into the constraints, it would show error like below. Are there ways to get ...
Warrior's user avatar
  • 223
0 votes
0 answers
65 views

CVXPY DCPError: Problem does not follow DCP rules. Specifically: The objective is not DCP. Its following subexpressions are not

I am trying to create an optimization problem using CVXPY with a variable number of summed expressions. Unfortunately, it keeps erroring out and saying that I am not following DCP rules. From my ...
taystew0927's user avatar
0 votes
1 answer
70 views

CVXPY returning `Strict inequalities are not allowed.` with no strict inequalities

I've got a script import cvxpy x, y = cvxpy.Variable(), cvxpy.Variable() prob = cvxpy.Problem(cvxpy.Minimize( cvxpy.norm2(1, cvxpy.quad_over_lin(x, cvxpy.sqrt(y))) ), [y >= 0]) print(...
Pavel Komarov's user avatar
0 votes
1 answer
144 views

Minimizing 3x + x*e^(1/x) such that 1<= x <=10 using cvxpy

I am trying to solve the following problem using CVXPY import cvxpy as cp x = cp.Variable(nonneg=True) from cvxpy.atoms.elementwise.power import power objective = cp.Minimize(3*x + x*cp.exp(cp.inv_pos(...
a23.ws's user avatar
  • 1
0 votes
0 answers
164 views

Migrating from CVXPY directly to Solver or How to Make CVXPY run faster

I am trying to solve a convex optimization problem very quickly with python. My problem looks like this: with p, m, z and o being arrays of values. Z being the one to solve for. and both p and z ...
SSC Fan's user avatar
  • 135
0 votes
0 answers
93 views

Mixed Integer Optimisation Using cvxpy

I'm trying to solve an optimisation problem in python using CVXPY. Specifically, I am trying to optimise two available resources based on some data. Below is a toy example of the problem I am having. ...
speeder1987's user avatar
0 votes
1 answer
94 views

How to make the operation != in cvxpy?

I am currently working on cvxpy and I have the following constraint: constraints.append(z[p][offices.index(office), offices.index(linked_office)] != 3/M) I need each value of z to belong to [0,3/M[ ...
Ethan07's user avatar
0 votes
0 answers
27 views

How to Compose Geometric Mean in cvxpy

I want to write x + z <= sqrt(y(x - z**2/y)) using geo_mean and quad_over_lin from cvxpy, but I see that geo_mean takes in a vector. I'm trying something like [x + z <= cp.geo_mean(np.array([y, ...
Lowell H.'s user avatar
0 votes
1 answer
91 views

why we can't use large bound as replacement for infinity in mosek?

Here in the documentation (https://docs.mosek.com/latest/pythonfusion/debugging-numerical.html) we see: Never use a very large number as replacement for infinity . Instead define the variable or ...
Taylor Fang's user avatar
0 votes
0 answers
69 views

Call cvxpy Python library on Android

I need to call python function in Android Studio. I have tried Chaquopy and run simple program successfully. However my Python program need to import cvxpy library and it fails to import cvxpy ...
yolopoi's user avatar
  • 49
0 votes
0 answers
46 views

cvxpy Repeatedly solving a problem get the “”Problem is unbounded“”

I used CVXPY to solve a planning problem, which requires running the same problem multiple times with inputting different parameters. enter image description hereI obtained the result in the form of ...
Jjhao's user avatar
  • 1
0 votes
0 answers
110 views

General questions on gradients in CVXPY

I have some general questions on gradients in CVXPY for simple convex optimization problems and gradients. In the code below, I have enabled automatic differentiation through the optimization, but ...
Alex's user avatar
  • 65
0 votes
0 answers
258 views

Solve MINLP with SCIP

I'm using CVXPY with solver SCIP to solve mixed integer nonlinear programming problems (MINLPs). I have a problem with a constraint that contains log function. It means that if I comment that ...
uv_utna's user avatar
  • 63
0 votes
0 answers
77 views

CVXPY Not Recognizing Obviously Convex Objective

I currently have a cost function that I'm minimizing, cvxpy.norm(A@x+B@u1+G - y1)+cvxpy.norm(A@(A@x+B@u1+G) + B@u2 + G - y2), with A a Variable matrix, and everything else a Parameter object (vector ...
Davis Last's user avatar
0 votes
0 answers
94 views

Optimal Innacurate in solving Quadratic Program with CVXPY

In am implementing an MPC controller and for solving the QP I am using CVXPY. I have the issue that the feasibility of the problem depends on the cost function (this has no theoretical support) and ...
Giulia Cutini's user avatar
0 votes
0 answers
78 views

DCP Rule Error in the Optimization Problem

I have an optimization problem where the following constraint causes "DCP Rule Error". Assuming that rho_n and x_n are among the decision variables and B is constant. Is this constraint ...
Mojtaba's user avatar
  • 21
0 votes
0 answers
216 views

How to implement non-zero count constraint for cvxpy in integer programming

I want to implement the constraint that the number of non-zero elements per row in x is less than 2. constraint2 = cp.sum( x >= 0, 1) <= 2 but get the error TypeError: float() argument must be ...
ChaoII's user avatar
  • 1
0 votes
0 answers
147 views

SVM implementation problem with CVXPY: Persistent errors with RBF kernel and linear kernel

I'm working on an SVM (Support Vector Machine) implementation using CVXPY in Python. Unfortunately, I'm having persistent problems with both the RBF kernel and the linear kernel. I define the ...
fallou0202's user avatar
0 votes
1 answer
117 views

How to change problem parameter in cvxpy without recompiling?

I have a SDP problem that takes a couple MOSEK solver seconds to run but a couple minutes to compile in cvxpy. I hope to be able to change parameters and solve again without having to recompile, and ...
That Frank Guy's user avatar
1 vote
2 answers
242 views

Solving non-convex optimization problem using python

I need to maximize a two-variable non-convex function, which contains a log to the base 2. I tried CVXPY but an error appears: cvxpy.error.DCPError: Problem does not follow DCP rules. The function is ...
learning statistics 's user avatar
0 votes
0 answers
60 views

why does summing in cvxpy will occur broadcasting error

I having a problem of value error with my code. It keeps showing cannot broadcast dimensions (5,)(5,3). I am still learning how to use cvxpy so I cannot find the way to solve it. The problem is at &...
user1155920's user avatar
0 votes
0 answers
68 views

Optimizing a diagonal elements of a matrix using cvxpy

If I have a diagonal matrix, its main diagonal elements are e**(1jx) where x is the optimizable variable between 0 and 2pi, something like this: Matrix_of_X = np.diag(e**(1j*x)) How to use the CVX ...
learning statistics 's user avatar

1
2 3 4 5
13