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]
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)
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]
def __format(self): """Internal version of format with cached results. Returns ------- tuple (equality constraints, inequality constraints) """ return ([], format_elemwise([self.t] + self.x_elems))
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])
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.")
def __SCS_format(self): return ([], format_elemwise([self.x, self.y, self.z]))
def __ECOS_format(self): return ([], format_elemwise([self.x, self.z, self.y]))
def format(self): """Formats SOC constraints as inequalities for the solver. """ return format_elemwise([self.t] + self.x_elems)