コード例 #1
0
    def choose_solver(constraints):
        """Determines the appropriate solver.

        Parameters
        ----------
        constraints: list
            The list of canonicalized constraints.

        Returns
        -------
        str
            The solver that will be used.
        """
        constr_map = SymData.filter_constraints(constraints)
        # If no constraints, use ECOS.
        if len(constraints) == 0:
            return s.ECOS
        # If mixed integer constraints, use ECOS_BB.
        elif constr_map[s.BOOL] or constr_map[s.INT]:
            return s.ECOS_BB
        # If SDP or EXP, defaults to CVXOPT.
        elif constr_map[s.SDP] or constr_map[s.EXP]:
            return s.CVXOPT
        # Otherwise use ECOS.
        else:
            return s.ECOS
コード例 #2
0
ファイル: solver.py プロジェクト: Adarsh-Barik/cvxpy
    def choose_solver(constraints):
        """Determines the appropriate solver.

        Parameters
        ----------
        constraints: list
            The list of canonicalized constraints.

        Returns
        -------
        str
            The solver that will be used.
        """
        constr_map = SymData.filter_constraints(constraints)
        # If no constraints, use ECOS.
        if len(constraints) == 0:
            return s.ECOS
        # If mixed integer constraints, use ECOS_BB.
        elif constr_map[s.BOOL] or constr_map[s.INT]:
            return s.ECOS_BB
        # If SDP, defaults to CVXOPT.
        elif constr_map[s.SDP]:
            return s.CVXOPT
        # Otherwise use ECOS.
        else:
            return s.ECOS
コード例 #3
0
ファイル: solver.py プロジェクト: Jakobularius/cvxpy
    def validate_solver(self, constraints):
        """Raises an exception if the solver cannot solve the problem.

        Parameters
        ----------
        constraints: list
            The list of canonicalized constraints.
        """
        constr_map = SymData.filter_constraints(constraints)
        if (constr_map[s.SDP] and not self.sdp_capable()) or \
           (constr_map[s.EXP] and not self.exp_capable()) or \
           (len(constraints) == 0 and self.name() == s.SCS):
            raise SolverError(
                "The solver %s cannot solve the problem." % self.name()
            )
コード例 #4
0
    def validate_solver(self, constraints):
        """Raises an exception if the solver cannot solve the problem.

        Parameters
        ----------
        constraints: list
            The list of canonicalized constraints.
        """
        # Check the solver is installed.
        if not self.is_installed():
            raise SolverError("The solver %s is not installed." % self.name())
        # Check the solver can solve the problem.
        constr_map = SymData.filter_constraints(constraints)
        if ((constr_map[s.BOOL] or constr_map[s.INT]) \
            and not self.MIP_CAPABLE) or \
           (constr_map[s.SDP] and not self.SDP_CAPABLE) or \
           (constr_map[s.EXP] and not self.EXP_CAPABLE) or \
           (constr_map[s.SOC] and not self.SOCP_CAPABLE) or \
           (len(constraints) == 0 and self.name() in [s.SCS,
                                                      s.GLPK]):
            raise SolverError("The solver %s cannot solve the problem." %
                              self.name())
コード例 #5
0
ファイル: solver.py プロジェクト: Adarsh-Barik/cvxpy
    def validate_solver(self, constraints):
        """Raises an exception if the solver cannot solve the problem.

        Parameters
        ----------
        constraints: list
            The list of canonicalized constraints.
        """
        # Check the solver is installed.
        if not self.is_installed():
            raise SolverError("The solver %s is not installed." % self.name())
        # Check the solver can solve the problem.
        constr_map = SymData.filter_constraints(constraints)
        if ((constr_map[s.BOOL] or constr_map[s.INT]) \
            and not self.MIP_CAPABLE) or \
           (constr_map[s.SDP] and not self.SDP_CAPABLE) or \
           (constr_map[s.EXP] and not self.EXP_CAPABLE) or \
           (constr_map[s.SOC] and not self.SOCP_CAPABLE) or \
           (len(constraints) == 0 and self.name() in [s.SCS,
                                                      s.GLPK]):
            raise SolverError(
                "The solver %s cannot solve the problem." % self.name()
            )
コード例 #6
0
    def validate_solver(self, constraints):
        """Raises an exception if the solver cannot solve the problem.

        Parameters
        ----------
        constraints: list
            The list of canonicalized constraints.
        """
        # Check the solver is installed.
        if not self.is_installed():
            raise SolverError("The solver %s is not installed." % self.name())
        # Check the solver can solve the problem.
        constr_map = SymData.filter_constraints(constraints)

        if (constr_map[s.BOOL] or constr_map[s.INT]) and not self.MIP_CAPABLE:
            self._reject_problem("it cannot solve mixed-integer problems")
        elif constr_map[s.SDP] and not self.SDP_CAPABLE:
            self._reject_problem("it cannot solve semidefinite problems")
        elif constr_map[s.EXP] and not self.EXP_CAPABLE:
            self._reject_problem("it cannot solve exponential cone problems")
        elif constr_map[s.SOC] and not self.SOCP_CAPABLE:
            self._reject_problem("it cannot solve second-order cone problems")
        elif len(constraints) == 0 and self.name() in (s.SCS, s.GLPK):
            self._reject_problem("it cannot solve unconstrained problems")
コード例 #7
0
ファイル: solver.py プロジェクト: nicaiseeric/cvxpy
    def validate_solver(self, constraints):
        """Raises an exception if the solver cannot solve the problem.

        Parameters
        ----------
        constraints: list
            The list of canonicalized constraints.
        """
        # Check the solver is installed.
        if not self.is_installed():
            raise SolverError("The solver %s is not installed." % self.name())
        # Check the solver can solve the problem.
        constr_map = SymData.filter_constraints(constraints)

        if (constr_map[s.BOOL] or constr_map[s.INT]) and not self.MIP_CAPABLE:
            self._reject_problem("it cannot solve mixed-integer problems")
        elif constr_map[s.SDP] and not self.SDP_CAPABLE:
            self._reject_problem("it cannot solve semidefinite problems")
        elif constr_map[s.EXP] and not self.EXP_CAPABLE:
            self._reject_problem("it cannot solve exponential cone problems")
        elif constr_map[s.SOC] and not self.SOCP_CAPABLE:
            self._reject_problem("it cannot solve second-order cone problems")
        elif len(constraints) == 0 and self.name() in (s.SCS, s.GLPK):
            self._reject_problem("it cannot solve unconstrained problems")