Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import numpy as np
import quadprog.problem as qp
from quadprog.results import quadprogResults
import cplex as cpx
import ipdb
class CPLEX(object):
"""
An interface for the CPLEX QP solver.
"""
# Map of CPLEX status to CVXPY status. #TODO: add more!
STATUS_MAP = {1: qp.OPTIMAL,
3: qp.INFEASIBLE,
2: qp.UNBOUNDED,
6: qp.OPTIMAL_INACCURATE}
def __init__(self, **kwargs):
self.options = kwargs
def solve(self, p):
# Convert Matrices in CSR format
p.A = p.A.tocsr()
p.P = p.P.tocsr()
# Get problem dimensions
n = p.P.shape[0]
m = p.A.shape[0]
# Adjust infinity values in bounds
import numpy as np
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):