Ejemplo n.º 1
0
Archivo: atom.py Proyecto: zxuen/cvxpy
 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)])
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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())
Ejemplo n.º 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)
Ejemplo n.º 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_)
Ejemplo n.º 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)
Ejemplo n.º 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))
Ejemplo n.º 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()])
Ejemplo n.º 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()])
Ejemplo n.º 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()])
Ejemplo n.º 12
0
 def _parameters(self):
     params = self.objective.parameters()
     for constr in self.constraints:
         params += constr.parameters()
     return unique_list(params)
Ejemplo n.º 13
0
 def _variables(self):
     vars_ = self.objective.variables()
     for constr in self.constraints:
         vars_ += constr.variables()
     return unique_list(vars_)
Ejemplo n.º 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())