osqp / osqp-python

Python interface for OSQP

Home Page:https://osqp.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

macos build wheels fail for 10.15 (catalina)

youkaichao opened this issue · comments

I install osqp via pip: pip install osqp, and then run a small LP problem:

import cvxpy as cp
import numpy as np
x = cp.Variable(4)

objective = cp.Minimize(4 * x[1] + 3 * x[2] + x[3])
constraints = [
    x[0] == 0,
    x >= 0,
    x[1] - x[2] + x[3] >= 1,
    x[1] + 2 * x[2] - 3 * x[3] >= 2,
]
prob = cp.Problem(objective, constraints)

# The optimal objective value is returned by `prob.solve()`.
result = prob.solve()
# The optimal value for x is stored in `x.value`.
print(x.value)
print(objective.value)

It fails on the osqp side.
The error message looks like:

TypeError                                 Traceback (most recent call last)
<ipython-input-2-8997b7dfd83e> in <module>()
----> 1 result = prob.solve()

/Users/youkaichao/anaconda3/envs/py3/lib/python3.6/site-packages/cvxpy/problems/problem.py in solve(self, *args, **kwargs)
    287         else:
    288             solve_func = Problem._solve
--> 289         return solve_func(self, *args, **kwargs)
    290
    291     @classmethod

/Users/youkaichao/anaconda3/envs/py3/lib/python3.6/site-packages/cvxpy/problems/problem.py in _solve(self, solver, warm_start, verbose, parallel, gp, qcp, **kwargs)
    569             self._intermediate_problem)
    570         solution = self._solving_chain.solve_via_data(
--> 571             self, data, warm_start, verbose, kwargs)
    572         full_chain = self._solving_chain.prepend(self._intermediate_chain)
    573         inverse_data = self._intermediate_inverse_data + solving_inverse_data

/Users/youkaichao/anaconda3/envs/py3/lib/python3.6/site-packages/cvxpy/reductions/solvers/solving_chain.py in solve_via_data(self, problem, data, warm_start, verbose, solver_opts)
    192         """
    193         return self.solver.solve_via_data(data, warm_start, verbose,
--> 194                                           solver_opts, problem._solver_cache)

/Users/youkaichao/anaconda3/envs/py3/lib/python3.6/site-packages/cvxpy/reductions/solvers/qp_solvers/osqp_qpif.py in solve_via_data(self, data, warm_start, verbose, solver_opts, solver_cache)
    111             solver_opts['polish'] = solver_opts.get('polish', True)
    112             solver = osqp.OSQP()
--> 113             solver.setup(P, q, A, lA, uA, verbose=verbose, **solver_opts)
    114
    115         results = solver.solve()

/Users/youkaichao/anaconda3/envs/py3/lib/python3.6/site-packages/osqp/interface.py in setup(self, P, q, A, l, u, **settings)
     30
     31         unpacked_data, settings = utils.prepare_data(P, q, A, l, u, **settings)
---> 32         self._model.setup(*unpacked_data, **settings)
     33
     34     def update(self, q=None, l=None, u=None,

TypeError: argument 2 must be numpy.ndarray, not numpy.ndarray

But it works if I build the package myself.

I'm using macos 10.15 (catalina).

This is strange. I think it should be fixed automatically when we build the new wheels using osqp-wheels with the next patch release. Does it fix it for now if you install it with github and pip as:

pip install git+git://github.com/oxfordcontrol/osqp-python.git@v0.6.1