## 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

I'm trying to create a polytope from a lp given in
untitled.lp
. 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.
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.

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

### Re: Error in reading a .lp file using lp2poly

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

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
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

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

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.

gawrilow
Main Author
Posts: 404
Joined: 25 Dec 2010, 17:40

### Re: Error in reading a .lp file using lp2poly

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

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