How to use the osqp._osqp.constant function in osqp

To help you get started, we’ve selected a few osqp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oxfordcontrol / osqp-python / module / utils.py View on Github external
linsys_solver_str = settings.pop('linsys_solver', '')
        if not isinstance(linsys_solver_str, str):
            raise TypeError("Setting linsys_solver " +
                            "is required to be a string.")
        linsys_solver_str = linsys_solver_str.lower()
        if linsys_solver_str == 'qdldl':
            settings['linsys_solver'] = _osqp.constant('QDLDL_SOLVER')
        elif linsys_solver_str == 'mkl pardiso':
            settings['linsys_solver'] = _osqp.constant('MKL_PARDISO_SOLVER')
        # Default solver: QDLDL
        elif linsys_solver_str == '':
            settings['linsys_solver'] = _osqp.constant('QDLDL_SOLVER')
        else:   # default solver: QDLDL
            warn("Linear system solver not recognized. " +
                 "Using default solver QDLDL.")
            settings['linsys_solver'] = _osqp.constant('QDLDL_SOLVER')
        return settings
github oxfordcontrol / osqp-python / module / utils.py View on Github external
warn("Converting sparse P to a CSC " +
                 "(compressed sparse column) matrix. (It may take a while...)")
            P = P.tocsc()
        if not sparse.isspmatrix_csc(A):
            warn("Converting sparse A to a CSC " +
                 "(compressed sparse column) matrix. (It may take a while...)")
            A = A.tocsc()

        # Check if P an A have sorted indices
        if not P.has_sorted_indices:
            P.sort_indices()
        if not A.has_sorted_indices:
            A.sort_indices()

        # Convert infinity values to OSQP Infinity
        u = np.minimum(u, _osqp.constant('OSQP_INFTY'))
        l = np.maximum(l, -_osqp.constant('OSQP_INFTY'))

        # Convert linsys_solver string to integer
        settings = linsys_solver_str_to_int(settings)

        return ((n, m), P.data, P.indices, P.indptr, q,
                A.data, A.indices, A.indptr,
                l, u), settings
github oxfordcontrol / osqp-python / module / utils.py View on Github external
"(compressed sparse column) matrix. (It may take a while...)")
            P = P.tocsc()
        if not sparse.isspmatrix_csc(A):
            warn("Converting sparse A to a CSC " +
                 "(compressed sparse column) matrix. (It may take a while...)")
            A = A.tocsc()

        # Check if P an A have sorted indices
        if not P.has_sorted_indices:
            P.sort_indices()
        if not A.has_sorted_indices:
            A.sort_indices()

        # Convert infinity values to OSQP Infinity
        u = np.minimum(u, _osqp.constant('OSQP_INFTY'))
        l = np.maximum(l, -_osqp.constant('OSQP_INFTY'))

        # Convert linsys_solver string to integer
        settings = linsys_solver_str_to_int(settings)

        return ((n, m), P.data, P.indices, P.indptr, q,
                A.data, A.indices, A.indptr,
                l, u), settings
github oxfordcontrol / osqp-python / module / interface.py View on Github external
"""

        # get problem dimensions
        (n, m) = self._model.dimensions()

        # check consistency of the input arguments
        if q is not None and len(q) != n:
            raise ValueError("q must have length n")
        if l is not None:
            if not isinstance(l, np.ndarray):
                raise TypeError("l must be numpy.ndarray, not %s" %
                                type(l).__name__)
            elif len(l) != m:
                raise ValueError("l must have length m")
            # Convert values to -OSQP_INFTY
            l = np.maximum(l, -_osqp.constant('OSQP_INFTY'))
        if u is not None:
            if not isinstance(u, np.ndarray):
                raise TypeError("u must be numpy.ndarray, not %s" %
                                type(u).__name__)
            elif len(u) != m:
                raise ValueError("u must have length m")
            # Convert values to OSQP_INFTY
            u = np.minimum(u, _osqp.constant('OSQP_INFTY'))
        if Ax is None:
            if len(Ax_idx) > 0:
                raise ValueError("Vector Ax has not been specified")
        else:
            if len(Ax_idx) > 0 and len(Ax) != len(Ax_idx):
                raise ValueError("Ax and Ax_idx must have the same lengths")
        if Px is None:
            if len(Px_idx) > 0:

osqp

OSQP: The Operator Splitting QP Solver

Apache-2.0
Latest version published 1 month ago

Package Health Score

79 / 100
Full package analysis