コード例 #1
0
ファイル: exponential.py プロジェクト: eightyeight/cvxpy
    def format(self, eq_constr, leq_constr, dims, solver):
        """Formats EXP constraints for the solver.

        Parameters
        ----------
        eq_constr : list
            A list of the equality constraints in the canonical problem.
        leq_constr : list
            A list of the inequality constraints in the canonical problem.
        dims : dict
            A dict with the dimensions of the conic constraints.
        solver : str
            The solver being called.
        """
        # Need x, y, z to be lone Variables.
        if solver == s.CVXOPT:
            constraints = []
            for i, var in enumerate(self.vars_):
                if not var.type is VARIABLE:
                    lone_var = lu.create_var(var.size)
                    constraints.append(lu.create_eq(lone_var, var))
                    self.vars_[i] = lone_var
            eq_constr += constraints
        # Converts to an inequality constraint.
        elif solver == s.SCS:
            leq_constr += format_elemwise([self.x, self.y, self.z])
        else:
            raise ValueError("Solver does not support exponential cone.")
        # Update dims.
        dims[s.EXP_DIM] += self.size[0]*self.size[1]
コード例 #2
0
ファイル: exponential.py プロジェクト: bakhtiary/cvxpy
    def __format(self, solver):
        """Internal version of format with cached results.

        Returns
        -------
        tuple
            (equality constraints, inequality constraints)
        """
        eq_constr = []
        leq_constr = []
        # Need x, y, z to be lone Variables.
        if solver == s.CVXOPT:
            constraints = []
            for i, var in enumerate(self.vars_):
                if not var.type is VARIABLE:
                    lone_var = lu.create_var(var.size)
                    constraints.append(lu.create_eq(lone_var, var))
                    self.vars_[i] = lone_var
            eq_constr += constraints
        # Converts to an inequality constraint.
        elif solver == s.SCS:
            leq_constr += format_elemwise([self.x, self.y, self.z])
        else:
            raise SolverError("Solver does not support exponential cone.")
        return (eq_constr, leq_constr)
コード例 #3
0
    def format(self, eq_constr, leq_constr, dims, solver):
        """Formats EXP constraints for the solver.

        Parameters
        ----------
        eq_constr : list
            A list of the equality constraints in the canonical problem.
        leq_constr : list
            A list of the inequality constraints in the canonical problem.
        dims : dict
            A dict with the dimensions of the conic constraints.
        solver : str
            The solver being called.
        """
        # Need x, y, z to be lone Variables.
        if solver == s.CVXOPT:
            constraints = []
            for i, var in enumerate(self.vars_):
                if not var.type is VARIABLE:
                    lone_var = lu.create_var(var.size)
                    constraints.append(lu.create_eq(lone_var, var))
                    self.vars_[i] = lone_var
            eq_constr += constraints
        # Converts to an inequality constraint.
        elif solver == s.SCS:
            leq_constr += format_elemwise([self.x, self.y, self.z])
        else:
            raise ValueError("Solver does not support exponential cone.")
        # Update dims.
        dims[s.EXP_DIM] += self.size[0] * self.size[1]
コード例 #4
0
ファイル: soc_elemwise.py プロジェクト: Adarsh-Barik/cvxpy
    def __format(self):
        """Internal version of format with cached results.

        Returns
        -------
        tuple
            (equality constraints, inequality constraints)
        """
        return ([], format_elemwise([self.t] + self.x_elems))
コード例 #5
0
ファイル: soc_elemwise.py プロジェクト: zxp-proteus/mf_cvxpy
    def __format(self):
        """Internal version of format with cached results.

        Returns
        -------
        tuple
            (equality constraints, inequality constraints)
        """
        return ([], format_elemwise([self.t] + self.x_elems))
コード例 #6
0
    def format(self, eq_constr, leq_constr, dims, solver):
        """Formats SOC constraints as inequalities for the solver.

        Parameters
        ----------
        eq_constr : list
            A list of the equality constraints in the canonical problem.
        leq_constr : list
            A list of the inequality constraints in the canonical problem.
        dims : dict
            A dict with the dimensions of the conic constraints.
        solver : str
            The solver being called.
        """
        leq_constr += format_elemwise([self.t] + self.x_elems)
        # Update dims.
        for cone_size in self.size:
            dims[s.SOC_DIM].append(cone_size[0])
コード例 #7
0
    def format(self, solver):
        """Formats EXP constraints for the solver.

        Parameters
        ----------
            solver : str
                The solver targetted.
        """
        # Need x, y, z to be lone Variables.
        if solver == s.CVXOPT:
            constraints = []
            for i, var in enumerate(self.vars_):
                if not var.type is VARIABLE:
                    lone_var = lu.create_var(var.size)
                    constraints.append(lu.create_eq(lone_var, var))
                    self.vars_[i] = lone_var
            return constraints
        # Converts to an inequality constraint.
        elif solver == s.SCS:
            return format_elemwise([self.x, self.y, self.z])
        else:
            raise TypeError("Solver does not support exponential cone.")
コード例 #8
0
 def __SCS_format(self):
     return ([], format_elemwise([self.x, self.y, self.z]))
コード例 #9
0
 def __ECOS_format(self):
     return ([], format_elemwise([self.x, self.z, self.y]))
コード例 #10
0
ファイル: exponential.py プロジェクト: skaslev/cvxpy
 def __SCS_format(self):
     return ([], format_elemwise([self.x, self.y, self.z]))
コード例 #11
0
ファイル: exponential.py プロジェクト: nishi951/cvxpy
 def __ECOS_format(self):
     return ([], format_elemwise([self.x, self.z, self.y]))
コード例 #12
0
ファイル: soc_elemwise.py プロジェクト: timesofbadri/cvxpy
 def format(self):
     """Formats SOC constraints as inequalities for the solver.
     """
     return format_elemwise([self.t] + self.x_elems)