Questions tagged [cvxpy]

CVXPY is a Python-embedded modeling language for convex optimization problems inspired by the MATLAB package CVX.

609 questions
2
votes
1 answer

Any Differences in `cvxpy` Library Between L2 Norm and `sum_of_square()`?

I am trying to use cvxpy lib to solve a very simple least square problem. But I found that cvxpy gave me very different results when I use sum_squares and norm(x,2) as loss functions. The same happens when I try the l1 norm and sum of absolute…
skinfaxi
  • 21
  • 3
2
votes
1 answer

Mosek solver failing when constraints added to optimisation problem (10000 variable, using Python/cvxpy)

In short The optimisation problem below is declared infeasible when run with Mosek, but is solvable (easily and accurately) using the open-source solver ECOS. I'm wondering: why is such an advanced commercial solver like Mosek failing to solve this…
Gareth Williams
  • 242
  • 4
  • 10
2
votes
1 answer

CVXPY Square root of Singular Quadratic

I need to model sqrt(x^T C x) for a singular positive semidefinite matrix C. Here, it is proposed to use norm(Q*x) where Q is obtained from the Cholesky decomposition of C. How to take the square root of quad_form output in CVXPY? But,…
Behrooz Ns
  • 63
  • 5
2
votes
1 answer

How to install CVXPY / SCS to use with GPU?

All the dependencies are installed in a docker container, but when I run the example with GPU=True it returns "Status: Unbounded" and with GPU=False it works ok. The scs-python GPU tests return "Status: Unbounded". Also, nvidia-smi displays GPU…
Cerebrock
  • 122
  • 11
2
votes
1 answer

How to set a semi-positive Parameter(matrix) in CVXPY?

I want to use warm start to check whether there's performance benefit by setting a cvx.Parameter, while I come accross this: cvxpy.error.DCPError: Problem does not follow DCP rules. My code is here: import time import numpy as np import cvxpy as…
Naive
  • 475
  • 1
  • 6
  • 14
2
votes
0 answers

CVXPY error: "NotImplementedError: Strict inequalities are not allowed"

def PPNM_model(a,E, beta): p = E.shape[1] x = E*a x = sum(x,beta*cp.square(x)) return x def PPNM_model_cvxpy(a,E,beta): first = E*a second = beta*cp.square(first) third = sum(first,second) return third def…
S2304
  • 21
  • 2
2
votes
0 answers

Representing log difference as disciplined convex program in cvxpy - Index tracking error

I am trying to construct a portfolio tracking an index as closely as possible i.e. minimizing tracking error. The objective function is to minimize the following: The expression being summed is below I have tried setting up the problem in the…
Neelotpal Shukla
  • 446
  • 6
  • 13
2
votes
1 answer

cvxpy:'sum_entries' is not defined

I am trying to resolve a portfolio optimization problem in Python using CVXPY but getting an error sum_entries is not defined. I am using Anaconda 2.7 and Jupyter notebook. I have installed cvxpy, msgpack, argpack and cvxopt using conda pip install.…
2
votes
1 answer

Why does the CVXPY solver violate this simple constraint

import cvxpy as cp import numpy as np x_1 = cp.Variable() x_2 = cp.Variable() objective = cp.Minimize(x_1) constraints = [2*x_1 + x_2 >= 1, x_1+3*x_2>=1, x_1>=0, x_2>=0] prob = cp.Problem(objective, constraints) # The optimal objective value is…
samol
  • 18,950
  • 32
  • 88
  • 127
2
votes
2 answers

How to Access CVXPY Variables/Parameters After Declaration

I'd like to standardize a few cvxpy problems and use them in many places in my codebase. Here is a cleaned example: from cvxpy import Variable, Parameter, Problem, Minimize def problem_builder(n, ...) var = Variable(n) param =…
rhaskett
  • 1,864
  • 3
  • 29
  • 48
2
votes
1 answer

Conda Not Installing Latest Version

I'm installing cvxpy from cvxgrp. Looking a the link it clearly shows version 1.01 for win-64. However when I go to run the install conda install -c cvxgrp cvxpy it downloads and installs "cvxpy-0.4.10". Updating "all" does not seem to help. I…
rhaskett
  • 1,864
  • 3
  • 29
  • 48
2
votes
1 answer

CVXPY installation issues

I'm trying to install cvxpy on Windows 10 with Python 3.6.5. I've installed Anaconda 5.2 but the package website says that, given my version I should go with pip. I tried doing so but I'm stuck with these errors. Any help? (base)…
foreignvol
  • 681
  • 2
  • 7
  • 15
2
votes
1 answer

CVXPY expression doesn't give expected result

I am using CVXPY (version 1.0). I do not understand what causes the difference between a ZERO expression and a NONNEGATIVE expression as demonstrated by the following code: >>> import cvxpy as cv >>> a = cv.Variable(1) >>> b = cv.Variable(1) >>>…
Tony
  • 445
  • 6
  • 13
2
votes
1 answer

CVXPY throws SolverError

When using CVXPY, I frequently get "SolverError". Their doc just says this is caused by numerical issues, but no further information is given about how to avoid them. The following code snippet is an example, the problem is trivial, but the…
Tony
  • 445
  • 6
  • 13
2
votes
1 answer

Upgrading cvxpy Using pip3 Failed

I got this error when upgrading cvxpy using pip3. Does anybody know how to fix this? Thanks. The platform is OS X 10.11.2. Collecting cvxpy Using cached cvxpy-0.3.5.tar.gz Requirement already satisfied (use --upgrade to upgrade): cvxopt>=1.1.6 in…
user111741
  • 21
  • 1