Writing a .lp file
AnsweredHi,
I am trying to read and optimize a .lp file using gurobi. Here's my .lp file:
--------------------------------------------------------
\ Model powerloss
\ LP format - for model browsing. Use MPS format to capture full model detail.
Minimize
[ x ^ 2 + 4 y ^ 2 + 6 z ^ 2 + 12 w ^ 2 + 3 v ^ 2 ]
Subject to
c0: x + y = 710
c1: x -z -w = 0
c2: y + z - v = 0
c3: w + v = 710
Bounds
End
-----------------------------------------------
So, when I try to run this in python using gurobi and some code, it says the following:
Can you please help me with this?
Unable to open file 'C:\Users\user\OneDrive\Documents\powerloss.lp' for input An error occurred: Unable to read model
-
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 Dhruv,
Your LP file is in the correct format. One way to check this is to navigate to the location of your LP file and run the following commands with Python:
import gurobipy as gp
model = gp.read("powerloss.lp")It seems the error is due to your code not being able to locate/open the LP file. Please ensure your code can access the file.
Best regards,
Simran0
Post is closed for comments.
Comments
2 comments