Exemple #1
0
 def atoms(self):
     """A list of the atom types present amongst this atom's arguments.
     """
     atom_list = []
     for arg in self.args:
         atom_list += arg.atoms()
     return unique_list(atom_list + [type(self)])
Exemple #2
0
 def __add__(self, other):
     if other == 0:
         return self
     elif not isinstance(other, XpressProblem):
         raise NotImplementedError()
     return XpressProblem(self.objective + other.objective,
                          unique_list(self.constraints + other.constraints))
Exemple #3
0
 def __add__(self, other):
     if other == 0:
         return self
     elif not isinstance(other, Problem):
         return NotImplemented
     return Problem(self.objective + other.objective,
                    unique_list(self.constraints + other.constraints))
Exemple #4
0
    def atoms(self):
        """Returns all the atoms present in the args.

        Returns
        -------
        list
        """
        # Remove duplicates.
        return unique_list(atom for arg in self.args for atom in arg.atoms())
Exemple #5
0
    def parameters(self):
        """Accessor method for parameters.

        Returns
        -------
        list of :class:`~cvxpy.expressions.constants.parameter.Parameter`
            A list of the parameters in the problem.
        """
        params = self.objective.parameters()
        for constr in self.constraints:
            params += constr.parameters()
        return unique_list(params)
Exemple #6
0
    def variables(self):
        """Accessor method for variables.

        Returns
        -------
        list of :class:`~cvxpy.expressions.variable.Variable`
            A list of the variables in the problem.
        """
        vars_ = self.objective.variables()
        for constr in self.constraints:
            vars_ += constr.variables()
        return unique_list(vars_)
Exemple #7
0
    def atoms(self):
        """Accessor method for atoms.

        Returns
        -------
        list of :class:`~cvxpy.atoms.Atom`
            A list of the atom types in the problem; note that this list
            contains classes, not instances.
        """
        atoms = self.objective.atoms()
        for constr in self.constraints:
            atoms += constr.atoms()
        return unique_list(atoms)
Exemple #8
0
 def __sub__(self, other):
     if not isinstance(other, Problem):
         return NotImplemented
     return Problem(self.objective - other.objective,
                    unique_list(self.constraints + other.constraints))
Exemple #9
0
 def constants(self):
     """Returns all the constants present in the arguments.
     """
     return unique_list(
         [const for arg in self.args for const in arg.constants()])
Exemple #10
0
 def parameters(self):
     """Returns all the parameters present in the arguments.
     """
     return unique_list(
         [param for arg in self.args for param in arg.parameters()])
Exemple #11
0
 def variables(self):
     """Returns all the variables present in the arguments.
     """
     return unique_list(
         [var for arg in self.args for var in arg.variables()])
Exemple #12
0
 def _parameters(self):
     params = self.objective.parameters()
     for constr in self.constraints:
         params += constr.parameters()
     return unique_list(params)
Exemple #13
0
 def _variables(self):
     vars_ = self.objective.variables()
     for constr in self.constraints:
         vars_ += constr.variables()
     return unique_list(vars_)
Exemple #14
0
 def variables(self):
     """Returns all the variables present in the arguments.
     """
     # Remove duplicates.
     return unique_list(var for arg in self.args for var in arg.variables())