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
527 stars 92 forks source link

Can variable index on string set? #47

Closed qtbhappy closed 4 years ago

qtbhappy commented 4 years ago

for example, productSet = ["a" , "b"] var x[p in product]

h-g-s commented 4 years ago

from mip import * m = Model() products = ["a", "b", "c"] x = {p: m.add_var() for p in products} m += xsum(x[p] for p in products) == 1