Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __eq__(self, other) -> LinExpr:
if isinstance(other, Var):
return LinExpr([self, other], [1, -1], sense="=")
elif isinstance(other, LinExpr):
return other == self
elif isinstance(other, int) or isinstance(other, float):
if other != 0:
return LinExpr([self], [1], -1 * other, sense="=")
return LinExpr([self], [1], sense="=")
def __ge__(self, other) -> LinExpr:
if isinstance(other, Var):
return LinExpr([self, other], [1, -1], sense=">")
elif isinstance(other, LinExpr):
return other <= self
elif isinstance(other, int) or isinstance(other, float):
if other != 0:
return LinExpr([self], [1], -1 * other, sense=">")
return LinExpr([self], [1], sense=">")
def copy(self) -> "LinExpr":
copy = LinExpr()
copy.__const = self.__const
copy.__expr = self.__expr.copy()
copy.__sense = self.__sense
return copy
def __le__(self, other) -> LinExpr:
if isinstance(other, Var):
return LinExpr([self, other], [1, -1], sense="<")
elif isinstance(other, LinExpr):
return other >= self
elif isinstance(other, int) or isinstance(other, float):
if other != 0:
return LinExpr([self], [1], -1 * other, sense="<")
return LinExpr([self], [1], sense="<")
def __eq__(self, other) -> LinExpr:
if isinstance(other, Var):
return LinExpr([self, other], [1, -1], sense="=")
elif isinstance(other, LinExpr):
return other == self
elif isinstance(other, int) or isinstance(other, float):
if other != 0:
return LinExpr([self], [1], -1 * other, sense="=")
return LinExpr([self], [1], sense="=")
def __add__(self, other) -> LinExpr:
if isinstance(other, Var):
return LinExpr([self, other], [1, 1])
elif isinstance(other, LinExpr):
return other.__add__(self)
elif isinstance(other, int) or isinstance(other, float):
return LinExpr([self], [1], other)
def __add__(self, other) -> LinExpr:
if isinstance(other, Var):
return LinExpr([self, other], [1, 1])
elif isinstance(other, LinExpr):
return other.__add__(self)
elif isinstance(other, int) or isinstance(other, float):
return LinExpr([self], [1], other)