Writing a .lp file
回答済みHi,
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
-
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
サインインしてコメントを残してください。
コメント
1件のコメント