Unable to retrieve attribute 'ObjVal', despite GRB_Optimal status
Awaiting user inputHi all,
I use C++ and try to solve a LP with a LinExpr object function and LinExpr constraints that are added in a while-loop. I noticed that sometimes the solution of my algorithm was not feasible for my purpose.
In order to debug the problem I tried to use the model.write() method which gave me an error 10005. I searched through this community and found that my solution might be unfeasible and so I checked for the GRB_IntAttr_Status Attribute (see https://support.gurobi.com/hc/en-us/community/posts/4403281044113-Error-10005-Unable-to-retrieve-attribute-X-). In my case, this attribute is always set to GRB_OPTIMAL. As far as I know, the write() method also writes everything correctly into my lp-file but I still get the error (after writing everything into the output file).
To give a bit of context: In my case the theoretical number of constraints grows exponentially with the problem size and therefore I try to add single constraints in a while-loop until a special condition ist met. Sometimes I get a LP-solution which works as expected and then I don't have the above-mentioned problem when using the write-method, but sometimes this problem occurs and this is always the case, when the LP-solution is wrong and violates constraints that should have been added.
Does anybody know what might be my problem here?
Edit: I think I found the problem: I have the problem that sometimes I add a new constraint, but after that I don't call model.optimize() again. Might this lead to the given error?
-
Hi Robert,
I think I found the problem: I have the problem that sometimes I add a new constraint, but after that I don't call model.optimize() again. Might this lead to the given error?
Probably yes. If the constraint cuts of the previous solution and you don't re-optimize, it is possible that the previous solution is lost. However, I am just guessing here. If calling model.optimize() does not help, could you share a minimal working example reproducing the issue?
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
1 comment