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

Can ECOS handle infinite values in inequality vectors? #49

Open
stephane-caron opened this issue Jan 31, 2023 · 0 comments
Open

Can ECOS handle infinite values in inequality vectors? #49

stephane-caron opened this issue Jan 31, 2023 · 0 comments

Comments

@stephane-caron
Copy link

stephane-caron commented Jan 31, 2023

ECOS does not seem to handle infinite values in inequality bounds, which happen for instance when disabling an inequality while working on a problem (e.g. in box inequalities lb <= x <= ub). Right now the solver fails at first iteration if we put an infinite float (numpy.inf) in the inequality vector.

Reproduction steps

Here is an example:

import numpy as np
import scipy.sparse as spa
import ecos

c = np.array([0.0, 0.0, 1.0])
G = spa.csc_matrix(
    np.array(
        [
            [-1.0, 0.0, 0.0],
            [0.0, -1.0, 0.0],
            [1.0, 0.0, 0.0],
            [0.0, 1.0, 0.0],
            [0.0, 0.0, -0.70710678],
            [-1.0, 0.0, 0.0],
            [0.0, -1.0, 0.0],
            [0.0, 0.0, 0.70710678],
        ]
    )
)
h = np.array([1.0, np.inf, np.inf, 1.0, 0.70710678, 0.0, 0.0, 0.70710678])
dims = {"q": [4], "l": 4}
ecos.solve(c, G, h, dims)

It produces the following output:

ECOS 2.0.10 - (C) embotech GmbH, Zurich Switzerland, 2012-15. Web: www.embotech.com/ECOS

It     pcost       dcost      gap   pres   dres    k/t    mu     step   sigma     IR    |   BT
 0   -nan   -inf  +nan  0e+00  7e-02  1e+00  nan    ---    ---    0  1  - |  -  - 
Reached NAN dead end, recovering best iterate (368424832) and stopping.

Close to OPTIMAL (within feastol=6.9e-310, reltol=6.9e-310, abstol=6.9e-310).
Runtime: 0.000546 seconds.

See also

This example was produced from a small 2D quadratic program with box inequalities qpsolvers/qpsolvers#160:

import numpy as np
from qpsolvers import solve_qp

# minimize 1/2 x^T P x + q^T x
P = np.eye(2)
q = np.zeros(2)

# subject to lb <= x <= ub
lb = np.array([-1.0, -np.inf])
ub = np.array([np.inf, 1.0])

solve_qp(P, q, lb=lb, ub=ub, solver="ecos")
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

1 participant