coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
518 stars 92 forks source link

Add model.add_at_most_one_constraint() #170

Open PMLP-novo opened 3 years ago

PMLP-novo commented 3 years ago

Sorry if I don't understand SOS correctly but if the result of using an SOS type 1 is at that at most one of the boolean variables are 1 then I think the api should reflect this. So for the sake of clarity I purpose that the api gets updated with a method that is easier to understand for a reader that does not know what an SOS is.

Lets say something like this:

class Model
----
    def add_at_most_one_constraint(self, boolean_variables: List["mip.Var"]:
        self.add_sos([(var,1 )for var in boolean_variables],1)