Load file from command line, elaborate, print output

Questions and problems about using polymake go here.
V123E
Posts: 1
Joined: 28 Oct 2020, 10:29

Load file from command line, elaborate, print output

Postby V123E » 28 Oct 2020, 10:46

Hi all! I am facing some troubles in doing a simple thing with polymake: What I would like to do is, from the command line, load a polytope in polymake, expressed through H-Description - equalities and inequalities -, print vertices, and have them saved on a file.
I have done a web search and I found that something like that should work:

Code: Select all

polymake 'my $p=load("MyPol.poly"); print $p->VERTICES;' > MyOut.txt
However, it sounds like my file "MyPol.poly" is not properly wrote, as I face the error

Code: Select all

line 2: ill-formed section header
I have tried three different formats for the .poly file:

Code: Select all

new Polytope(INEQUALITIES=>[...], EQUATIONS=>[...])

Code: Select all

Polytope(INEQUALITIES=>[...], EQUATIONS=>[...])

Code: Select all

(INEQUALITIES=>[...], EQUATIONS=>[...])
But the three of them return the same error and I am not able to figure out a suitable format. I should generate it automatically because it contains hundreds of inequalities and equalities.

Thank you for helping.

lkastner
Developer
Posts: 10
Joined: 27 May 2012, 23:35

Re: Load file from command line, elaborate, print output

Postby lkastner » 29 Oct 2020, 17:07

When using load the data needs to be in json(or previously xml) format. You can have a look at this as follows in polymake:

Code: Select all

$p = cube(2); $p->name="square"; save($p);
Then open the file square.poly to see what it looks like.

Maybe if you do the following you can fix your issue. Change the content of MyPol.poly to

Code: Select all

use application "polytope"; my $p = new Polytope(INEQUALITIES=>[...], EQUATIONS=>[...]); print $p->VERTICES; save_data($p->VERTICES, "vertices.txt");
and then run it with polymake --script MyPol.poly. Then there should be a file vertices.txt containing the vertices (as json/xml). Furthermore it should print the vertices to the screen.


Return to “Helpdesk”

cron