How to use the cvxopt.solvers.options function in cvxopt

To help you get started, we’ve selected a few cvxopt 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 jeffmahler / GPIS / src / grasp_selection / quality.py View on Github external
qualities = []
        metrics = ['force_closure', 'min_singular', 'wrench_volume', 'grasp_isotropy', 'ferrari_canny_L1']
        for metric in metrics:
            q = PointGraspMetrics3D.grasp_quality(grasp, graspable, metric, soft_fingers=True)
            qualities.append(q)
            print 'Grasp quality according to %s: %f' %(metric, q)

        if vis:
            grasp.visualize(graspable)
            graspable.visualize()
            mv.show()


# TODO: find a way to log output?
cvx.solvers.options['show_progress'] = False

if __name__ == '__main__':
    logging.getLogger().setLevel(logging.ERROR)
    # test_gurobi_qp()
    test_cvxopt_qp()
    # test_ferrari_canny_L1_synthetic()
github rwl / pylon / pylon / routine / ac_opf.py View on Github external
def solve(self):
        """ Solves AC OPF. """

        # Turn off output to screen.
        solvers.options["show_progress"] = self.show_progress
        solvers.options["maxiters"] = self.max_iterations
        solvers.options["abstol"] = self.absolute_tol
        solvers.options["reltol"] = self.relative_tol
        solvers.options["feastol"] = self.feasibility_tol
        solvers.options["refinement"] = self.refinement

        network = self.network
        logger.debug("Solving AC OPF [%s]" % network.name)

        buses = network.connected_buses
        branches = network.online_branches
        generators = network.online_generators
        n_buses = len(network.connected_buses)
        n_branches = len(network.online_branches)
        n_generators = len(network.online_generators)

        # The number of non-linear equality constraints.
        n_equality = 2 * n_buses
        # The number of control variables.
github sawcordwell / pymdptoolbox / src / mdptoolbox / mdp.py View on Github external
# Initialise a linear programming MDP.
        # import some functions from cvxopt and set them as object methods
        try:
            from cvxopt import matrix, solvers
            self._linprog = solvers.lp
            self._cvxmat = matrix
        except ImportError:
            raise ImportError("The python module cvxopt is required to use "
                              "linear programming functionality.")
        # initialise the MDP. epsilon and max_iter are not needed
        MDP.__init__(self, transitions, reward, discount, None, None,
                     skip_check=skip_check)
        # Set the cvxopt solver to be quiet by default, but ...
        # this doesn't do what I want it to do c.f. issue #3
        if not self.verbose:
            solvers.options['show_progress'] = False
github eriklindernoren / ML-From-Scratch / mlfromscratch / supervised_learning / support_vector_machine.py View on Github external
from __future__ import division, print_function
import numpy as np
import cvxopt
from mlfromscratch.utils import train_test_split, normalize, accuracy_score
from mlfromscratch.utils.kernels import *
from mlfromscratch.utils import Plot

# Hide cvxopt output
cvxopt.solvers.options['show_progress'] = False

class SupportVectorMachine(object):
    """The Support Vector Machine classifier.
    Uses cvxopt to solve the quadratic optimization problem.

    Parameters:
    -----------
    C: float
        Penalty term.
    kernel: function
        Kernel function. Can be either polynomial, rbf or linear.
    power: int
        The degree of the polynomial kernel. Will be ignored by the other
        kernel functions.
    gamma: float
        Used in the rbf kernel function.
github rwl / pylon / contrib / cvxopf.py View on Github external
def __init__(self, om, opt=None, solver=None):
        """ Initialises the new DCOPF instance.
        """
        super(DCOPFSolver, self).__init__(om, opt)

        # Choice of solver (May be None or "mosek" (or "glpk" for linear
        # formulation)). Specify None to use the Python solver from CVXOPT.
        self.solver = solver

        if opt.has_key("verbose"):
            solvers.options["show_progress"] = opt["verbose"]
        if opt.has_key("max_it"):
            solvers.options["maxiters"] = opt["max_it"]
        if opt.has_key("feastol"):
            solvers.options["feastol"] = opt["feastol"]
        if opt.has_key("gradtol"):
            raise NotImplementedError
        if opt.has_key("comptol"):
            raise NotImplementedError
        if opt.has_key("costtol"):
            raise NotImplementedError
        if opt.has_key("max_red"):
            raise NotImplementedError
        if opt.has_key("step_control"):
            raise NotImplementedError
        if opt.has_key("cost_mult"):
            raise NotImplementedError
github yangarbiter / adversarial-nonparametrics / nnattack / attacks / trees / dt_opt.py View on Github external
from copy import deepcopy

import numpy as np
from sklearn.tree import DecisionTreeClassifier
from joblib import Parallel, delayed
from cvxopt import matrix, solvers
import cvxopt.glpk
import cvxopt

from ..base import AttackModel

solvers.options['maxiters'] = 30
solvers.options['show_progress'] = False
solvers.options['refinement'] = 0
solvers.options['feastol'] = 1e-7
solvers.options['abstol'] = 1e-7
solvers.options['reltol'] = 1e-7
cvxopt.glpk.options["msg_lev"] = "GLP_MSG_OFF"

def get_sol_l2(target_x, target_y, paths, tree, constraints):
    value = tree.value
    fet_dim = tree.n_features
    temp = (target_x, np.inf)

    for i, path in enumerate(paths):
        if np.argmax(value[path[-1]]) != target_y:
            G, h = constraints[i]
            G, h = matrix(G, tc='d'), matrix(h, tc='d')
            temph = h - 1e-4

            c = matrix(np.concatenate((np.zeros(fet_dim), np.ones(1))), tc='d')
github math1um / objects-invariants-properties / graphinvariants.py View on Github external
def lovasz_theta(g):
    import cvxopt.base
    import cvxopt.solvers

    cvxopt.solvers.options['show_progress'] = False
    cvxopt.solvers.options['abstol'] = float(1e-10)
    cvxopt.solvers.options['reltol'] = float(1e-10)

    gc = g.complement()
    n = gc.order()
    m = gc.size()

    if n == 1:
        return 1.0

    #the definition of Xrow assumes that the vertices are integers from 0 to n-1, so we relabel the graph
    gc.relabel()
    
    d = m + n
    c = -1 * cvxopt.base.matrix([0.0]*(n-1) + [2.0]*(d-n))
    Xrow = [i*(1+n) for i in xrange(n-1)] + [b+a*n for (a, b) in gc.edge_iterator(labels=False)]
    Xcol = range(n-1) + range(d-1)[n-1:]
github statsmodels / statsmodels / statsmodels / stats / _knockoff.py View on Github external
c = matrix(-np.ones(nvar))

    h0 = np.concatenate((np.zeros(nvar), np.ones(nvar)))
    h0 = matrix(h0)
    G0 = np.concatenate((-np.eye(nvar), np.eye(nvar)), axis=0)
    G0 = matrix(G0)

    h1 = 2 * Sigma
    h1 = matrix(h1)
    i, j = np.diag_indices(nvar)
    G1 = np.zeros((nvar*nvar, nvar))
    G1[i*nvar + j, i] = 1
    G1 = matrix(G1)

    solvers.options['show_progress'] = False
    sol = solvers.sdp(c, G0, h0, [G1], [h1])
    sl = np.asarray(sol['x']).ravel()

    xcov = np.dot(exog.T, exog)
    exogn = _get_knmat(exog, xcov, sl)

    return exog, exogn, sl
github cvxgrp / cvxpy / cvxpy / problems / solvers / cvxopt_intf.py View on Github external
def _restore_solver_options(old_options):
        import cvxopt.solvers
        for key, value in list(cvxopt.solvers.options.items()):
            if key in old_options:
                cvxopt.solvers.options[key] = old_options[key]
            else:
                del cvxopt.solvers.options[key]
github msmbuilder / msmbuilder / Mixtape / mslds_solvers / mslds_Q_sdp.py View on Github external
Gs[i] = -Gs[i]
    G = np.copy(matrix(Gs[0]))

    # Now scale D upwards for stability
    max_D_eig = max(eig(D)[0])

    hs, _ = construct_const_matrix(x_dim, A, Bdown, D)
    for i in range(len(hs)):
        hs[i] = matrix(hs[i])
    # Smallest number epsilon such that 1. + epsilon != 1.
    epsilon = np.finfo(np.float32).eps
    # Add a small positive offset to avoid taking sqrt of singular matrix
    F = real(sqrtm(Bdown + epsilon * eye(x_dim)))

    solvers.options['maxiters'] = max_iters
    solvers.options['show_progress'] = show_display
    #solvers.options['debug'] = True
    sol = solvers.sdp(cm, Gs=Gs, hs=hs)
    qvec = np.array(sol['x'])
    qvec = qvec[int(1 + x_dim * (x_dim + 1) / 2):]
    Q = np.zeros((x_dim, x_dim))
    for j in range(x_dim):
        for k in range(j + 1):
            vec_pos = int(j * (j + 1) / 2 + k)
            Q[j, k] = qvec[vec_pos]
            Q[k, j] = Q[j, k]
    return sol, c, Gs, hs