How to use the quadprog.solvers.solvers.GUROBI 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 / qp_examples / basis_pursuit.py View on Github external
m = 200

# Set options of the OSQP solver
options = {'eps_abs':       1e-4,
           'eps_rel':       1e-4,
           'alpha':         1.6,
           'scale_problem': True,
           'scale_steps':   4,
           'polish':        False}

# Create an svm object
basis_pursuit_obj = basis_pursuit(m, n, dens_lvl=0.3, osqp_opts=options)

# Solve with different solvers
resultsCPLEX = basis_pursuit_obj.solve(solver=CPLEX)
resultsGUROBI = basis_pursuit_obj.solve(solver=GUROBI)
resultsOSQP = basis_pursuit_obj.solve(solver=OSQP)


# Print objective values
print "CPLEX  Objective Value: %.3f" % resultsCPLEX.objval
print "GUROBI Objective Value: %.3f" % resultsGUROBI.objval
print "OSQP   Objective Value: %.3f" % resultsOSQP.objval
print "\n"

# Print timings
print "CPLEX  CPU time: %.3f" % resultsCPLEX.cputime
print "GUROBI CPU time: %.3f" % resultsGUROBI.cputime
print "OSQP   CPU time: %.3f" % resultsOSQP.cputime
github oxfordcontrol / osqp / tests / python / qp_examples / huber_fit.py View on Github external
m = 10*n

# Set options of the OSQP solver
options = {'eps_abs':       1e-4,
           'eps_rel':       1e-4,
           'alpha':         1.6,
           'scale_problem': True,
           'scale_steps':   4,
           'polish':        False}

# Create a lasso object
huber_fit_obj = huber_fit(m, n, dens_lvl=0.50, osqp_opts=options)

# Solve with different solvers
resultsCPLEX = huber_fit_obj.solve(solver=CPLEX)
resultsGUROBI = huber_fit_obj.solve(solver=GUROBI)
resultsOSQP = huber_fit_obj.solve(solver=OSQP)

# Print objective values
print "CPLEX  Objective Value: %.3f" % resultsCPLEX.objval
print "GUROBI Objective Value: %.3f" % resultsGUROBI.objval
print "OSQP   Objective Value: %.3f" % resultsOSQP.objval
print "\n"

# Print timings
print "CPLEX  CPU time: %.3f" % resultsCPLEX.cputime
print "GUROBI CPU time: %.3f" % resultsGUROBI.cputime
print "OSQP   CPU time: %.3f" % resultsOSQP.cputime

# ipdb.set_trace()

# Recover A, x and b from the problem
github oxfordcontrol / osqp / tests / python / qp_examples / svm.py View on Github external
def solve(self, solver=OSQP):
        """
        Solve the problem with a specificed solver.
        """
        if solver == OSQP:
            results = self._osqp.solve()
        elif solver == CPLEX:
            results = self._prob.solve(solver=CPLEX, verbose=0)
        elif solver == GUROBI:
            results = self._prob.solve(solver=GUROBI, OutputFlag=0)
        else:
            assert False, "Unhandled solver"
        return results
github oxfordcontrol / osqp / tests / python / qp_examples / svm.py View on Github external
m = 2*n

# Set options of the OSQP solver
options = {'eps_abs':       1e-5,
           'eps_rel':       1e-5,
           'alpha':         1.6,
           'scale_problem': True,
           'scale_steps':   4,
           'polish':        False}

# Create an svm object
svm_obj = svm(m, n, dens_lvl=0.3, osqp_opts=options)

# Solve with different solvers
resultsCPLEX = svm_obj.solve(solver=CPLEX)
resultsGUROBI = svm_obj.solve(solver=GUROBI)
resultsOSQP = svm_obj.solve(solver=OSQP)


# Print objective values
print "CPLEX  Objective Value: %.3f" % resultsCPLEX.objval
print "GUROBI Objective Value: %.3f" % resultsGUROBI.objval
print "OSQP   Objective Value: %.3f" % resultsOSQP.objval
print "\n"

# Print timings
print "CPLEX  CPU time: %.3f" % resultsCPLEX.cputime
print "GUROBI CPU time: %.3f" % resultsGUROBI.cputime
print "OSQP   CPU time: %.3f" % resultsOSQP.cputime
github oxfordcontrol / osqp / tests / python / qp_examples / lp.py View on Github external
def solve(self, solver=OSQP):
        """
        Solve the problem with a specificed solver.
        """
        if solver == OSQP:
            results = self._osqp.solve()
        elif solver == CPLEX:
            results = self._prob.solve(solver=CPLEX, verbose=0)
        elif solver == GUROBI:
            results = self._prob.solve(solver=GUROBI, OutputFlag=0)
        else:
            assert False, "Unhandled solver"
        return results
github oxfordcontrol / osqp / tests / python / qp_examples / lasso.py View on Github external
# Set options of the OSQP solver
options = {'eps_abs':       1e-4,
           'eps_rel':       1e-4,
           'alpha':         1.6,
           'scale_problem': True,
           'scale_steps':   4,
           'polish':        False,
           'warm_start':    True}

# Create a lasso object
lasso_obj = lasso(m, n, inst=numofinst, version='sparse', osqp_opts=options)
for i in range(numofinst):
    # Solve with different solvers
    resultsCPLEX = lasso_obj.solve(solver=CPLEX)
    resultsGUROBI = lasso_obj.solve(solver=GUROBI)
    resultsOSQP = lasso_obj.solve(solver=OSQP)

    # Print objective values
    print "CPLEX  Objective Value: %.3f" % resultsCPLEX.objval
    print "GUROBI Objective Value: %.3f" % resultsGUROBI.objval
    print "OSQP   Objective Value: %.3f" % resultsOSQP.objval
    print "\n"

    # Print timings
    print "CPLEX  CPU time: %.3f" % resultsCPLEX.cputime
    print "GUROBI CPU time: %.3f" % resultsGUROBI.cputime
    print "OSQP   CPU time: %.3f" % resultsOSQP.cputime
    if numofinst > 1:
        lasso_obj.update_gamma(n)
github oxfordcontrol / osqp / tests / python / performance_profile_maros.py View on Github external
def main():
    # Define all solvers
    solvers = [GUROBI, CPLEX]
    nsolvers = len(solvers)  # Number of solvers

    # Directory of problems
    prob_dir = './tests/maros_meszaros'
    lst_probs = os.listdir(prob_dir)

    # Count number of problems
    nprob = len([name for name in lst_probs
                 if os.path.isfile(prob_dir + "/" + name)])
    p = 0

    # DEBUG: To Remove
    # count so that you do not solve all
    # nprob = 50

    # Preallocate times
github oxfordcontrol / osqp / tests / python / qp_examples / basis_pursuit.py View on Github external
def solve(self, solver=OSQP):
        """
        Solve the problem with a specificed solver.
        """
        if solver == OSQP:
            results = self._osqp.solve()
        elif solver == CPLEX:
            results = self._prob.solve(solver=CPLEX, verbose=0)
        elif solver == GUROBI:
            results = self._prob.solve(solver=GUROBI, OutputFlag=0)
        else:
            assert False, "Unhandled solver"
        return results
github oxfordcontrol / osqp / tests / python / qp_examples / lp.py View on Github external
def solve(self, solver=OSQP):
        """
        Solve the problem with a specificed solver.
        """
        if solver == OSQP:
            results = self._osqp.solve()
        elif solver == CPLEX:
            results = self._prob.solve(solver=CPLEX, verbose=0)
        elif solver == GUROBI:
            results = self._prob.solve(solver=GUROBI, OutputFlag=0)
        else:
            assert False, "Unhandled solver"
        return results
github oxfordcontrol / osqp / tests / python / qp_examples / nonneg_l2.py View on Github external
def solve(self, solver=OSQP):
        """
        Solve the problem with a specificed solver.
        """
        if solver == OSQP:
            results = self._osqp.solve()
        elif solver == CPLEX:
            results = self._prob.solve(solver=CPLEX, verbose=1)
        elif solver == GUROBI:
            results = self._prob.solve(solver=GUROBI, OutputFlag=0)
        else:
            assert False, "Unhandled solver"
        return results