Error with reading lp/mps model in python
回答済みHi,
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
-
正式なコメント
This post is more than three 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 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
投稿コメントは受け付けていません。
コメント
4件のコメント