I have a question about Gurobi. How do I define a constraint that can accept multiple different values? For example, a sample constraint is shown as follows:
f = [1.0, 1.0, 1.0, 1.0]
x = m.addVars(4, lb=0, ub=15, vtype=GRB.INTEGER)
m.addConstr(x.prod(f) == 10 or 15, name="")
This constraint can be equal to multiple values, such as 10 or 15. Is this constraint possible in Gurobi based on the Python language? If so, how should I write the code?
for e in range(nSolutions): part = [] m.setParam(GRB.Param.SolutionNumber, e) for v in range(m.NumVars): part.append(int(x[v].Xn)) solution.append(part)According to the code you gave, the code I wrote seems to report an error, originally it worked fine. – Zying Jul 09 '21 at 07:36.Xattribute, i.e.x[i].Xgives you the value of the variablex[i]andb[i].Xthe value of the variableb[i]. However, I don't see how this should be related to your original question or my answer. My code is based on the example you provided in the question and it's impossible to answer your new question based on the incomplete code snippet in your comment. So please ask a separate question and provide a minimal reproducible example. – joni Jul 09 '21 at 08:32