File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -816,6 +816,29 @@ def remove_constraints(self, name: str | list[str]) -> None:
816816 logger .debug (f"Removed constraint: { name } " )
817817 self .constraints .remove (name )
818818
819+ def remove_sos_constraints (self , variable : Variable ) -> None :
820+ """
821+ Remove all sos constraints from a given variable.
822+
823+ Parameters
824+ ----------
825+ variable : Variable
826+ Variable instance from which to remove all sos constraints.
827+ Can be retrieved from `m.variables.sos`.
828+
829+ Returns
830+ -------
831+ None.
832+ """
833+ sos_type = variable .attrs .get ("sos_type" )
834+ sos_dim = variable .attrs .get ("sos_dim" )
835+
836+ del variable .attrs ["sos_type" ], variable .attrs ["sos_dim" ]
837+
838+ logger .debug (
839+ f"Removed sos{ sos_type } constraint on { sos_dim } from { variable .name } "
840+ )
841+
819842 def remove_objective (self ) -> None :
820843 """
821844 Remove the objective's linear expression from the model.
You can’t perform that action at this time.
0 commit comments