problem reading .lp files

2,718 views
Skip to first unread message

Fabian Hoermann

unread,
May 10, 2014, 4:19:22 PM5/10/14
to gur...@googlegroups.com
Dear Colleagues,

i have problems with reading .lp-Files. Here is my error, after i typed m=read("inst2501.lp")

-------------------------------------------------------------------
Unable to read file
Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "gurobi.pxi", line 1997, in gurobipy.read (../../src/python/gurobipy.c:64310)
      File "gurobi.pxi", line 56, in gurobipy.gurobi.read (../../src/python/gurobipy.c:62689)
gurobipy.GurobiError: Unable to read model
------------------------------------------------------------------

The .lp File seems to be correct, as CPLEX can read it. Is there a better solution than converting the .lp-File to .mps ?

Sincerely yours

T.

unread,
May 10, 2014, 7:49:12 PM5/10/14
to gur...@googlegroups.com
There is no common standard for LP files, so it can happen that CPLEX can read files that Gurobi cannot read. For example, Gurobi needs spaces between numbers and operators, etc.

Could you post your LP file?

Fabian Hoermann

unread,
May 11, 2014, 5:18:23 AM5/11/14
to gur...@googlegroups.com
Hi,

thanks for your answer. Here is an example:

Maximize
 obj:  +132 x#1#2#3 +146 x#1#2#4 +163 x#1#2#5 +131 x#1#3#4 +56 x#1#3#5 +133 x#1#4#5
  +139 x#2#3#4 +159 x#2#3#5 +170 x#2#4#5 +122 x#3#4#5
Subject to
 feasibility_1:
  + x#1#4#5 + x#1#3#5 + x#1#3#4 + x#1#2#5 + x#1#2#4 + x#1#2#3
  <= 1
 feasibility_2:
  + x#1#2#5 + x#1#2#4 + x#1#2#3 + x#2#4#5 + x#2#3#5 + x#2#3#4
  <= 1
 feasibility_3:
  + x#1#2#3 + x#2#3#5 + x#2#3#4 + x#1#3#5 + x#1#3#4 + x#3#4#5
  <= 1
 feasibility_4:
  + x#2#3#4 + x#1#3#4 + x#1#2#4 + x#3#4#5 + x#2#4#5 + x#1#4#5
  <= 1
 feasibility_5:
  + x#3#4#5 + x#2#4#5 + x#2#3#5 + x#1#4#5 + x#1#3#5 + x#1#2#5
  <= 1

User Cuts
 upperBound_1U:
  + x#3#4#5 + x#2#4#5 + x#2#3#5 + x#2#3#4 + x#1#4#5 + x#1#3#5
  + x#1#3#4 + x#1#2#5 + x#1#2#4 + x#1#2#3 <= 1
Bounds
 0 <= x#1#2#3 <= 1
 0 <= x#1#2#4 <= 1
 0 <= x#1#2#5 <= 1
 0 <= x#1#3#4 <= 1
 0 <= x#1#3#5 <= 1
 0 <= x#1#4#5 <= 1
 0 <= x#2#3#4 <= 1
 0 <= x#2#3#5 <= 1
 0 <= x#2#4#5 <= 1
 0 <= x#3#4#5 <= 1
General
 x#1#2#3
 x#1#2#4
 x#1#2#5
 x#1#3#4
 x#1#3#5
 x#1#4#5
 x#2#3#4
 x#2#3#5
 x#2#4#5
 x#3#4#5
End

kind regards

Greg Glockner

unread,
May 11, 2014, 9:24:17 AM5/11/14
to gur...@googlegroups.com
> User Cuts
> upperBound_1U:
> + x#3#4#5 + x#2#4#5 + x#2#3#5 + x#2#3#4 + x#1#4#5 + x#1#3#5
> + x#1#3#4 + x#1#2#5 + x#1#2#4 + x#1#2#3 <= 1

This is proprietary to CPLEX. You will need to write this as a constraint or use the APIs to implement a cut.


T.

unread,
May 11, 2014, 9:46:10 AM5/11/14
to gur...@googlegroups.com
As a quick and dirty fix, it should be sufficient to remove the line "User Cuts" from the file.

Fabian Hoermann

unread,
May 12, 2014, 1:13:14 PM5/12/14
to gur...@googlegroups.com
Thanks to both of you for your answers.

Best regards

Morgrim X

unread,
Dec 18, 2014, 2:50:46 PM12/18/14
to gur...@googlegroups.com
I am having this problem now.  I can't find a reference guide that explains the lp format that Gurobi requires.  I'm not even sure how to make a comment

I have saved it as a text file d=format using the .lp extension in Windows 8.1's notepad.

The gurobi examples have no comment.  It looks like there is no CRLF.

I have no idea what I have to do. 

Renan Garcia

unread,
Dec 18, 2014, 2:58:12 PM12/18/14
to gur...@googlegroups.com
Have a look at http://www.gurobi.com/documentation/6.0/reference-manual/lp_format. For example, the backslash symbol '\' starts a comment.

--

---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Morgrim X

unread,
Dec 18, 2014, 3:36:46 PM12/18/14
to gur...@googlegroups.com
Thank you so much.  Some of my variable names begin with a number.

I hope that's the problem. 

It would be nice if the parser gave a meaningful error message.

I presume any text file using the correct format would be readable.
Message has been deleted

Morgrim X

unread,
Dec 18, 2014, 5:39:37 PM12/18/14
to gur...@googlegroups.com
I failed to show the error I'm getting.  I think it's identical to the code the person who opened this thread had:

gurobi> m = read("C:\Users\Public\Towers.lp")

Unable to read file
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "gurobi.pxi", line 2002, in gurobipy.read (../../src/python/gurobipy.c:68
614)
  File "gurobi.pxi", line 57, in gurobipy.gurobi.read (../../src/python/gurobipy
.c:66993)

gurobipy.GurobiError: Unable to read model
gurobi>


Since then, I renamed the file, but this is the error I get  every time.

Renan Garcia

unread,
Dec 18, 2014, 5:53:43 PM12/18/14
to gur...@googlegroups.com
Are tokens "T1Def <96> 1500" supposed to be a single variable name? Spaces are not allowed in the LP format.

Morgrim X

unread,
Dec 18, 2014, 6:24:13 PM12/18/14
to gur...@googlegroups.com
I found some errors in my model, fixed them, and still get the same error messages:

gurobi> m = read("C:\Users\Micky Lee\Documents\Empire\Towers.lp")

Unable to read file
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "gurobi.pxi", line 2002, in gurobipy.read (../../src/python/gurobipy.c:68
614)
  File "gurobi.pxi", line 57, in gurobipy.gurobi.read (../../src/python/gurobipy
.c:66993)
gurobipy.GurobiError: Unable to read model
gurobi>

Attached is the file associated with these errors.  Everything seems so straightforward.  This is driving me nuts.
Towers.lp

Morgrim X

unread,
Dec 18, 2014, 6:51:32 PM12/18/14
to gur...@googlegroups.com
I found my error.  I hope no one wasted too much time on this.

I had a number of entries where I included a multiplier symbol, *, e.g. 2 * X.  It should read 2 X.

Duh.

Erwin Kalvelagen

unread,
Dec 18, 2014, 7:49:38 PM12/18/14
to gur...@googlegroups.com
Try to replace \ with / in the path of your input file.


----------------------------------------------------------------
Erwin Kalvelagen
Amsterdam Optimization Modeling Group
er...@amsterdamoptimization.com
http://amsterdamoptimization.com
----------------------------------------------------------------

--

Morgrim X

unread,
Dec 22, 2014, 8:01:05 PM12/22/14
to gur...@googlegroups.com, er...@amsterdamoptimization.com
Yes.  Thank you. I noticed that before and moved on.  I appreciate your help
Reply all
Reply to author
Forward
0 new messages