Taking remainders in gurobi
AnsweredHi, I was interested in taking remainder in Gurobi and I referenced the following post.
However, I am facing an issue.
I want to perform T % 32. Say T is 320 and I expect the remainder to be 0. To formulate this, I have 320 = 32 * a + b. Gurobi gave result a = 9, b = 32. How to ensure that 'b' gets the minimum value. So, 'a' should be 10 and 'b' is zero.
-
Official comment
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
-
I think I found the answer, I set upper bound for b to be 31. Let me know if this not the right way.
0 -
Hi Shesha,
a=9 and b=32 is a perfectly valid solution to the problem. To enforce that Gurobi selects a solution that minimizes the remainder b, you need to specify exactly that and add b to your objective function.
Setting the upper bound of the remainder to be n-1 for n being the modulo value, is also a good idea nonetheless.
I hope that helps.
Cheers,
Matthias0 -
Thank you !
0
Post is closed for comments.
Comments
4 comments