model write contains duplicate constraints and variables
AnsweredHello guys, I have a model and when I do model.write() the created file contains the binary variables plenty of times and a constraint 2 times. I do not create the variables or the constraint 2 times. Is this a typical behavior or is something going wrong?
Kind regards
Iason
-
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. -
Hi Iason,
Please check if the variables or constraints that appear duplicated have the same name in your code. In Gurobi, if different variables or constraints are given the same name, they may appear as duplicates in the output file generated by
model.write(), despite being distinct objects. Always assign unique names to each variable and constraint to prevent this issue.Best regards,
Simran0 -
Thanks Kaur. This was the case as I was using the code:
for i in ["I","E"]:
for r,s in drs.keys():
MPmodel.addGenConstrPWL(Rirs[i,r,s], lRirs[i,r,s], horizPoints, verticalPoints, "log_approximation")0 -
Great to know this is resolved!
0
Post is closed for comments.
Comments
4 comments