How to use the quadprog.problem.SOLVER_ERROR function in quadprog

To help you get started, we’ve selected a few quadprog 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 / tests / python / quadprog / solvers / cplex_qpif.py View on Github external
end = model.get_time()
        except:  # Error in the solution
            print "Error in CPLEX solution\n"
            return quadprogResults(qp.SOLVER_ERROR, None, None, None,
                                   np.inf, None)

        # Return results

        # Get status
        status = self.STATUS_MAP.get(model.solution.get_status(),
                                     qp.SOLVER_ERROR)

        # Get computation time
        cputime = end-start

        if (status != qp.SOLVER_ERROR) & (status != qp.INFEASIBLE):
            # Get objective value
            objval = model.solution.get_objective_value()

            # Get solution
            sol = np.array(model.solution.get_values())

            # Get dual values
            dual = -np.array(model.solution.get_dual_values())
            # dual_eq = -np.array(duals[:neq])    # Cplex uses swapped signs (-1)
            # dual_ineq = -np.array(duals[neq:])  # Cplex uses swapped signs (-1)

            # Bounds
            # dual_ub = np.zeros(n)
            # dual_lb = np.zeros(n)

            # RCx = m.solution.get_reduced_costs()  # Get reduced costs
github oxfordcontrol / osqp / tests / python / quadprog / solvers / cplex_qpif.py View on Github external
# Solve problem
        try:
            start = model.get_time()
            model.solve()
            end = model.get_time()
        except:  # Error in the solution
            print "Error in CPLEX solution\n"
            return quadprogResults(qp.SOLVER_ERROR, None, None, None,
                                   np.inf, None)

        # Return results

        # Get status
        status = self.STATUS_MAP.get(model.solution.get_status(),
                                     qp.SOLVER_ERROR)

        # Get computation time
        cputime = end-start

        if (status != qp.SOLVER_ERROR) & (status != qp.INFEASIBLE):
            # Get objective value
            objval = model.solution.get_objective_value()

            # Get solution
            sol = np.array(model.solution.get_values())

            # Get dual values
            dual = -np.array(model.solution.get_dual_values())
            # dual_eq = -np.array(duals[:neq])    # Cplex uses swapped signs (-1)
            # dual_ineq = -np.array(duals[neq:])  # Cplex uses swapped signs (-1)
github oxfordcontrol / osqp / quadprog / solvers / gurobi_qpif.py View on Github external
import ipdb


class GUROBI(object):
    """
    An interface for the Gurobi QP solver.
    """

    # Map of Gurobi status to CVXPY status.
    STATUS_MAP = {2: qp.OPTIMAL,
                  3: qp.INFEASIBLE,
                  5: qp.UNBOUNDED,
                  4: qp.SOLVER_ERROR,
                  6: qp.SOLVER_ERROR,
                  7: qp.SOLVER_ERROR,
                  8: qp.SOLVER_ERROR,
                  # TODO could be anything.
                  # means time expired.
                  9: qp.OPTIMAL_INACCURATE,
                  10: qp.SOLVER_ERROR,
                  11: qp.SOLVER_ERROR,
                  12: qp.SOLVER_ERROR,
                  13: qp.SOLVER_ERROR}

    def __init__(self, **kwargs):
        self.options = kwargs

    def solve(self, p):

        # Convert Matrices in CSR format
        p.Aeq = p.Aeq.tocsr()
        p.Aineq = p.Aineq.tocsr()
github oxfordcontrol / osqp / quadprog / solvers / gurobi_qpif.py View on Github external
from quadprog.results import quadprogResults
import gurobipy as grb
import quadprog.problem as qp
import ipdb


class GUROBI(object):
    """
    An interface for the Gurobi QP solver.
    """

    # Map of Gurobi status to CVXPY status.
    STATUS_MAP = {2: qp.OPTIMAL,
                  3: qp.INFEASIBLE,
                  5: qp.UNBOUNDED,
                  4: qp.SOLVER_ERROR,
                  6: qp.SOLVER_ERROR,
                  7: qp.SOLVER_ERROR,
                  8: qp.SOLVER_ERROR,
                  # TODO could be anything.
                  # means time expired.
                  9: qp.OPTIMAL_INACCURATE,
                  10: qp.SOLVER_ERROR,
                  11: qp.SOLVER_ERROR,
                  12: qp.SOLVER_ERROR,
                  13: qp.SOLVER_ERROR}

    def __init__(self, **kwargs):
        self.options = kwargs

    def solve(self, p):