Error with reading lp/mps model in python
AnsweredHi,
I have the following codes that do not work. I want to read a model file that is in .lp or .mps format.
import gurobipy as gp
model = read("C:\\gurobi810\\win64\\examples\\data\\afiro.mps")
I get the following error,
---------------------------------------------------------------------------
NameError
Traceback (most recent call last)
c:\Users\...\ReadModel.py in <module>
0
-
I can read the same file in Gurobi Interactive Shell and optimize it. I just don't know why I can't read it in VS code using python. thanks!
0 -
Hi Yasaman,
In the interactive shell a different import command is run so that Gurobi's "read" command can be called directly. For normal python code, you'll need to give the "gp" package name for the "read" command, so you should change your python script to the following:
import gurobipy as gp
model = gp.read("C\\gurobi810\\win64\\examples\\data\\afiro.mps")Best regards,
Simon0 -
Thanks for your response!
I tried the following,
import gurobipy as gp
model = gp.read("C\\gurobi810\\win64\\examples\\data\\afiro.mps")I get the following error,---------------------------------------------------------------------------GurobiError Traceback (most recent call last) c:\Users\A126289\OneDrive - PROGRESSIVE CORPORATION\Yasaman_folder_All Files\Optimization_Analysis\OMB\OMB Schedule Models\Python Code\ReadModel.py in <module>0
Please sign in to leave a comment.
Comments
3 comments