Reading MPS Files Java

135 views
Skip to first unread message

David Myers

unread,
Dec 30, 2015, 10:25:05 AM12/30/15
to Gurobi Optimization
Hello everyone,

I am using Gurobi through the Java API and I generate my own MPS file first and read in that MPS file into Gurobi and solve the problem. 

For some reason, Gurobi is changing my variable names and using their own variable names (which makes it impossible to actually understand the associated .sol file).  It also is telling me "variables X and Y have the same name "varName"" where each time I solve the problem, x, , and "varName" change.  Any advice would be much appreciated.

--David

Kostja Siefen

unread,
Dec 30, 2015, 11:23:20 AM12/30/15
to Gurobi Optimization
Hi David,

by using the Java API the variable object (class GRBVar) gives you a unique reference to a specific variable. That also means you can create and use two different variable objects with the same name. 
However, variables in MPS files are identified by their unique name. So if you try to write an MPS file of a model that contains multiple variables with the same name the variable names are changed to the default names. You should see a message like

Warning: default variable names used to write mps file

Kostja 

David Myers

unread,
Dec 30, 2015, 11:39:09 AM12/30/15
to Gurobi Optimization
Thank you for your response.

I see that when writing an MPS file back out, it does use these new unique names.  Is it possible to stop the reader from considering these "different variable objects" for lack of better terms.  This disconnect is causing it to say I have an objective value of 0, despite variables that should be in the objective function (and according to reading the .lp file are in the objective function) having value.

Thanks again, I appreciate it.

Kostja Siefen

unread,
Dec 30, 2015, 11:44:14 AM12/30/15
to Gurobi Optimization
Just make sure that all of your variables (see getVars() at http://www.gurobi.com/documentation/6.5/refman/java_grbmodel_getvars.html) contain unique values (without spaces) for the VarName attribute.

Kostja
Reply all
Reply to author
Forward
0 new messages