@@ -126,7 +126,7 @@ def __and__(self, other: "LRA"):
126126 if isinstance (other , And ):
127127 return And (* (self .children + other .children ))
128128 else :
129- return And (* (self .children + [other ]))
129+ return And (* (list ( self .children ) + [other ]))
130130
131131 def __str__ (self ) -> str :
132132 return "(" + " & " .join ([str (child ) for child in self .children ]) + ")"
@@ -259,7 +259,8 @@ def to_logic(var: str, lb: float, ub: float):
259259 return self ._expression
260260
261261 def map_constraints (
262- self , f : Callable [[LinearInequality ], LinearInequality ]
262+ self ,
263+ f : Callable [[LinearInequality ], LinearInequality ]
263264 ) -> "LRAProblem" :
264265 """
265266 Applies a function `f` to each `LinearConstraint` in the expression tree while keeping
@@ -268,6 +269,8 @@ def map_constraints(
268269 Args:
269270 f (Callable[[LinearConstraint], LinearConstraint]): The function to apply to each
270271 `LinearConstraint`.
272+ drop_vars (list[str]): A list of variables to to drop as a result of the mapping.
273+ This is used for removing variables that are no longer needed after the mapping.
271274
272275 Returns:
273276 LinearIneqLogicTree: A new expression tree with the modified `LinearConstraint` objects.
@@ -285,15 +288,15 @@ def recurse_expression(expr: LRA) -> LRA:
285288 return Or (* mapped_children )
286289
287290 if self .expression is None :
288- return LRAProblem (None , self ._variables )
291+ return LRAProblem (None , self ._variables , self . _name )
289292 else :
290293 expr = recurse_expression (self ._expression )
291294 variables = gather_variables (expr )
292295 if isinstance (self ._variables , dict ):
293296 sub_vars = {var : self ._variables [var ] for var in variables }
294297 else :
295298 sub_vars = [var for var in self ._variables if var in variables ]
296- return LRAProblem (expr , sub_vars )
299+ return LRAProblem (expr , sub_vars , self . _name )
297300
298301 def get_global_limits (self ) -> dict [str , tuple [float , float ]]:
299302 """
@@ -309,9 +312,9 @@ def get_global_limits(self) -> dict[str, tuple[float, float]]:
309312 "Global limits are not available when variables are provided as a list."
310313 )
311314
312- def __and__ (self , other : LRA | Box ):
315+ def __and__ (self , other : LRA | Box ) -> "LRAProblem" :
313316 if isinstance (other , LRA ):
314- return LRAProblem (self .expression & other , self ._variables )
317+ return LRAProblem (self .expression & other , self ._variables , self . _name )
315318 elif isinstance (other , Box ):
316319 # via global bounds
317320 if isinstance (self ._variables , dict ):
0 commit comments