@@ -691,23 +691,22 @@ def _create_constraints_for_model(
691691 # Sanitize constraint name for LP format (spaces → underscores)
692692 safe_name = constraint .name .replace (" " , "_" ).replace ("-" , "_" )
693693
694- # Lower bound constraint: lhs >= lb (if lb != -inf)
695- if not is_unbounded (constraint .lower_bound ):
694+ if constraint .is_equality :
696695 lb = visit (constraint .lower_bound , builder )
697696 if validity_mask is not None :
698697 lb = _apply_validity_mask (lb , validity_mask )
699- name = f"{ prefix } __{ safe_name } __lb"
700- con_lb = lhs >= lb # type: ignore[operator]
701- self . linopy_model . add_constraints ( con_lb , name = name ) # type: ignore[arg-type]
702-
703- # Upper bound constraint: lhs <= ub ( if ub != +inf)
704- if not is_unbounded ( constraint . upper_bound ):
705- ub = visit ( constraint . upper_bound , builder )
706- if validity_mask is not None :
707- ub = _apply_validity_mask ( ub , validity_mask )
708- name = f" { prefix } __ { safe_name } __ub"
709- con_ub = lhs <= ub # type: ignore[operator]
710- self .linopy_model .add_constraints (con_ub , name = name ) # type: ignore[arg-type]
698+ self . linopy_model . add_constraints ( lhs == lb , name = f"{ prefix } __{ safe_name } __eq" ) # type: ignore[operator,arg-type]
699+ else :
700+ if not is_unbounded ( constraint . lower_bound ):
701+ lb = visit ( constraint . lower_bound , builder )
702+ if validity_mask is not None :
703+ lb = _apply_validity_mask ( lb , validity_mask )
704+ self . linopy_model . add_constraints ( lhs >= lb , name = f" { prefix } __ { safe_name } __lb" ) # type: ignore[operator,arg-type]
705+ if not is_unbounded ( constraint . upper_bound ) :
706+ ub = visit ( constraint . upper_bound , builder )
707+ if validity_mask is not None :
708+ ub = _apply_validity_mask ( ub , validity_mask )
709+ self .linopy_model .add_constraints (lhs <= ub , name = f" { prefix } __ { safe_name } __ub" ) # type: ignore[operator, arg-type]
711710
712711 def _add_objectives_for_model (
713712 self ,
0 commit comments