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)])
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))
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))
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())
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)
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_)
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)
def __sub__(self, other): if not isinstance(other, Problem): return NotImplemented return Problem(self.objective - other.objective, unique_list(self.constraints + other.constraints))
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()])
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()])
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()])
def _parameters(self): params = self.objective.parameters() for constr in self.constraints: params += constr.parameters() return unique_list(params)
def _variables(self): vars_ = self.objective.variables() for constr in self.constraints: vars_ += constr.variables() return unique_list(vars_)
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())