Writing a Constraint using quicksum
AnsweredHi team, I am new to Gurobi.
Can someone guide me with writing this constraint?

-
Hi Maxim,
Please provide a Minimal Reproducible Example (MRE) showing what you have already done and the error you are observing.
Cheers,
David0 -
It takes a lot of time to build an MRE. C is an array of options that are predefined. x and y are boolean variables. I used this constraint:
m.addConstrs((gp.quicksum(c[i][j] * x[(i, j)] for i in range(N)) <= c[k][j] * y[k] for k in range(N) for j in range(M)), name="Profit")
Does it match this?
I get an error: Unable to retrieve attribute 'ObjVal'. Did you mean: 'ObjNVal', when trying to take the optimum value. I think that the solver cannot find the optimal solution, given the constraint.
0 -
Hi Maxim,
The constraint looks like it matches.
The error you are getting may indicate that you need to call \(\texttt{m.optimize()}\) before trying to extract the solution.
Cheers,
David0
Please sign in to leave a comment.
Comments
3 comments