Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect solution from quasilinear constraint #1828

Closed
nicklar opened this issue Jul 18, 2022 · 1 comment
Closed

Incorrect solution from quasilinear constraint #1828

nicklar opened this issue Jul 18, 2022 · 1 comment

Comments

@nicklar
Copy link

nicklar commented Jul 18, 2022

Describe the bug
cp.sum(cp.sign(x)) constraints not being enforced in a DQCP.

To Reproduce
x = cp.Variable(2)
obj = cp.sum_squares(np.ones(2) - x)
constr = [cp.sum(cp.sign(x)) <= 1]
prob = cp.Problem(cp.Minimize(obj), constr)
prob.solve(qcp = True)

Also try this with <= 0 instead of 1 and it will raise a recursion error.

Expected behavior
The optimal solution of this problem should be (0, 1) but x.value returns (1, 1)

Version

  • OS: M1 Mac monterey
  • CVXPY Version: 1.2.0
@nicklar nicklar closed this as completed Jul 18, 2022
@SteveDiamond SteveDiamond reopened this Jul 18, 2022
@SteveDiamond
Copy link
Collaborator

Your problem should not be qcp. It's a bug in the problem validation. QCP is only supposed to handle sign applied to scalars. @akshayka can you confirm?

SteveDiamond added a commit that referenced this issue Jul 18, 2022
SteveDiamond added a commit to tasseff/cvxpy that referenced this issue Jul 27, 2022
* origin/master:
  Add new QpSolver and ConicSolver for COPT under CVXPY (cvxpy#1836)
  fix linter
  contribute a atomic operation of trace(inv(X)) (cvxpy#1822)
  Add Coverage and benchmark badges (cvxpy#1839)
  Skip XPRESS test (cvxpy#1838)
  Fix bug with diff (cvxpy#1835)
  fix cvxpy#1828 (cvxpy#1829)
SteveDiamond added a commit to r-barnes/cvxpy that referenced this issue Aug 1, 2022
* origin/master: (57 commits)
  fix linters (cvxpy#1851)
  fix link
  publish to web
  [CI] Bump macOS runner (cvxpy#1846)
  Add new QpSolver and ConicSolver for COPT under CVXPY (cvxpy#1836)
  fix linter
  contribute a atomic operation of trace(inv(X)) (cvxpy#1822)
  Add Coverage and benchmark badges (cvxpy#1839)
  Skip XPRESS test (cvxpy#1838)
  Fix bug with diff (cvxpy#1835)
  fix cvxpy#1828 (cvxpy#1829)
  Follow up with assume PSD (cvxpy#1820)
  Update finite_set.py
  Added feature mentioned in issue cvxpy#1695 (cvxpy#1754)
  Assume PSD argument to quad_form (cvxpy#1818)
  Added benchmarks workflow to benchmark the master branch of cvxpy and upload results (cvxpy#1798)
  COPT interface (cvxpy#1796)
  New workflow to make benchmarks run on PR commits (cvxpy#1810)
  [doc] Clarify that abs() supports complex numbers (cvxpy#1814)
  Add condition_number as a quasi-convex atom (cvxpy#1768)
  ...
SteveDiamond added a commit that referenced this issue Aug 31, 2022
SteveDiamond added a commit that referenced this issue Aug 31, 2022
SteveDiamond added a commit that referenced this issue Nov 4, 2022
* fix osqp warm start (#1882)

* switch SCS timings to seconds (#1880)

Co-authored-by: Steven Diamond <steven@gridmatic.com>

* merge fix

* merge fix

* Fix SOC residual (#1844)

* fix SOC residual

* dimension test

* Suggestion for how to compute SOC residual (#1853)

Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>

* Fix bug with diff (#1835)

* fix #1834

* test error

Co-authored-by: Steven Diamond <steven@gridmatic.com>

* fix #1828 (#1829)

* fix mosek

* switch pcp opt vals back

* resolved merge conflicts

* removed mi_lp_5 test

* Update __init__.py

Resolve #1910

* allow lists as shape definitions

* fix types

* fix types for 3.6

* fix gradient for multidimensional quad form (#1854)

* fix multidimensional quad form

* autoblack messed up line ordering

* Adding edge case handling for string inputs into norm (#1871)

* Adding edge case handling for string inputs into norm

Signed-off-by: KerimovEmil <emilkerimov93@gmail.com>

* Update cvxpy/atoms/norm.py

Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>

* Adding norm exception tests to ensure that invalid string inputs are caught

Signed-off-by: KerimovEmil <emilkerimov93@gmail.com>
Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>
Co-authored-by: Steven Diamond <steven@gridmatic.com>

Signed-off-by: KerimovEmil <emilkerimov93@gmail.com>
Co-authored-by: Fabian Schramm <55981657+fabinsch@users.noreply.github.com>
Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>
Co-authored-by: Riley Murray <rileyjmurray@users.noreply.github.com>
Co-authored-by: Robert Huisman <74955560+roberthuisman@users.noreply.github.com>
Co-authored-by: KerimovEmil <emilkerimov93@gmail.com>
SteveDiamond added a commit that referenced this issue Nov 4, 2022
* fix osqp warm start (#1882)

* switch SCS timings to seconds (#1880)

Co-authored-by: Steven Diamond <steven@gridmatic.com>

* merge fix

* fix test

* resolve merge

* Fix SOC residual (#1844)

* fix SOC residual

* dimension test

* Suggestion for how to compute SOC residual (#1853)

Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>

* Fix bug with diff (#1835)

* fix #1834

* test error

Co-authored-by: Steven Diamond <steven@gridmatic.com>

* fix #1828 (#1829)

* cap ortools at 9.3

* fix mosek

* switch pcp opt vals back

* resolve merge conflict

* Update __init__.py

Resolve #1910

* allow list as shape input

* fix gradient for multidimensional quad form (#1854)

* fix multidimensional quad form

* autoblack messed up line ordering

* Adding edge case handling for string inputs into norm (#1871)

* Adding edge case handling for string inputs into norm

Signed-off-by: KerimovEmil <emilkerimov93@gmail.com>

* Update cvxpy/atoms/norm.py

Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>

* Adding norm exception tests to ensure that invalid string inputs are caught

Signed-off-by: KerimovEmil <emilkerimov93@gmail.com>
Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>
Co-authored-by: Steven Diamond <steven@gridmatic.com>

* Fix time_limit_sec for GLOP and PDLP (#1859)

Fixes #1858

Signed-off-by: KerimovEmil <emilkerimov93@gmail.com>
Co-authored-by: Fabian Schramm <55981657+fabinsch@users.noreply.github.com>
Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>
Co-authored-by: Riley Murray <rileyjmurray@users.noreply.github.com>
Co-authored-by: Robert Huisman <74955560+roberthuisman@users.noreply.github.com>
Co-authored-by: KerimovEmil <emilkerimov93@gmail.com>
Co-authored-by: Miles Lubin <miles.lubin@gmail.com>
SteveDiamond added a commit that referenced this issue Dec 27, 2022
* fix osqp warm start (#1882)

* switch SCS timings to seconds (#1880)

Co-authored-by: Steven Diamond <steven@gridmatic.com>

* merge fix

* merge fix

* Fix SOC residual (#1844)

* fix SOC residual

* dimension test

* Suggestion for how to compute SOC residual (#1853)

Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>

* Fix bug with diff (#1835)

* fix #1834

* test error

Co-authored-by: Steven Diamond <steven@gridmatic.com>

* fix #1828 (#1829)

* fix mosek

* switch pcp opt vals back

* resolved merge conflicts

* removed mi_lp_5 test

* Update __init__.py

Resolve #1910

* allow lists as shape definitions

* fix types

* fix types for 3.6

* fix gradient for multidimensional quad form (#1854)

* fix multidimensional quad form

* autoblack messed up line ordering

* Adding edge case handling for string inputs into norm (#1871)

* Adding edge case handling for string inputs into norm

Signed-off-by: KerimovEmil <emilkerimov93@gmail.com>

* Update cvxpy/atoms/norm.py

Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>

* Adding norm exception tests to ensure that invalid string inputs are caught

Signed-off-by: KerimovEmil <emilkerimov93@gmail.com>
Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>
Co-authored-by: Steven Diamond <steven@gridmatic.com>

* disallow float for diamatrix values (#1931)

* add setup.cfg

* Make log_det robust to numerical issues with complex data (#1866)

* log_det takes Hermitian part of its input, therefore can assume that "sign" from numpys slogdet is real.

* Update test_complex.py

* Update test_complex.py

Make certain failing tests verbose, so we can see why logdet tests fail on a small number of platforms.

* guess for fix

* lower precision of test log det

* Update cvxpy/tests/test_complex.py

Remove verbose

Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>

* Update cvxpy/tests/test_complex.py

Remove verbose from test

Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>

Co-authored-by: Steven Diamond <diamond.po.central@gmail.com>
Co-authored-by: Steven Diamond <steven@gridmatic.com>
Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>

* Adapt to API changes in gurobipy (#1962)

Signed-off-by: KerimovEmil <emilkerimov93@gmail.com>
Co-authored-by: Fabian Schramm <55981657+fabinsch@users.noreply.github.com>
Co-authored-by: phschiele <44360364+phschiele@users.noreply.github.com>
Co-authored-by: Riley Murray <rileyjmurray@users.noreply.github.com>
Co-authored-by: Robert Huisman <74955560+roberthuisman@users.noreply.github.com>
Co-authored-by: KerimovEmil <emilkerimov93@gmail.com>
Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>
Co-authored-by: Robert Luce <2168992+rluce@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants