Error in reading a .lp file using lp2poly

Questions and problems about using polymake go here.
Sangha52
Posts: 10
Joined: 25 Feb 2021, 00:01

Error in reading a .lp file using lp2poly

Postby Sangha52 » 02 Mar 2021, 20:21

I'm trying to create a polytope from a lp given in
untitled.lp
(2.2 KiB) Downloaded 263 times
. It's giving me an error

ERROR: /Applications/polymake.app/Contents/Resources/polymake/bin/polymake: invalid expression in input line '  
C3: x#31 + x#41 + x#51 + x#61 + x#71 ' at /Applications/polymake.app/Contents/Resources/polymake/share/polymake/apps/polytope/perllib/LPparser.pm line 322.
Can you please help me sort this out? Thanks in advance!
FYI, I'm using the latest version of Polymake 4.3 on Mac OS. My objective is to identify all the facets of the polytope created from the constraint set of the given lp. Also, my problem is quite big as it has 42 variables and possibly around 80-100 constraints. Any advices are welcome.
Sincerely appreciate your time!

paffenholz
Developer
Posts: 211
Joined: 24 Dec 2010, 13:47

Re: Error in reading a .lp file using lp2poly

Postby paffenholz » 02 Mar 2021, 22:24

Your file is utf-8 encoded, while polymake expects a file that only contains the standard ascii characters. As long as you stick to letters/digits/spaces this is not a problem.

But utf-8 has several versions of a space character, and your file contains some of the "nonstandard" spaces. You can see this with a text editor that shows spaces, or if you switch the encoding.

You can get rid of them by rewriting your input, e.g. with

Code: Select all

cat untitled.lp | sed 's/[[:space:]]/ /g' > untitled_clean.lp
Andreas

opfer
Developer
Posts: 80
Joined: 04 Feb 2013, 11:12

Re: Error in reading a .lp file using lp2poly

Postby opfer » 02 Mar 2021, 23:45

On my systems (Linux, Windows), the above command did not replace some strange white space character. I had to replace it manually.

Here is my corrected file:
untitled.lp
(2.12 KiB) Downloaded 294 times
I did a few tests with it. The optimal value is 7 and I found 880 feasible solutions.

Best regards,
Thomas

Sangha52
Posts: 10
Joined: 25 Feb 2021, 00:01

Re: Error in reading a .lp file using lp2poly

Postby Sangha52 » 09 Mar 2021, 18:12

Thank you so much for your time & effort. The Polymake was able to read the corrected file you have attached. FYI, I have manually created this text file (i.e. manually entered the lp in the file) in the jupyter notebook & later saved it as a ".lp" file so that I can create a corresponding polytope using "lp2poly" command in Polymake.
Your file is utf-8 encoded, while polymake expects a file that only contains the standard ascii characters. As long as you stick to letters/digits/spaces this is not a problem.

But utf-8 has several versions of a space character, and your file contains some of the "nonstandard" spaces. You can see this with a text editor that shows spaces, or if you switch the encoding.

You can get rid of them by rewriting your input, e.g. with

Code: Select all

cat untitled.lp | sed 's/[[:space:]]/ /g' > untitled_clean.lp
I would like to add more variables & constraints to this lp. I guess it would still give me the same "space character" error. Is there as any way I can prefix it while entering? Also, did you use the above code in the text editor for windows? Any options to fix this in OS environment?

opfer
Developer
Posts: 80
Joined: 04 Feb 2013, 11:12

Re: Error in reading a .lp file using lp2poly

Postby opfer » 09 Mar 2021, 23:20

If you use "simple" text editors (e.g. Notepad, Notepad++ on Windows or vi, vim, nano, mc on Linux or Mac), I would not expect any such problems.

User avatar
gawrilow
Main Author
Posts: 422
Joined: 25 Dec 2010, 17:40

Re: Error in reading a .lp file using lp2poly

Postby gawrilow » 10 Mar 2021, 10:51

We should eventually teach the LP input parser to cope with all valid Unicode characters, not only with ASCII. After all, the names of variables and constraints are pure labels used for text output and nothing else, we should not impose any unnecessary restrictions on them.

Sangha52
Posts: 10
Joined: 25 Feb 2021, 00:01

Re: Error in reading a .lp file using lp2poly

Postby Sangha52 » 19 May 2021, 20:10

Thank you so much for all the timely & helpful replies!


Return to “Helpdesk”